Why is text truncated to PDF using Linux?

I am trying to format Date in Jasper Reports and it works with Windows, but not Linux. On Linux, the resulting text is truncated.

The code:

JRXML:

<parameter name="timestamp" class="java.util.Date"/>
[...]
<textField>
    <reportElement x="0" y="0" width="50" height="16" uuid="0007846a-26f1-457a-a198-67a2f7c8417c">
        <property name="local_mesure_unitwidth" value="pixel"/>
        <property name="com.jaspersoft.studio.unit.width" value="px"/>
        <property name="local_mesure_unitx" value="pixel"/>
        <property name="com.jaspersoft.studio.unit.x" value="px"/>
        <property name="local_mesure_unity" value="pixel"/>
        <property name="com.jaspersoft.studio.unit.y" value="px"/>
        <property name="local_mesure_unitheight" value="pixel"/>
        <property name="com.jaspersoft.studio.unit.height" value="px"/>
    </reportElement>
    <box padding="2"/>
    <textElement textAlignment="Left" verticalAlignment="Top">
        <font size="8" pdfFontName="Helvetica" pdfEncoding="Cp1250" isPdfEmbedded="true"/>
    </textElement>
    <textFieldExpression><![CDATA[DATEFORMAT($P{timestamp},"dd.MM HH:mm")]]></textFieldExpression>
</textField>

Maven Dependencies:

<dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports</artifactId>
    <version>5.6.0</version>
</dependency>
<dependency>
    <groupId>net.sf.jasperreports</groupId>
    <artifactId>jasperreports-functions</artifactId>
    <version>5.6.0</version>
</dependency>

Java:

private byte[] createPdf() {

    try {
        InputStream is = getClass().getResourceAsStream("MyReport.jasper");
        JasperReport jasperReport = (JasperReport) JRLoader.loadObject(is);
        Map<String, Object> parameters = new HashMap<String, Object>();
        parameters.put("timestamp", new Date());
        JRDataSource jrDataSource = new JRBeanCollectionDataSource(new Vector(), false);
        JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, jrDataSource);
        byte[] pdf = JasperExportManager.exportReportToPdf(jasperPrint);
        return pdf;
    } catch (JRException e) {
        throw new RuntimeException("Could not create PDF.", e);
    }
}

Results:

Result with Windows:

Windows

Result with Linux:

Linux

PDF Properties:

Both generated PDF files have the same font properties in Acrobat Reader for Windows:

PDF Properties

As you can see, the font is not embedded. (The second "Helvetica" font disappears if I add the dependency jasperreports-fontsand remove the attributes pdfFontName, pdfEncodingand isPdfEmbedded).

Research:

I read:

, , , .

"Helvetica", , , . Wikipedia:

PDF- PDF

qaru.site/questions/1652089/...:

iText, iText , , Adobe Reader .

:

Windows Linux? / ?

+4
2

, macchine Java.

: JVM Jasper,

jasper- - -

jasperreports-font.jar, :

DejaVu Sans
DejaVu Serif
DejaVu Sans Mono

fontName="DejaVu Sans", , .ttf ( jasper- ).

, JVM , .

, , .ttf, IDE.

+3

, - - , , , , .

, ( ), - ( ), Unicode.org ( ), , , .

OSX Windows - " ", .

PDF , . , .

, Helvetica Arial, : , - , , , , ASCII , . Arial - Windows, .

0

Source: https://habr.com/ru/post/1652085/


All Articles