Jump to content
JasperReports Library 7.0 is now available ×

JRXML file looks fine in Jaspersoft Studio and JasperViewer, looks terrible as PDF


zbigniew.nitecki
Go to solution Solved by zbigniew.nitecki,

Recommended Posts

Hi,

I have a problem with my JRXML file created in Jaspersoft Studio. When I'm previewing the file in Studio, or when I'm using the Java class JasperViewer - everything looks PERFECT, exactly as in the Report Design view.

But when I am trying to export it to the PDF file like this:

InputStream invoiceJasper = MainJasper.class.getResourceAsStream("/invoices/invoice.jrxml");InputStream taskTableJasper = MainJasper.class.getResourceAsStream("/invoices/invoice_sub.jrxml");JasperDesign mainReportDesign = JRXmlLoader.load(invoiceJasper);JasperDesign tableReportDesign = JRXmlLoader.load(taskTableJasper);JasperReport report = JasperCompileManager.compileReport(mainReportDesign);JasperReport table = JasperCompileManager.compileReport(tableReportDesign);mainReport = JasperFillManager.fillReport(report, map, new JREmptyDataSource());tableReport = JasperFillManager.fillReport(table, map, new JREmptyDataSource());List<JasperPrint> printList = new ArrayList<>();printList.add(mainReport);printList.add(tableReport);JRPdfExporter exporter = new JRPdfExporter();exporter.setExporterInput(SimpleExporterInput.getInstance(printList)); //Set as export input my list with JasperPrint sexporter.setExporterOutput(new SimpleOutputStreamExporterOutput("/home/znitecki/output.pdf")); //or any other out streaamSimplePdfExporterConfiguration configuration = new SimplePdfExporterConfiguration();configuration.setCreatingBatchModeBookmarks(true); //add this so your bookmarks work, you may set other parametersexporter.setConfiguration(configuration);exporter.exportReport();[/code]

Everything is falling apart. The main design remains intact, but the font setting is lost (In the designer I am using Times New Roman font), and almost all the polish characters used in text (ąłęćźż) are missing. They just dissapear, when I have a word: BĘDĄCYCH, all that remains in the PDF file is BDCYCH. It also looses any styling (i have a few places where I am using markup = html, and the bold text is no longer bold...)

THE SAME THING happens when I am trying to export the PDF file FROM Jaspersoft Studio. A regular preview is 100% correct with correct fonts and polish characters, but the export function looses all the fonts and html styling too.

I am working on UBUNTU 18.04, I have the ubuntu-restricted-extras package installed...

Am I missing something in my operating system? or in the Jaspersoft Studio configuration? Or the JRXML file configuration? Or something in the JAVA code?

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

  • Solution

I have solved the problem with exporting from the Jaspersoft Studio by adding the font path in Window->Preferences->Fonts. The problem with Java-side was simple to solve, I have found out that I have to select used fonts from Window-Preferences-Fonts and export them as a Jar (as fonts.jar), and add them to my classpath.

I am using Gradle so i have created a libs directory in the root folder of the project, and the configuration looks like this:

build.gradle:

dependencies {   ...   compile files('libs/fonts.jar')   ...}[/code]

 

Link to comment
Share on other sites

  • 2 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...