Skip to content

output a list of JasperPrint object to PDF got blank pages before each item #7

@richso

Description

@richso

I have a report which composed of different Jasperreport templates, e.g. template1 and template2, therefore we use ArrayList to collect the JasperPrint Objects and generate the report into PDF like this:

JasperFillManager fm = new JasperFillManager();
JasperPrint jp1 = fm.fillReport("template1.jasper", ...);
JasperPrint jp2 = fm.fillReport("template1.jasper", ...);
List list = new java.util.ArrayList();
list.add(jp1);
list.add(jp2);
JRPdfExporter pdfExporter = new JRPdfExporter();

///////////////////////////////////////////////////////////////////////////////////
// NOTE: this set of code is required for using itext7 support instead of itext2

JasperReportsContext defJrCtx = net.sf.jasperreports.engine.DefaultJasperReportsContext.getInstance();
defJrCtx.setProperty(pdfExporter.PDF_PRODUCER_FACTORY_PROPERTY, "com.jaspersoft.jasperreports.export.pdf.modern.ModernPdfProducerFactory");

////////////////////////////////////////////////----------------------------------

pdfExporter.setExporterInput(SimpleExporterInput.getInstance(list));
FileOutputStream fos = new FileOutputStream('test.pdf')
pdfExporter.setExporterOutput(new SimpleOutputStreamExporterOutput(fos));
pdfExporter.exportReport();

The above code will generate the PDF file with an extra blank page before each items in the ArrayList, i.e. before contents of template1 and before contents of template2; on commenting out the itext7 support code (use itext2), the output will not have the extra blank pages; is there any way to instruct the ModernPdfProducerFactory / itext7 to NOT outputting the extra blank pages?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions