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

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

我有以下 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>

我的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。我没有看到第二行和第三行。如果我删除方向,我会看到所有三行。

我错过了什么?

如果你想从上到下堆叠 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 格式化结果]

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

[示例 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 格式化结果]

希望这对您的样式表开发有所帮助。