2016-05-16 89 views
0

我正在使用Apache FOP生成PDF。我想包裝文本當且僅當超過表格單元格長度。我試着用wrap-option =「wrap」。當它找到空間本身時,它會分割這個詞。它不會查看錶格單元的長度是否超過。WRAP選項在超出長度前包裝該單詞

<fo:table width="33%" table-layout="fixed" position="fixed" margin-top="-21.5%" margin-left="68.5%"> 
    <fo:table-body> 
    <fo:table-row> 
     <fo:table-cell padding-bottom="3px" text-align="left" width="5cm" margin-left="1.2cm"> 
     <fo:block-container> 
      <fo:block wrap-option="wrap"> 
      <fo:inline font-family="TimesNewRoman" font-weight="bold"> 
       <xsl:value-of select="test/test1"/> 
      </fo:inline> 
      </fo:block> 
     </fo:block-container> 
     </fo:table-cell> 
    </fo:table-row> 
    </fo:table-body> 
</fo:table> 

例如:我有一個字符串象下面這樣:

TEST 1 TEST 2 TEST 3 

當我使用上述XSLT生成PDF,它顯示像下面

TEST 
1 
TEST 
2 
TEST 
3 

Eventhough,它具有更寬度,它是分裂和顯示。

我想怎麼顯示是

TEST 1 TEST ..if length exceeds the length 
2 TEST 3 

enter image description here

誰能幫助我在這?

+1

你能爲fo:table-cell添加實際的FO XML標記嗎?你能添加格式化表格單元格的屏幕截圖嗎?你所描述的並不是我期望會發生的事情。你爲'fo:table'設置了一個邊距或開始縮進?這是發生在所有列還是隻在一列中? –

+0

它正在發生所有的列。另外,我正在爲該表單元格設置保證金屬性。 –

+0

\t \t \t的 \t \t \t的 \t \t \t \t的 \t \t \t \t \t的 \t \t \t \t \t \t的 \t \t \t \t \t \t \t的 \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t

回答

1

fo:table-body添加start-indent="0pt"

<fo:table width="33%" table-layout="fixed" 
     position="fixed" margin-top="-21.5%" margin-left="68.5%"> 
    <fo:table-body start-indent="0pt"> 
    <fo:table-row> 
     <fo:table-cell padding-bottom="3px" text-align="left" width="5cm"> 
     <fo:block> 
      <fo:inline font-family="TimesNewRoman" font-weight="bold" 
     > TEST 1 TEST 2 TEST 3 </fo:inline> 
     </fo:block> 
     </fo:table-cell> 
    </fo:table-row> 
    </fo:table-body> 
</fo:table> 

fo:table/@margin-left是設置工作了start-indent特質每個fo:table-cell的內容時所使用的繼承start-indent值。詳情請參閱https://www.w3.org/TR/xsl11/#refine-margin-space-indent

此外,fo:table-cell/@margin-leftfo:block-containerfo:block/@wrap-option沒有添加任何東西。

+0

謝謝。它運作良好。 –

+0

另外我想將表格單元格設置爲特定位置。我試着用。它不適用於我。可以讓我知道,我必須在這種情況下做什麼 –

+0

請開始另一個問題,解釋你想要做什麼。 –