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 2019/06/19 16:32:17 UTC
svn commit: r1861641 -
/pdfbox/branches/issue4569/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java
Author: tilman
Date: Wed Jun 19 16:32:16 2019
New Revision: 1861641
URL: http://svn.apache.org/viewvc?rev=1861641&view=rev
Log:
PDFBOX-2941: improve detection of widget annotations by checking whether field widget annotation is in the list of page annotations, because widget.getPage() is sometimes null, see bottom fields in the file of poppler issue 778
Modified:
pdfbox/branches/issue4569/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java
Modified: pdfbox/branches/issue4569/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/issue4569/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java?rev=1861641&r1=1861640&r2=1861641&view=diff
==============================================================================
--- pdfbox/branches/issue4569/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java (original)
+++ pdfbox/branches/issue4569/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java Wed Jun 19 16:32:16 2019
@@ -48,8 +48,10 @@ import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import org.apache.pdfbox.debugger.ui.HighResolutionImageIcon;
@@ -160,14 +162,27 @@ public class PagePane implements ActionL
{
return;
}
+ Set<COSDictionary> dictionarySet = new HashSet<>();
+ try
+ {
+ for (PDAnnotation annotation : page.getAnnotations())
+ {
+ dictionarySet.add(annotation.getCOSObject());
+ }
+ }
+ catch (IOException ex)
+ {
+ return;
+ }
for (PDField field : acroForm.getFieldTree())
{
- String fullyQualifiedName = field.getFullyQualifiedName();
for (PDAnnotationWidget widget : field.getWidgets())
{
- if (page.equals(widget.getPage()))
+ // check if the annotation widget is on this page
+ // (checking widget.getPage() also works, but it is sometimes null)
+ if (dictionarySet.contains(widget.getCOSObject()))
{
- rectMap.put(widget.getRectangle(), "Field name: " + fullyQualifiedName);
+ rectMap.put(widget.getRectangle(), "Field name: " + field.getFullyQualifiedName());
}
}
}