Search code examples
xsltapache-fop

Unable to display all lines in the region-start in the PDF file


I have following XML as input

<AFPXMLFile>
  <docs>
    <regList>
     </regList>
     <regList>
        <region>2</region>
        <secList>
          <col>2</col>
          <lines>
             <line>IBM BELGIUM SPRL/BVBA </line>
             <line>d'entreprise/Ondernemingsnr TVA / BTW</line>
             <line>405 912 336/03.28.1.3 DISPENSE </line>
          </lines>
        </secList>
       </regList>
       <regList></regList>
       <regList></regList>
     </docs>

MY xsl for the start region as follows:

   <xsl:when test="region = '2'">
           <fo:static-content flow-name="xsl-region-start">
                <xsl:for-each select="./secList/lines">
                    <xsl:for-each select="node()">
                    <fo:block-container reference-orientation="90" white-space="pre" font-size="4pt" color="green">
                    <fo:block>
                          <xsl:value-of select="."/>
                          <fo:leader />
                    </fo:block>          
                    </fo:block-container>   
                    </xsl:for-each>
                 </xsl:for-each>
             </fo:static-content>    
        </xsl:when>

I my PDF file I see only the first line IBM BELGIUXxxx. I dont see the second and the third line. If I remove the orientation I see all three lines.

What am I missing?


Solution

  • If you want stack fo:block-container from top to bottom, you should explicitly specify @inline-progression-dimension to each fo:block-container. Here is the sample XSL-FO.

    <?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="spm" page-width="10.5in" page-height="10.5in">
                <fo:region-body margin-top="1in" margin-bottom="1in" margin-left="1in"
                    margin-right="1in" overflow="error-if-overflow"/>
                <fo:region-before extent="1in" precedence="true" display-align="after"/>
                <fo:region-start extent="1in"/>
                <fo:region-end extent="1in"/>
            </fo:simple-page-master>
        </fo:layout-master-set>
        <fo:page-sequence master-reference="spm" reference-orientation="from-page-master-region()"
            writing-mode="from-page-master-region()">
            <fo:static-content flow-name="xsl-region-before">
                <fo:block  border-bottom="1.5pt solid blue"/>
            </fo:static-content>
            <fo:static-content flow-name="xsl-region-start">
                <fo:block-container reference-orientation="90" text-align="right" inline-progression-dimension="15em">
                    <fo:block white-space="pre" font-size="9pt" color="green">IBM BELGIUM SPRL/BVBA</fo:block>
                </fo:block-container>
                <fo:block-container reference-orientation="90" text-align="right" inline-progression-dimension="15em">
                    <fo:block white-space="pre" font-size="9pt" color="green">d'entreprise/Ondernemingsnr TVA / BTW</fo:block>
                </fo:block-container>
                <fo:block-container reference-orientation="90" text-align="right" inline-progression-dimension="15em">
                    <fo:block white-space="pre" font-size="9pt" color="green">405 912 336/03.28.1.3 DISPENSE</fo:block>
                </fo:block-container>
            </fo:static-content>
            <fo:flow flow-name="xsl-region-body">
                <fo:block font-size="1.2em" space-before="2mm" space-before.conditionality="retain">Region-start test</fo:block>
                <fo:block>Body text.</fo:block>
                <fo:block>Body text.</fo:block>
                <fo:block>Body text.</fo:block>
                <fo:block>Body text.</fo:block>
                <fo:block>Body text.</fo:block>
            </fo:flow>
        </fo:page-sequence>
    </fo:root>
    

    [Formatting result via FOP]

    Formatting result via FOP

    Or if you want to set up <line> elements from left to right, generate fo:block-container per <lines> element.

    [Sample FO file]

    <?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="spm" page-width="10.5in" page-height="10.5in">
                <fo:region-body margin-top="1in" margin-bottom="1in" margin-left="1in"
                    margin-right="1in" overflow="error-if-overflow"/>
                <fo:region-before extent="1in" precedence="true" display-align="after"/>
                <fo:region-start extent="1in"/>
                <fo:region-end extent="1in"/>
            </fo:simple-page-master>
        </fo:layout-master-set>
        <fo:page-sequence master-reference="spm" reference-orientation="from-page-master-region()"
            writing-mode="from-page-master-region()">
            <fo:static-content flow-name="xsl-region-before">
                <fo:block  border-bottom="1.5pt solid blue"/>
            </fo:static-content>
            <fo:static-content flow-name="xsl-region-start">
                <fo:block-container reference-orientation="90" text-align="right">
                    <fo:block white-space="pre" font-size="9pt" color="green">IBM BELGIUM SPRL/BVBA</fo:block>
                    <fo:block white-space="pre" font-size="9pt" color="green">d'entreprise/Ondernemingsnr TVA / BTW</fo:block>
                    <fo:block white-space="pre" font-size="9pt" color="green">405 912 336/03.28.1.3 DISPENSE</fo:block>
                </fo:block-container>
            </fo:static-content>
            <fo:flow flow-name="xsl-region-body">
                <fo:block font-size="1.2em" space-before="2mm" space-before.conditionality="retain">Region-start test</fo:block>
                <fo:block>Body text.</fo:block>
                <fo:block>Body text.</fo:block>
                <fo:block>Body text.</fo:block>
                <fo:block>Body text.</fo:block>
                <fo:block>Body text.</fo:block>
            </fo:flow>
        </fo:page-sequence>
    </fo:root>
    

    [Formatting result via FOP]

    enter image description here

    Hope this helps your stylesheet development.