From commits-return-14852-archive-asf-public=cust-asf.ponee.io@pdfbox.apache.org Wed Jun 19 16:32:12 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 3A24618060F for ; Wed, 19 Jun 2019 18:32:12 +0200 (CEST) Received: (qmail 44374 invoked by uid 500); 19 Jun 2019 16:32:11 -0000 Mailing-List: contact commits-help@pdfbox.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pdfbox.apache.org Delivered-To: mailing list commits@pdfbox.apache.org Received: (qmail 44365 invoked by uid 99); 19 Jun 2019 16:32:11 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Jun 2019 16:32:11 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 12B2E3A34BE for ; Wed, 19 Jun 2019 16:32:11 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1861640 - /pdfbox/branches/issue45/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java Date: Wed, 19 Jun 2019 16:32:11 -0000 To: commits@pdfbox.apache.org From: tilman@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20190619163211.12B2E3A34BE@svn01-us-west.apache.org> Author: tilman Date: Wed Jun 19 16:32:10 2019 New Revision: 1861640 URL: http://svn.apache.org/viewvc?rev=1861640&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/issue45/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java Modified: pdfbox/branches/issue45/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java URL: http://svn.apache.org/viewvc/pdfbox/branches/issue45/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java?rev=1861640&r1=1861639&r2=1861640&view=diff ============================================================================== --- pdfbox/branches/issue45/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java (original) +++ pdfbox/branches/issue45/debugger/src/main/java/org/apache/pdfbox/debugger/pagepane/PagePane.java Wed Jun 19 16:32:10 2019 @@ -29,7 +29,9 @@ 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.Set; import java.util.concurrent.ExecutionException; import javax.swing.BoxLayout; import javax.swing.JLabel; @@ -152,14 +154,27 @@ public class PagePane implements ActionL { return; } + Set 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()); } } }