using the "standard" code to optimize images
- Code: Select all
PdfPageCollection pages = document.getPages();
for (int i = 0; i < pages.getCount(); i++) {
PdfPageBase page = pages.get(i);
if (page != null) {
PdfImageInfo[] infos = page.getImagesInfo();
if (infos != null) {
for (PdfImageInfo pdfImageInfo : infos) {
page.tryCompressImage(pdfImageInfo.getIndex());
}
}
}
}
I get an OutOfMemory exception when using some files with a lot of images.
The runtime also increase in a clearly non-linear fashion...
Thanks in advance
Guillaume PATRY