Is there any API to compress a PDF?

Hi,

I am creating 10 PDFs and finally concatenating them to make a single PDF. Now I want to compress this final PDF.

Is there any API which provide this facility in Aspose ?

I am using Aspose Java 2.7.0, pdf kit 3.7.0.

Hi Sriman,

You may use setCompressionLevel property to set the compression level before concatenating the PDF files.

I hope this helps. If you find any further questions, please do let us know.
Regards,

I tried with the approach you suggested. But the final PDF size after concatenation is coming same for all compression level.

I tried with default(without setting any value), 1, 6, 8.

Sample code :

Settings.setCompressionLevel(1);

PdfFileEditor pdfEditor = new PdfFileEditor();

pdfEditor.concatenate(inStreams, outStream);

Do I need to do some other changes too ?

Hi Sriman,

Please share the input PDF file with us, so we could investigate the issue at our end. You’ll be updated with the results the accordingly.

We’re sorry for the inconvenience.
Regards,

Hi,

Attaching the sample PDF.

Hi Sriman,

It looks like the attached PDF file is the concatenated output file. Could you please share the input PDF files which you’re trying to concatenate?

Regards,

Hi,

This is just a example. You can test this for any PDF. However I am attaching the single page PDF.Concatenate this same PDF twice or thrice and try to compress. Size is constant irrespective of the copmression level.

Hi Sriman,

Thank you very much for sharing the sample PDF file. As I can see, this PDF contains only image. However, Aspose.Pdf.Kit for Java currently allows you to compress only those PDF files which contain text information. In case of the files containing both text or images, only text data is compressed. I’m afraid, it is unable to compress images at the moment. However, I have logged a new feature request as PDFKITJAVA-30171 in our issue tracking system to support image compression as well. You’ll be notified via this forum thread once it is supported in future.

We’re sorry for the inconvenience.
Regards,

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan