Skip to content

Commit 65d723f

Browse files
committed
PDFBOX-6018: add test for orphan popup annotations
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1926333 13f79535-47bb-0310-9956-ffa450edef68
1 parent 8fd7cfb commit 65d723f

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,6 +1437,37 @@ void testSplitWithPgEntryAtTheTop() throws IOException
14371437
}
14381438
}
14391439

1440+
/**
1441+
* PDFBOX-6018: Test split a PDF with popup annotations that are not in the annotations list.
1442+
* Verify that after splitting, they still link back to their markup annotation and these to the
1443+
* page.
1444+
*
1445+
* @throws IOException
1446+
*/
1447+
@Test
1448+
void testSplitWithOrphanPopupAnnotation() throws IOException
1449+
{
1450+
try (PDDocument doc = Loader.loadPDF(new File(SRCDIR, "PDFBOX-6018-099267-p9-OrphanPopups.pdf")))
1451+
{
1452+
Splitter splitter = new Splitter();
1453+
List<PDDocument> splitResult = splitter.split(doc);
1454+
assertEquals(1, splitResult.size());
1455+
try (PDDocument dstDoc = splitResult.get(0))
1456+
{
1457+
assertEquals(1, dstDoc.getNumberOfPages());
1458+
PDPage page = dstDoc.getPage(0);
1459+
List<PDAnnotation> annotations = page.getAnnotations();
1460+
assertEquals(2, annotations.size());
1461+
PDAnnotationText ann0 = (PDAnnotationText) annotations.get(0);
1462+
PDAnnotationText ann1 = (PDAnnotationText) annotations.get(1);
1463+
assertEquals(page, ann0.getPage());
1464+
assertEquals(page, ann1.getPage());
1465+
assertEquals(ann0, ann0.getPopup().getParent());
1466+
assertEquals(ann1, ann1.getPopup().getParent());
1467+
}
1468+
}
1469+
}
1470+
14401471
/**
14411472
* PDFBOX-5939: merge a file with an outline that has itself as a parent without producing a
14421473
* stack overflow.
Binary file not shown.

0 commit comments

Comments
 (0)