Hi mithunk, Two things I can think of given your description: The measurements are in milipoints. Divide by 1000 when finished to get points. Only add relevant blocks. Given a structure like
<block A> <block B /> <block C /> </block A> <block D> <block E /> <block F /> </block D> to get the position of block F you add the height of blocks E and A. Basically: previous siblings of targetnode and all of its parent nodes are interesting. Regards, Georg Datterl ------ Kontakt ------ Georg Datterl Geneon media solutions gmbh Gutenstetter Straße 8a 90449 Nürnberg HRB Nürnberg: 17193 Geschäftsführer: Yong-Harry Steiert Tel.: 0911/36 78 88 - 26 Fax: 0911/36 78 88 - 20 www.geneon.de Weitere Mitglieder der Willmy MediaGroup: IRS Integrated Realization Services GmbH: www.irs-nbg.de Willmy PrintMedia GmbH: www.willmy.de Willmy Consult & Content GmbH: www.willmycc.de -----Ursprüngliche Nachricht----- Von: mithunk [mailto:mithunakulka...@yahoo.com] Gesendet: Dienstag, 5. Oktober 2010 22:14 An: fop-users@xmlgraphics.apache.org Betreff: Re: AW: AW: Identifying absolute position of a FO:Block Hi, I tried creating AreaTree for my XSL-FO. And as you suggested added bpda of all the block elements in the area tree (untill my block is hit). But the y position that I get after adding all these is wrong. I want to calculate the absolute position of this block (x and y coordinates). Please help, as I need to finish this POC in another day. Please also mention if it not possible in FOP. Thanks, Mithun Georg Datterl wrote: > > Hi, > > First: I had a look at IF, but AT is better suited for the task, IMHO. > > Now for some details: > > Here's a simple fo file with a named block: > > <?xml version="1.0" encoding="UTF-8"?> > <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> > <fo:layout-master-set> > <fo:simple-page-master master-name="x"> > <fo:region-body/> > </fo:simple-page-master> > </fo:layout-master-set> > <fo:page-sequence master-reference="x"> > <fo:flow flow-name="xsl-region-body"> > <fo:block> > <fo:block id="block-to-find"> > <fo:inline>testtext </fo:inline> > </fo:block> > </fo:block> > </fo:flow> > </fo:page-sequence> > </fo:root> > > Here's the area tree for this fo (fop test.fo -at test.xml): > > <?xml version="1.0" encoding="UTF-8"?> > <!--Produced by Apache FOP Version svn-trunk--> > <areaTree> > <pageSequence> > <pageViewport bounds="0 0 594720 792000" key="P1" nr="1" > formatted-nr="1" simple-page-master-name="x"> > <page> > <regionViewport ipd="594720" bpd="792000" > ipda="594720" bpda="792000" bap="0 0 0 0" is-viewport-area="true" rect="0 > 0 594720 792000"> > <regionBody ipd="594720" > bpd="792000" ipda="594720" bpda="792000" bap="0 0 0 0" > is-reference-area="true" name="xsl-region-body" ctm="[1.0 0.0 0.0 1.0 0.0 > 0.0]"> > <beforeFloat/> > <mainReference ipd="0" > bpd="0" bap="0 0 0 0" is-reference-area="true"> > > <flow > ipd="594720" bpd="14400" ipda="594720" bpda="14400" bap="0 0 0 0" > is-reference-area="true"> > > <block ipd="594720" bpd="14400" ipda="594720" bpda="14400" bap="0 0 0 0"> > > <block ipd="594720" bpd="14400" ipda="594720" bpda="14400" bap="0 0 0 0" > prod-id="block-to-find"> > > <lineArea ipd="594720" bpd="11100" ipda="594720" bpda="14400" bap="0 0 0 > 0" space-before="1650" space-after="1650"> > > <inlineparent ipd="38688" bpd="11100" ipda="38688" bpda="11100" bap="0 0 0 > 0" offset="0"> > > <text offset="0" baseline="8616" ipd="38688" bpd="11100" ipda="38688" > bpda="11100" bap="0 0 0 0" font-name="sans-serif" font-style="normal" > font-weight="400" font-size="12000" color="#000000"> > > <word offset="0">testtext</word> > > </text> > > </inlineparent> > > </lineArea> > > </block> > > </block> > </flow> > > </mainReference> > <footnote top-offset="0"/> > </regionBody> > </regionViewport> > </page> > </pageViewport> > </pageSequence> > </areaTree> > > Now look for the block element with attribute prod-id="block-to-find". > That's your target block. As Craig said, if the block spans more pages, > there may be more than one block with this attribute. > > Now you can get the width of the block (attribute ipd) and the height > (attribute bpd). Use ipda and bpda if you need the padding, too. Also see > http://wiki.apache.org/xmlgraphics-fop/AreaTreeXMLDocumentation or search > this mailing list for "area tree". > For the block's position in the page, add the height of all previous > blocks in the page. > > Regards, > > Georg Datterl > > ------ Kontakt ------ > > Georg Datterl > > Geneon media solutions gmbh > Gutenstetter Straße 8a > 90449 Nürnberg > > HRB Nürnberg: 17193 > Geschäftsführer: Yong-Harry Steiert > > Tel.: 0911/36 78 88 - 26 > Fax: 0911/36 78 88 - 20 > > www.geneon.de > > Weitere Mitglieder der Willmy MediaGroup: > > IRS Integrated Realization Services GmbH: www.irs-nbg.de > Willmy PrintMedia GmbH: www.willmy.de > Willmy Consult & Content GmbH: www.willmycc.de > > > -----Ursprüngliche Nachricht----- > Von: Craig Ringer [mailto:cr...@postnewspapers.com.au] > Gesendet: Dienstag, 5. Oktober 2010 02:35 > An: fop-users@xmlgraphics.apache.org > Cc: mithunk > Betreff: Re: AW: Identifying absolute position of a FO:Block > > On 4/10/2010 11:28 PM, mithunk wrote: >> >> Thanks Georg, >> >> I am new to FOP. Can you please help me with how to calculate the >> position >> by giving a block id. >> I modified my XSL with a block id (for a field), now dont know how to >> calculate the position. > > METHOD 1: > > Use fop to produce the intermediate "area tree" output from your XSL-FO. > See the documentation for details on that. > > Once you have the area tree, use xpath to find the block. IIRC the id > will be in the 'prod-id' attribute of the block(s) generated. If it's > broken across a page, column, etc there may be more than one element > generated. > > Once you've found the element(s) you should be able to work out the > position from the positioning attributes them and their parent elements. > > It's possible that the new intermediate format ("IF") is better than the > area tree for this, but I haven't worked with it much so all I can > suggest is generating it, looking at it, and seeing if it's useful. I > have the feeling the new IF doesn't include element IDs, but I may be > misremembering. > > -- > Craig Ringer > > Tech-related writing at http://soapyfrogs.blogspot.com/ > > --------------------------------------------------------------------- > To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org > For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org > > > -- View this message in context: http://old.nabble.com/Identifying-absolute-position-of-a-FO%3ABlock-tp29858679p29890837.html Sent from the FOP - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org