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 2022/06/12 08:09:04 UTC
svn commit: r1901836 - /pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
Author: tilman
Date: Sun Jun 12 08:09:04 2022
New Revision: 1901836
URL: http://svn.apache.org/viewvc?rev=1901836&view=rev
Log:
PDFBOX-4892: optimize, as suggested by Valery Bokov
Modified:
pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java?rev=1901836&r1=1901835&r2=1901836&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/interactive/form/PDAcroForm.java Sun Jun 12 08:09:04 2022
@@ -40,6 +40,7 @@ import org.apache.pdfbox.pdmodel.PDDocum
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.PDPageContentStream.AppendMode;
+import org.apache.pdfbox.pdmodel.PDPageTree;
import org.apache.pdfbox.pdmodel.PDResources;
import org.apache.pdfbox.pdmodel.common.COSArrayList;
import org.apache.pdfbox.pdmodel.common.COSObjectable;
@@ -243,7 +244,8 @@ public final class PDAcroForm implements
}
// get the widgets per page
- Map<COSDictionary,Set<COSDictionary>> pagesWidgetsMap = buildPagesWidgetsMap(fields);
+ PDPageTree pages = document.getPages();
+ Map<COSDictionary,Set<COSDictionary>> pagesWidgetsMap = buildPagesWidgetsMap(fields, pages);
// preserve all non widget annotations
for (PDPage page : document.getPages())
@@ -718,7 +720,8 @@ public final class PDAcroForm implements
return transformedAppearanceBox.getBounds2D();
}
- private Map<COSDictionary,Set<COSDictionary>> buildPagesWidgetsMap(List<PDField> fields) throws IOException
+ private Map<COSDictionary,Set<COSDictionary>> buildPagesWidgetsMap(
+ List<PDField> fields, PDPageTree pages) throws IOException
{
Map<COSDictionary,Set<COSDictionary>> pagesAnnotationsMap =
new HashMap<COSDictionary, Set<COSDictionary>>();
@@ -749,7 +752,7 @@ public final class PDAcroForm implements
// If there is a widget with a missing page reference we need to build the map reverse i.e.
// from the annotations to the widget.
LOG.warn("There has been a widget with a missing page reference, will check all page annotations");
- for (PDPage page : document.getPages())
+ for (PDPage page : pages)
{
for (PDAnnotation annotation : page.getAnnotations())
{