I'm migrating from itext 2.1.7 to OpenPDF. The same PDFs being generated are 3x the size with OpenPDF. Are there methods for optimizing the file size? Should I expect the file size to be close to equivalent?
Hello. As part of cleaning up OpenPDF from the old iText-legacy-code, some image codecs were removed from OpenPDF, because we didn't want to maintain image codecs (it's complicated!), and we wanted to use the image codecs which were provided by the native Java JVM libraries and other Java libraries instead. This was also part of removing uncertainties about the origin and license of some parts of the code, since this was sometimes questionable in old iText versions; as part of the license of source code cleanup process done in OpenPDF. I suggest two possible ways forward for you:
Try converting the images to different formats before you add them to OpenPDF. For example, in my experience, JPEG images compress nicely and will result in smaller PDF files.
If you are interested, you can contribute to OpenPDF, to improve this part of the code-base. Pull-requests welcome!
Since we don't know what you are doing it is difficult to tell: Creating PDFs from scratch, Splitting, Merging, Editing ....
But depending on your use case there are also certain methods available:
I am the originals poster's co-worker and I ended up calling setFullCompression on the PDFwriter and it significantly reduced the size of the PDF file. It doesn't explain why the original file was over 3 times bigger but at least it's a smaller size now. We were not using pdfcopy/PdfSmartCopy and we also do not have any images in the PDFs in question. The files only contain plain text. and we are creating pdfs from scratch.
thx for help!
Most helpful comment
I am the originals poster's co-worker and I ended up calling setFullCompression on the PDFwriter and it significantly reduced the size of the PDF file. It doesn't explain why the original file was over 3 times bigger but at least it's a smaller size now. We were not using pdfcopy/PdfSmartCopy and we also do not have any images in the PDFs in question. The files only contain plain text. and we are creating pdfs from scratch.
thx for help!