无法显示区域中的所有行 - 从PDF文件开始

时间:2017-08-13 21:03:36

标签: xslt apache-fop

我有以下XML作为输入

<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如下:

   <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>

我的PDF文件我只看到第一行IBM BELGIUXxxx。我没看到第二行和第三行。如果我删除了方向,我会看到所有三条线。

我错过了什么?

1 个答案:

答案 0 :(得分:0)

如果您希望堆栈fo:block-container自上而下,则应明确指定@inline-progression-dimension到每个fo:block-container。以下是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>

[通过FOP格式化结果]

Formatting result via FOP

或者,如果您想从左到右设置<line>元素,请按fo:block-container元素生成<lines>

[样本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">
                <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>

[通过FOP格式化结果]

enter image description here

希望这有助于您的样式表开发。