You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2026/10/17 15:03:50 UTC
svn commit: r1939201 - pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/multipdf
Author: tilman
Date: Sat Oct 17 15:03:49 2026
New Revision: 1939201
Log:
PDFBOX-6283: improve test to add link annotations and check them
Modified:
pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
Modified: pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java Sat Oct 17 15:03:26 2026 (r1939200)
+++ pdfbox/branches/2.0/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java Sat Oct 17 15:03:49 2026 (r1939201)
@@ -24,6 +24,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
@@ -57,6 +58,7 @@ import org.apache.pdfbox.pdmodel.common.
import org.apache.pdfbox.pdmodel.common.PDNumberTreeNode;
import org.apache.pdfbox.pdmodel.common.PDPageLabelRange;
import org.apache.pdfbox.pdmodel.common.PDPageLabels;
+import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDMarkedContentReference;
import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDObjectReference;
import org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure.PDParentTreeValue;
@@ -1617,6 +1619,27 @@ public class PDFMergerUtilityTest extend
document.addPage(page1);
document.addPage(page2);
+ List<PDAnnotation> ann0 = new ArrayList<PDAnnotation>();
+ PDAnnotationLink annLink0 = new PDAnnotationLink();
+ annLink0.setDestination(new PDNamedDestination("dest0"));
+ annLink0.setRectangle(new PDRectangle(10, 600, 100, 100));
+ ann0.add(annLink0);
+ page0.setAnnotations(ann0);
+
+ List<PDAnnotation> ann1 = new ArrayList<PDAnnotation>();
+ PDAnnotationLink annLink1 = new PDAnnotationLink();
+ annLink1.setDestination(new PDNamedDestination("dest1"));
+ annLink1.setRectangle(new PDRectangle(10, 600, 100, 100));
+ ann1.add(annLink1);
+ page1.setAnnotations(ann1);
+
+ List<PDAnnotation> ann2 = new ArrayList<PDAnnotation>();
+ PDAnnotationLink annLink2 = new PDAnnotationLink();
+ annLink2.setDestination(new PDNamedDestination("dest2"));
+ annLink2.setRectangle(new PDRectangle(10, 600, 100, 100));
+ ann2.add(annLink2);
+ page2.setAnnotations(ann2);
+
PDPageFitDestination dest0 = new PDPageFitDestination();
dest0.setPage(page0);
PDPageFitDestination dest1 = new PDPageFitDestination();
@@ -1656,6 +1679,9 @@ public class PDFMergerUtilityTest extend
// the destination must point to the imported page of the split document
PDPage importedPage = ((PDPageFitDestination) copied).getPage();
assertSame(splitDocument.getPage(0).getCOSObject(), importedPage.getCOSObject());
+ PDAnnotationLink annLink = (PDAnnotationLink) importedPage.getAnnotations().get(0);
+ PDNamedDestination namedDestination = (PDNamedDestination) annLink.getDestination();
+ assertEquals(expectedName, namedDestination.getNamedDestination());
}
}
}