[#10661] - The JasperPrint on BaseReportFiller class ignore JasperReportsContext parameter

Jaspersoft Community 'Read-Only' as of July 8, 2022

Transition to New TIBCO Community Just Weeks Away

You can still search, review wiki content, and review discussions in read-only mode. Please email community@tibco.com with questions or issues requiring TIBCO review or response.

Category:
Bug report
Priority:
Normal
Status:
Acknowledged
Project: Severity:
Major
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:

Hello team.

I’ve found a problem trying to use the V6.4 JasperReport library with local-context instead of the default one.

First off all I’ve initialized a local-context with this code:
LocalJasperReportsContext localContext = new LocalJasperReportsContext(DefaultJasperReportsContext.getInstance());

Then I use this local-context everywhere is possible:

JRPropertiesUtil reportProperties = JRPropertiesUtil.getInstance(localContext);
JRSwapFile(localContext, VIRTUALIZER_TEMP_SUBFOLDER.getAbsolutePath(),ReportConstant.VIRTUALIZER_BLOCK_SIZE,ReportConstant.VIRTUALIZER_GROW_BY_BLOCKS);
JasperFillManager jasperFillManager = JasperFillManager.getInstance(localContext);
JasperReport report = theMainReport.getCodeCompiled();
report.setJasperReportsContext(localContext);
jasperPrint = jasperFillManager.fill(codeCompiled, params, dbConnection);
exporter = new JRPdfExporter(localContext);

After that I’ve tried to generate a PDF/a-1 report but I’ve got the error:

Caused by: com.lowagie.text.pdf.PdfXConformanceException: All the fonts must be embedded. This one isn't: Helvetica
at com.lowagie.text.pdf.internal.PdfXConformanceImp.checkPDFXConformance(Unknown Source)
at com.lowagie.text.pdf.PdfWriter.addSimple(Unknown Source)
at com.lowagie.text.pdf.PdfContentByte.setFontAndSize(Unknown Source)
at com.lowagie.text.pdf.PdfDocument.writeLineToContent(Unknown Source)
at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
at com.lowagie.text.pdf.ColumnText.go(Unknown Source)
at net.sf.jasperreports.engine.export.JRPdfExporter.writePageAnchor(JRPdfExporter.java:1015)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReportToStream(JRPdfExporter.java:927)
at net.sf.jasperreports.engine.export.JRPdfExporter.exportReport(JRPdfExporter.java:552)

In the local context properties I’ve forced to use another font then the 'Helvetian' font reported on the error.
The 'Helvetian' is the default PDF document font overridden in the local context.

After a debug session on API I’ve found this code:

public BaseReportFiller(JasperReportsContext jasperReportsContext, JasperReport jasperReport,
FillerParent parent) throws JRException
{
JRGraphEnvInitializer.initializeGraphEnv();

setJasperReportsContext(jasperReportsContext);
……
jasperPrint = new JasperPrint();

/*suggest jasperPrint context initialization*/

factory = initFillFactory();
……

So my question is:
- is it correct to create a JasperPrint instance without set it to current context?

During a debug session I’ve forced this JasperPrint to use the current-context and the report generation succeeded without error!
I suggest to add this line of code after the JasperPrint creation:

/*Proposed code*/
jasperPrint.setJasperReportsContext(jasperReportsContext)

Andrea

v6.3.1
jasper library
andrea.canu's picture
Joined: Mar 15 2018 - 5:55am
Last seen: 1 year 7 months ago

4 Comments:

#1
  • Status:New» Acknowledged
#2

Any update on that issue?

#3
  • Severity:Minor» Major
#4

We're currently considering the fix.

Note that for the moment you can do jasperPrint.setJasperReportsContext in your own code (after the jasperFillManager.fill call).

Regards,
Lucian

Feedback
randomness