You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Andrew Munn <an...@nmedia.net> on 2015/04/26 07:10:09 UTC
PDFBox detecting checked/unchecked checkboxes
What is the best way for PDFBox to detect checked vs unchecked checkboxes
in forms? I am thinking use the known x/y coordinates to pull the small
image of the checkbox out as a BufferedImage then write code that
determines if the box is filled in. Some boxes are solid black but some
just have a 1-pixel wide X in them. Detecting a solid box would be easy.
Detecting the X in the middle of an otherwise empty box would be harder.
Is there some trick to this stuff that I should know?
Thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: PDFBox detecting checked/unchecked checkboxes
Posted by Andrew Munn <an...@nmedia.net>.
On Sun, 26 Apr 2015, Tilman Hausherr wrote:
> I looked at your file... it doesn't have acroforms. So we're back to square
> one.
>
> So what you could do is either to use text extraction (to test whether these
> boxes are glyphs), or graphic method you mentioned at the beginning.
>
> However I just tried text extraction, but I didn't get the boxes. This
> suggests that these are graphics.
>
> If your job is to evaluate lots of PDF files like this one, you could do it
> with graphics, but only if these PDFs are really identical except for the
> boxes.
Thanks a lot for looking. Yes I will be doing a lot of these forms and
hopefully the boxes will be in the identical place. So it looks like I
collecting the graphics and trying to determine if the box is filled or
open.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: PDFBox detecting checked/unchecked checkboxes
Posted by Tilman Hausherr <TH...@t-online.de>.
I looked at your file... it doesn't have acroforms. So we're back to
square one.
So what you could do is either to use text extraction (to test whether
these boxes are glyphs), or graphic method you mentioned at the beginning.
However I just tried text extraction, but I didn't get the boxes. This
suggests that these are graphics.
If your job is to evaluate lots of PDF files like this one, you could do
it with graphics, but only if these PDFs are really identical except for
the boxes.
Tilman
Am 26.04.2015 um 21:56 schrieb Andrew Munn:
>>> I think I looked at that a while back and didn't get anyplace. I just
>>> tried to run the PrintFields app and I get a NullPointerException. I am
>>> thinking the checkboxes in my form are just stored as black squares, not
>>> completed form fields. Is that possible?
>>>
>>> PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
>>> PDAcroForm acroForm = docCatalog.getAcroForm(); // returns null
>>> List<PDFieldTreeNode> fields = acroForm.getFields(); //NPE here
>> Could you please mention what version you are using (even if you already did
>> before), and upload the file somewhere?
> I have these in my path:
>
> levigo-jbig2-imageio-1.6.3.jar
> pdfbox-app-2.0.0-20150420.221011-1230.jar
>
> I will email you the PDF because my web server is down for a bit.
>
> Thanks!
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: PDFBox detecting checked/unchecked checkboxes
Posted by Andrew Munn <an...@nmedia.net>.
> > I think I looked at that a while back and didn't get anyplace. I just
> > tried to run the PrintFields app and I get a NullPointerException. I am
> > thinking the checkboxes in my form are just stored as black squares, not
> > completed form fields. Is that possible?
> >
> > PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
> > PDAcroForm acroForm = docCatalog.getAcroForm(); // returns null
> > List<PDFieldTreeNode> fields = acroForm.getFields(); //NPE here
>
> Could you please mention what version you are using (even if you already did
> before), and upload the file somewhere?
I have these in my path:
levigo-jbig2-imageio-1.6.3.jar
pdfbox-app-2.0.0-20150420.221011-1230.jar
I will email you the PDF because my web server is down for a bit.
Thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: PDFBox detecting checked/unchecked checkboxes
Posted by Tilman Hausherr <TH...@t-online.de>.
Am 26.04.2015 um 18:54 schrieb Andrew Munn:
> On Sun, 26 Apr 2015, Tilman Hausherr wrote:
>> Am 26.04.2015 um 07:10 schrieb Andrew Munn:
>>> Is there some trick to this stuff that I should know?
>> Yes, "acroform". See the PrintFields example in the source package :-)
>>
> I think I looked at that a while back and didn't get anyplace. I just
> tried to run the PrintFields app and I get a NullPointerException. I am
> thinking the checkboxes in my form are just stored as black squares, not
> completed form fields. Is that possible?
>
> PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
> PDAcroForm acroForm = docCatalog.getAcroForm(); // returns null
> List<PDFieldTreeNode> fields = acroForm.getFields(); //NPE here
Could you please mention what version you are using (even if you already
did before), and upload the file somewhere?
Tilman
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: PDFBox detecting checked/unchecked checkboxes
Posted by Andrew Munn <an...@nmedia.net>.
On Sun, 26 Apr 2015, Tilman Hausherr wrote:
> Am 26.04.2015 um 07:10 schrieb Andrew Munn:
> > Is there some trick to this stuff that I should know?
>
> Yes, "acroform". See the PrintFields example in the source package :-)
>
I think I looked at that a while back and didn't get anyplace. I just
tried to run the PrintFields app and I get a NullPointerException. I am
thinking the checkboxes in my form are just stored as black squares, not
completed form fields. Is that possible?
PDDocumentCatalog docCatalog = pdfDocument.getDocumentCatalog();
PDAcroForm acroForm = docCatalog.getAcroForm(); // returns null
List<PDFieldTreeNode> fields = acroForm.getFields(); //NPE here
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: PDFBox detecting checked/unchecked checkboxes
Posted by Tilman Hausherr <TH...@t-online.de>.
Am 26.04.2015 um 07:10 schrieb Andrew Munn:
> What is the best way for PDFBox to detect checked vs unchecked checkboxes
> in forms? I am thinking use the known x/y coordinates to pull the small
> image of the checkbox out as a BufferedImage then write code that
> determines if the box is filled in. Some boxes are solid black but some
> just have a 1-pixel wide X in them. Detecting a solid box would be easy.
> Detecting the X in the middle of an otherwise empty box would be harder.
> Is there some trick to this stuff that I should know?
Yes, "acroform". See the PrintFields example in the source package :-)
Tilman
>
> Thanks!
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org