Closed elvisbegovic closed 7 months ago
What you think @mkl-public , if needed we can fix this optionally :
/* @param differIdenticalPage : when we have have identical page objet we should enable this option to fix som reader tool */
public static void optimize(PDDocument pdDocument, Boolean differIdenticalPage) throws IOException {
// reassure we keep multiple identical page objet
if(differIdenticalPage != null && differIdenticalPage == true) {
for (int i = 0; i < pdDocument.getPages().getCount(); i++) {
PDPage page = pdDocument.getPages().get(i);
COSDictionary customDict = new COSDictionary();
customDict.setInt("CustomCounter", i + 1);
page.getCOSObject().setItem("CustomCounterEntry", customDict);
}
}
optimize(pdDocument);
}
Thanks!
Make optimize method less agressive to fix issue when page are identical. For that we make all pages of a PdDocument different by adding custom entry to the page dictionary (page counter). Result: file output will be a few bytes larger.