2017-05-31 69 views
1

有關於這個主題的左右,但一些相關的問題都沒有解決(最接近的一個here在文本框用粗體樣式的文字越來越截斷分頁

我有很長的文本輸入文本字段在jasper報告中,如果分割文本具有粗體文本,則頁面中斷的部分文本會被截斷。如果分割文本是簡單的,它工作正常。

看起來好像JasperReports如果輸入文本帶有粗體html標籤,並且在導出爲PDF時剪切剩餘單詞,則引擎無法計算頁面中的最大字符數。我使用JasperReports的6.2.0

這是源代碼:

<band height="40" splitType="Stretch"> 
    <textField isStretchWithOverflow="true" isBlankWhenNull="true"> 
     <reportElement positionType="Float" stretchType="RelativeToBandHeight" x="30" y="10" width="510" height="20" isPrintWhenDetailOverflows="true"> 
      <property name="local_mesure_unity" value="pixel"/> 
      <property name="com.jaspersoft.studio.unit.y" value="px"/> 
      <property name="local_mesure_unitx" value="pixel"/> 
      <property name="com.jaspersoft.studio.unit.x" value="px"/> 
      <property name="local_mesure_unitwidth" value="pixel"/> 
      <property name="com.jaspersoft.studio.unit.width" value="px"/> 
      <property name="local_mesure_unitheight" value="pixel"/> 
      <printWhenExpression><![CDATA[$P{myInputData} != null]]></printWhenExpression> 
     </reportElement> 
     <textElement textAlignment="Justified" markup="html"> 
      <font fontName="ArialExtendedJasper"/> 
     </textElement> 
     <textFieldExpression><![CDATA[$P{myInputData}]]></textFieldExpression> 
    </textField> 
</band> 

編輯: 添加字體擴展屬性

<?xml version="1.0" encoding="UTF-8"?> 
<fontFamilies> 
    <fontFamily name="ArialExtendedJasper"> 
    <normal>fonts/ArialExtendedJasper/arial.ttf</normal> 
    <bold>fonts/ArialExtendedJasper/arialbd.ttf</bold> 
    <italic>fonts/ArialExtendedJasper/ariali.ttf</italic> 
    <boldItalic>fonts/ArialExtendedJasper/arialbi.ttf</boldItalic> 
    <pdfEncoding>Identity-H</pdfEncoding> 
    <pdfEmbedded>true</pdfEmbedded> 
    <exportFonts> 
    </exportFonts> 
    </fontFamily> 
</fontFamilies> 
+1

你嘗試過不同的字體嗎?你在使用字體擴展嗎? –

+0

您是否嘗試刪除標記? –

+1

如果我猜這是一個典型的[font extensions](https://stackoverflow.com/documentation/jasper-reports/5773/font-extensions)問題。 –

回答

0

Alex和皮特是正確的,它是一個字體擴展問題,我改變了字體(source .ttf文件),這個問題不會再發生。

我從互聯網上下載了宋體字體,但並不知道這種字體是授權的,而且您發現的字體並不可靠。

現在我正在使用Google Fonts,他們是免費的,作品完美!