Jump to content

Recommended Posts

Posted
Hi, I am using jasper library 6.1.0 with Java1.6 to generate pdf's using jrxml templates designed in Jaspersoft studio.  the size of pdf generated using jasper is around 200kb whereas the pdf generated with XSLFO(Apache FOP) is only 60kb with the same data on PDF. I  need help on reducing the size of the document as this is our client requirement.

I tried with pdf compression supported by jasper, but none of them reduced the pdf size.

 

 

By adding  property in jrxml: 

 

<property name="net.sf.jasperreports.export.pdf.compressed" value="true"/>

 

By setting compression on export:

 

JRPdfExporter PdfExporter = new JRPdfExporter ();

PdfExporter.setExporterInput(SimpleExporterInput.getInstance(jasperPrintList));

PdfExporter.setExporterOutput(new SimpleOutputStreamExporterOutput(outputFileName));

SimplePdfExporterConfiguration config = new SimplePdfExporterConfiguration();

config.setPdfVersion(PdfVersionEnum.VERSION_1_5);

config.setCompressed(true);

PdfExporter.setConfiguration(config);

PdfExporter.exportReport();

 

Also tried with PdfSmartCopy:

Document finalInvoiceDocument = new Document();

PdfSmartCopy copy = new PdfSmartCopy(finalInvoiceDocument,fos);

copy.setFullCompression();

copy.setPdfVersion(PdfWriter.PDF_VERSION_1_5);

PdfReader reader = new PdfReader(finalInvoice);

 

Using PdfStamper:

PdfStamper stamper = new PdfStamper(reader, new FileOutputStream("test.pdf"), PdfWriter.VERSION_1_5);

stamper.setFullCompression();

stamper.getWriter().setCompressionLevel(9);

 

All the approaches resulted in same file size, Can anyone let me know how to address this issue?

I have tried with online tool for compressing jasper generated PDF and that was able to compress to 80kb which is good.But I can't use that in my project.

 

Appreciate you help. Thanks in advance.

 

-Saroj

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Posted

Thankyou for responding Hozawa.

There are five fonts in PDF, four of them are specified in jrxml template and one is added by jasper (Helvetica-Bold) by default,
Is there anyway I can remove Helvetica-Bold from the report.

    1. ArialUnicodeMS (Embedded Subset), Type:TrueType (CID),  Encoding:Identity-H
    2. ArialUnicodeMS-Bold (Embedded Subset), Type:TrueType (CID),  Encoding:Identity-H
    3. ArialUnicodeMS-Bold-Italic (Embedded Subset), Type:TrueType (CID),  Encoding:Identity-H
    4. OCRAExtended (Embedded Subset), Type:TrueType (CID),  Encoding:Identity-H
    5. Helvetica-Bold, Type:Type1,  Encoding:Ansi

-Saroj

Posted

Hi Hozawa, I am not embedding fonts anywhere in the code, but when I extract the fonts from pdf, I get .afm and .cff files. .cff files are much larger

compared to the .cff files extracted from xslfo generated pdf. How does jasper support subsetting of fonts?

-Saroj

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...