Search code examples
javafontsjasper-reportsexport-to-pdf

JasperReports, export to PDF, blank new lines


JasperReports library seems to be miscalculating how many new lines the text field need to fit all its contents. In JasperReports Studio (in preview) everything looks fine, but not when exporting to PDF from my application.

I've read PDF FAQ from JasperReports and I tried setting PROPERTY_FORCE_LINEBREAK_POLICY in the report to true, but this didn't make any difference. I also experimented with various fonts, but then in runtime Java complained about missing font in AWT, so I guess my default font (SansSerif) is just fine.

When I print "english only" version of the report, then everything looks okay, because all texts are about a half in length, but when using longer texts (like in example below) then this line miscalculation happens.

Here is how it looks right now and I marked unwanted extra lines with red: enter image description here

Since I've tried with both hints from JasperReport's PDF FAQ, what else can I do?


Solution

  • I found the solution:

    1. Switch all fonts to Dejavu (I used to use default fonts)
    2. Have a jasperreports-fonts extension included in the project.

    The new font is a tiny bit wider, but that's okay. Other than that it looks very alike.