Author: tilman Date: Sun Apr 28 17:46:06 2024 New Revision: 1917402 URL: http://svn.apache.org/viewvc?rev=1917402&view=rev Log: PDFBOX-5809: revert because it changes source document and interferes with the structure tree changes in splitter
Modified: pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java Modified: pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java?rev=1917402&r1=1917401&r2=1917402&view=diff ============================================================================== --- pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java (original) +++ pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/PDDocument.java Sun Apr 28 17:46:06 2024 @@ -62,8 +62,6 @@ import org.apache.pdfbox.pdmodel.encrypt import org.apache.pdfbox.pdmodel.font.PDFont; import org.apache.pdfbox.pdmodel.graphics.color.PDDeviceRGB; import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotation; -import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationMarkup; -import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationPopup; import org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget; import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceDictionary; import org.apache.pdfbox.pdmodel.interactive.annotation.PDAppearanceStream; @@ -693,15 +691,6 @@ public class PDDocument implements Close { PDPage importedPage = new PDPage(new COSDictionary(page.getCOSObject()), resourceCache); importedPage.getCOSObject().removeItem(COSName.PARENT); - - // PDFBOX-5809: avoid orphan pages through beads and annotations - if (importedPage.getCOSObject().containsKey(COSName.B)) - { - importedPage.getCOSObject().removeItem(COSName.B); - LOG.warn("/B entry (beads) of source page is not imported to destination page"); - } - importedPage.getAnnotations().stream().forEach(ann -> fixAnnotation(ann, importedPage)); - PDStream dest = new PDStream(this, page.getContents(), COSName.FLATE_DECODE); importedPage.setContents(dest); addPage(importedPage); @@ -717,30 +706,6 @@ public class PDDocument implements Close } /** - * Avoid orphan page references in annotations. - * - * @param ann - * @param importedPage - */ - private void fixAnnotation(PDAnnotation ann, PDPage importedPage) - { - if (ann.getCOSObject().containsKey(COSName.P)) - { - ann.setPage(importedPage); - } - // getPopup() result of markup annotations needs not to be fixed, one can assume this one - // is in the page annotation list - if (ann instanceof PDAnnotationPopup) - { - PDAnnotationMarkup parentAnnotation = ((PDAnnotationPopup) ann).getParent(); - if (parentAnnotation != null) - { - fixAnnotation(parentAnnotation, importedPage); - } - } - } - - /** * Determine the highest object number from the imported page to avoid mixed up numbers when saving the new pdf. * * @param importedPage the imported page.