2017-08-13 12 views
0

我有以下XML作爲輸入無法顯示在該地區開始所有線路中的PDF文件

<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。我沒有看到第二和第三行。如果我刪除方向,我會看到所有三行。

我缺少什麼?

回答

0

如果您希望自上而下堆棧fo:block-container,則應該明確指定每個fo:block-container@inline-progression-dimension。這裏是示例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>元素。 [通過FOP格式化結果]

[樣品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> 

enter image description here

希望這有助於你的樣式表的發展。

+0

感謝您回覆我的問題。對不起,我忘了提及行數是動態的,在一段中可以是3行,而在另一段中可以是2等。 – Madhu

+0

@Madhu如果每行的行數(或內容)數量不同,您應該生成fo:按章節單位的頁面順序。這可以分別生成fo:region的靜態內容。 – tmakita

+0

感謝您的建議。這個內嵌的進程尺寸=「15em」屬性有所幫助。我在PDF文件中顯示了所有3行。雖然它沒有在它們之間添加換行符。我會努力的。 – Madhu

相關問題