You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Bart Taylor <ba...@gmail.com> on 2015/09/04 20:50:21 UTC
Checkbox with multiple AnnotationWidgets
Hi,
I have a simple document with two PDCheckbox fields, and one of those
fields has two AnnotationWidgets. I am able to successfully call check() on
the first field and see the result in the output document, but calling
check() on the field with multiple AnnotationWidgets has no effect.
My understanding of duplicated fields is that only a single PDField exists
but that an AnnotationWidget kid will exist for each instance of the field
in the document, so setting the PDField parent once should affect all of
the children. Am I misunderstanding how this should work?
Attached is the document I am testing as well as a small Java class that
reproduces the issue by calling check() on everything in getFields(). I
have tried this with PDFBox 1.8.9, 1.8.10, and the 09/03 Snapshot of 2.0.0.
I am viewing the document with Adobe Acrobat Reader DC Version
2015.008.20082.
Any insight would be appreciated.
Thanks,
Bart.
Re: Checkbox with multiple AnnotationWidgets
Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi Bart,
> Am 08.09.2015 um 16:15 schrieb Bart Taylor <ba...@gmail.com>:
>
> Calling the getOnValue() method for the field
> throws a Null Pointer Exception in PDCheckbox.java at line 140:
I've created https://issues.apache.org/jira/browse/PDFBOX-2964 <https://issues.apache.org/jira/browse/PDFBOX-2964> for that and already committed a fix. This will now also allow you to use check() and unCheck() in the 1.8 branch when the checkbox has multiple widgets.
BR
Maruan
Re: Checkbox with multiple AnnotationWidgets
Posted by Gilad Denneboom <gi...@gmail.com>.
The issue seems to have been related to the fact that the export values
were in Hebrew. When I changed them to English the setValue method worked...
On Thu, Nov 23, 2017 at 11:58 AM, Gilad Denneboom <gilad.denneboom@gmail.com
> wrote:
> I have a similar issue but no matter what I do I can't get it to work...
> I'm looking at the Options array for the new value and setting the matching
> widget, or at least I'm trying to. Any suggestions on how to do it (using
> 1.8.13)?
> Here's my code:
>
> PDCheckbox checkBox = (PDCheckbox) f;
> checkBox.getDictionary().setName("V", newValue);
> List<String> options = checkBox.getOptions();
> for (int i=0; i<options.size(); i++) {
> if (options.get(i).equals(newValue)) {
> checkBox.getWidgets().get(i).
> getDictionary().setName(COSName.getPDFName("AS"), newValue);
> } else checkBox.getWidgets().get(i).
> getDictionary().setItem(COSName.getPDFName("AS"),
> COSName.getPDFName("Off"));
> }
>
>
> On Wed, Sep 9, 2015 at 8:22 AM, Maruan Sahyoun <sa...@fileaffairs.de>
> wrote:
>
>> Hi,
>>
>> > Am 08.09.2015 um 21:00 schrieb Bart Taylor <ba...@gmail.com>:
>> >
>> > Hi Maruan,
>> >
>> > Thank you for the speedy fix. I built the 1.8 branch and verified that
>> > check() method works in both single and duplicate field cases.
>> getOnValue()
>> > also does not return a null pointer exception after the patch.
>>
>> you're welcome - thanks for testing the fix so quickly.
>> Maruan
>>
>> >
>> > Thanks again,
>> > Bart.
>> >
>> > On Tue, Sep 8, 2015 at 10:15 AM, Bart Taylor <ba...@gmail.com> wrote:
>> >
>> >> Hi Maruan,
>> >>
>> >> I was able to verify that the latest trunk snapshot does correct the
>> >> issue.
>> >>
>> >> I used the latest 1.8.11 snapshot to test the getWidgets() method and
>> set
>> >> the AppearanceStream for each widget, and that also works as long as I
>> know
>> >> the exact value to use. Calling the getOnValue() method for the field
>> >> throws a Null Pointer Exception in PDCheckbox.java at line 140:
>> >>
>> >> COSBase n = ap.getDictionaryObject(COSName.getPDFName("N"));
>> >> I did not get your response emails, so I cannot reply to the last one
>> in
>> >> the chain.
>> >>
>> >> Thanks for your help,
>> >> Bart.
>> >>
>> >> On Fri, Sep 4, 2015 at 2:50 PM, Bart Taylor <ba...@gmail.com> wrote:
>> >>
>> >>> Hi,
>> >>>
>> >>> I have a simple document with two PDCheckbox fields, and one of those
>> >>> fields has two AnnotationWidgets. I am able to successfully call
>> check() on
>> >>> the first field and see the result in the output document, but calling
>> >>> check() on the field with multiple AnnotationWidgets has no effect.
>> >>>
>> >>> My understanding of duplicated fields is that only a single PDField
>> >>> exists but that an AnnotationWidget kid will exist for each instance
>> of the
>> >>> field in the document, so setting the PDField parent once should
>> affect all
>> >>> of the children. Am I misunderstanding how this should work?
>> >>>
>> >>> Attached is the document I am testing as well as a small Java class
>> that
>> >>> reproduces the issue by calling check() on everything in
>> getFields(). I
>> >>> have tried this with PDFBox 1.8.9, 1.8.10, and the 09/03 Snapshot of
>> 2.0.0.
>> >>> I am viewing the document with Adobe Acrobat Reader DC Version
>> >>> 2015.008.20082.
>> >>>
>> >>> Any insight would be appreciated.
>> >>>
>> >>> Thanks,
>> >>> Bart.
>> >>>
>> >>
>> >>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>
>
Re: Checkbox with multiple AnnotationWidgets
Posted by Gilad Denneboom <gi...@gmail.com>.
I have a similar issue but no matter what I do I can't get it to work...
I'm looking at the Options array for the new value and setting the matching
widget, or at least I'm trying to. Any suggestions on how to do it (using
1.8.13)?
Here's my code:
PDCheckbox checkBox = (PDCheckbox) f;
checkBox.getDictionary().setName("V", newValue);
List<String> options = checkBox.getOptions();
for (int i=0; i<options.size(); i++) {
if (options.get(i).equals(newValue)) {
checkBox.getWidgets().get(i).getDictionary().setName(COSName.getPDFName("AS"),
newValue);
} else
checkBox.getWidgets().get(i).getDictionary().setItem(COSName.getPDFName("AS"),
COSName.getPDFName("Off"));
}
On Wed, Sep 9, 2015 at 8:22 AM, Maruan Sahyoun <sa...@fileaffairs.de>
wrote:
> Hi,
>
> > Am 08.09.2015 um 21:00 schrieb Bart Taylor <ba...@gmail.com>:
> >
> > Hi Maruan,
> >
> > Thank you for the speedy fix. I built the 1.8 branch and verified that
> > check() method works in both single and duplicate field cases.
> getOnValue()
> > also does not return a null pointer exception after the patch.
>
> you're welcome - thanks for testing the fix so quickly.
> Maruan
>
> >
> > Thanks again,
> > Bart.
> >
> > On Tue, Sep 8, 2015 at 10:15 AM, Bart Taylor <ba...@gmail.com> wrote:
> >
> >> Hi Maruan,
> >>
> >> I was able to verify that the latest trunk snapshot does correct the
> >> issue.
> >>
> >> I used the latest 1.8.11 snapshot to test the getWidgets() method and
> set
> >> the AppearanceStream for each widget, and that also works as long as I
> know
> >> the exact value to use. Calling the getOnValue() method for the field
> >> throws a Null Pointer Exception in PDCheckbox.java at line 140:
> >>
> >> COSBase n = ap.getDictionaryObject(COSName.getPDFName("N"));
> >> I did not get your response emails, so I cannot reply to the last one in
> >> the chain.
> >>
> >> Thanks for your help,
> >> Bart.
> >>
> >> On Fri, Sep 4, 2015 at 2:50 PM, Bart Taylor <ba...@gmail.com> wrote:
> >>
> >>> Hi,
> >>>
> >>> I have a simple document with two PDCheckbox fields, and one of those
> >>> fields has two AnnotationWidgets. I am able to successfully call
> check() on
> >>> the first field and see the result in the output document, but calling
> >>> check() on the field with multiple AnnotationWidgets has no effect.
> >>>
> >>> My understanding of duplicated fields is that only a single PDField
> >>> exists but that an AnnotationWidget kid will exist for each instance
> of the
> >>> field in the document, so setting the PDField parent once should
> affect all
> >>> of the children. Am I misunderstanding how this should work?
> >>>
> >>> Attached is the document I am testing as well as a small Java class
> that
> >>> reproduces the issue by calling check() on everything in getFields().
> I
> >>> have tried this with PDFBox 1.8.9, 1.8.10, and the 09/03 Snapshot of
> 2.0.0.
> >>> I am viewing the document with Adobe Acrobat Reader DC Version
> >>> 2015.008.20082.
> >>>
> >>> Any insight would be appreciated.
> >>>
> >>> Thanks,
> >>> Bart.
> >>>
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
>
Re: Checkbox with multiple AnnotationWidgets
Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi,
> Am 08.09.2015 um 21:00 schrieb Bart Taylor <ba...@gmail.com>:
>
> Hi Maruan,
>
> Thank you for the speedy fix. I built the 1.8 branch and verified that
> check() method works in both single and duplicate field cases. getOnValue()
> also does not return a null pointer exception after the patch.
you're welcome - thanks for testing the fix so quickly.
Maruan
>
> Thanks again,
> Bart.
>
> On Tue, Sep 8, 2015 at 10:15 AM, Bart Taylor <ba...@gmail.com> wrote:
>
>> Hi Maruan,
>>
>> I was able to verify that the latest trunk snapshot does correct the
>> issue.
>>
>> I used the latest 1.8.11 snapshot to test the getWidgets() method and set
>> the AppearanceStream for each widget, and that also works as long as I know
>> the exact value to use. Calling the getOnValue() method for the field
>> throws a Null Pointer Exception in PDCheckbox.java at line 140:
>>
>> COSBase n = ap.getDictionaryObject(COSName.getPDFName("N"));
>> I did not get your response emails, so I cannot reply to the last one in
>> the chain.
>>
>> Thanks for your help,
>> Bart.
>>
>> On Fri, Sep 4, 2015 at 2:50 PM, Bart Taylor <ba...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I have a simple document with two PDCheckbox fields, and one of those
>>> fields has two AnnotationWidgets. I am able to successfully call check() on
>>> the first field and see the result in the output document, but calling
>>> check() on the field with multiple AnnotationWidgets has no effect.
>>>
>>> My understanding of duplicated fields is that only a single PDField
>>> exists but that an AnnotationWidget kid will exist for each instance of the
>>> field in the document, so setting the PDField parent once should affect all
>>> of the children. Am I misunderstanding how this should work?
>>>
>>> Attached is the document I am testing as well as a small Java class that
>>> reproduces the issue by calling check() on everything in getFields(). I
>>> have tried this with PDFBox 1.8.9, 1.8.10, and the 09/03 Snapshot of 2.0.0.
>>> I am viewing the document with Adobe Acrobat Reader DC Version
>>> 2015.008.20082.
>>>
>>> Any insight would be appreciated.
>>>
>>> Thanks,
>>> Bart.
>>>
>>
>>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: Checkbox with multiple AnnotationWidgets
Posted by Bart Taylor <ba...@gmail.com>.
Hi Maruan,
Thank you for the speedy fix. I built the 1.8 branch and verified that
check() method works in both single and duplicate field cases. getOnValue()
also does not return a null pointer exception after the patch.
Thanks again,
Bart.
On Tue, Sep 8, 2015 at 10:15 AM, Bart Taylor <ba...@gmail.com> wrote:
> Hi Maruan,
>
> I was able to verify that the latest trunk snapshot does correct the
> issue.
>
> I used the latest 1.8.11 snapshot to test the getWidgets() method and set
> the AppearanceStream for each widget, and that also works as long as I know
> the exact value to use. Calling the getOnValue() method for the field
> throws a Null Pointer Exception in PDCheckbox.java at line 140:
>
> COSBase n = ap.getDictionaryObject(COSName.getPDFName("N"));
> I did not get your response emails, so I cannot reply to the last one in
> the chain.
>
> Thanks for your help,
> Bart.
>
> On Fri, Sep 4, 2015 at 2:50 PM, Bart Taylor <ba...@gmail.com> wrote:
>
>> Hi,
>>
>> I have a simple document with two PDCheckbox fields, and one of those
>> fields has two AnnotationWidgets. I am able to successfully call check() on
>> the first field and see the result in the output document, but calling
>> check() on the field with multiple AnnotationWidgets has no effect.
>>
>> My understanding of duplicated fields is that only a single PDField
>> exists but that an AnnotationWidget kid will exist for each instance of the
>> field in the document, so setting the PDField parent once should affect all
>> of the children. Am I misunderstanding how this should work?
>>
>> Attached is the document I am testing as well as a small Java class that
>> reproduces the issue by calling check() on everything in getFields(). I
>> have tried this with PDFBox 1.8.9, 1.8.10, and the 09/03 Snapshot of 2.0.0.
>> I am viewing the document with Adobe Acrobat Reader DC Version
>> 2015.008.20082.
>>
>> Any insight would be appreciated.
>>
>> Thanks,
>> Bart.
>>
>
>
Re: Checkbox with multiple AnnotationWidgets
Posted by Bart Taylor <ba...@gmail.com>.
Hi Maruan,
I was able to verify that the latest trunk snapshot does correct the issue.
I used the latest 1.8.11 snapshot to test the getWidgets() method and set
the AppearanceStream for each widget, and that also works as long as I know
the exact value to use. Calling the getOnValue() method for the field
throws a Null Pointer Exception in PDCheckbox.java at line 140:
COSBase n = ap.getDictionaryObject(COSName.getPDFName("N"));
I did not get your response emails, so I cannot reply to the last one in
the chain.
Thanks for your help,
Bart.
On Fri, Sep 4, 2015 at 2:50 PM, Bart Taylor <ba...@gmail.com> wrote:
> Hi,
>
> I have a simple document with two PDCheckbox fields, and one of those
> fields has two AnnotationWidgets. I am able to successfully call check() on
> the first field and see the result in the output document, but calling
> check() on the field with multiple AnnotationWidgets has no effect.
>
> My understanding of duplicated fields is that only a single PDField exists
> but that an AnnotationWidget kid will exist for each instance of the field
> in the document, so setting the PDField parent once should affect all of
> the children. Am I misunderstanding how this should work?
>
> Attached is the document I am testing as well as a small Java class that
> reproduces the issue by calling check() on everything in getFields(). I
> have tried this with PDFBox 1.8.9, 1.8.10, and the 09/03 Snapshot of 2.0.0.
> I am viewing the document with Adobe Acrobat Reader DC Version
> 2015.008.20082.
>
> Any insight would be appreciated.
>
> Thanks,
> Bart.
>
Re: Checkbox with multiple AnnotationWidgets
Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi Bart,
> Am 04.09.2015 um 20:50 schrieb Bart Taylor <ba...@gmail.com>:
>
> Hi,
>
> I have a simple document with two PDCheckbox fields, and one of those fields has two AnnotationWidgets. I am able to successfully call check() on the first field and see the result in the output document, but calling check() on the field with multiple AnnotationWidgets has no effect.
>
> My understanding of duplicated fields is that only a single PDField exists but that an AnnotationWidget kid will exist for each instance of the field in the document, so setting the PDField parent once should affect all of the children. Am I misunderstanding how this should work?
>
> Attached is the document I am testing as well as a small Java class that reproduces the issue by calling check() on everything in getFields(). I have tried this with PDFBox 1.8.9, 1.8.10, and the 09/03 Snapshot of 2.0.0. I am viewing the document with Adobe Acrobat Reader DC Version 2015.008.20082.
I have created https://issues.apache.org/jira/browse/PDFBOX-2961 for this. Thanks for the report.
Maruan
>
> Any insight would be appreciated.
>
> Thanks,
> Bart.
>
> ---------------------------------------------------------------------
> 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: Checkbox with multiple AnnotationWidgets
Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi Bart,
for the 1.8 branch I've added the method getWidgets() which will allow you to retrieve all widgets associated to a field. There you would need to set the /AS entry of the dictionary. Unfortunately I can't change the check()/unckeck() methods as this would be an API breaking change. Hope it helps anyway.
BR
Maruan
> Am 04.09.2015 um 20:50 schrieb Bart Taylor <ba...@gmail.com>:
>
> Hi,
>
> I have a simple document with two PDCheckbox fields, and one of those fields has two AnnotationWidgets. I am able to successfully call check() on the first field and see the result in the output document, but calling check() on the field with multiple AnnotationWidgets has no effect.
>
> My understanding of duplicated fields is that only a single PDField exists but that an AnnotationWidget kid will exist for each instance of the field in the document, so setting the PDField parent once should affect all of the children. Am I misunderstanding how this should work?
>
> Attached is the document I am testing as well as a small Java class that reproduces the issue by calling check() on everything in getFields(). I have tried this with PDFBox 1.8.9, 1.8.10, and the 09/03 Snapshot of 2.0.0. I am viewing the document with Adobe Acrobat Reader DC Version 2015.008.20082.
>
> Any insight would be appreciated.
>
> Thanks,
> Bart.
>
> ---------------------------------------------------------------------
> 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: Checkbox with multiple AnnotationWidgets
Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi,
> Am 04.09.2015 um 20:50 schrieb Bart Taylor <ba...@gmail.com>:
>
> Hi,
>
> I have a simple document with two PDCheckbox fields, and one of those fields has two AnnotationWidgets. I am able to successfully call check() on the first field and see the result in the output document, but calling check() on the field with multiple AnnotationWidgets has no effect.
>
> My understanding of duplicated fields is that only a single PDField exists but that an AnnotationWidget kid will exist for each instance of the field in the document, so setting the PDField parent once should affect all of the children. Am I misunderstanding how this should work?
>
> Attached is the document I am testing as well as a small Java class that reproduces the issue by calling check() on everything in getFields(). I have tried this with PDFBox 1.8.9, 1.8.10, and the 09/03 Snapshot of 2.0.0. I am viewing the document with Adobe Acrobat Reader DC Version 2015.008.20082.
as attachments don't work on that mailing list would it be possible to upload the files to a public location?
BR
Maruan
>
> Any insight would be appreciated.
>
> Thanks,
> Bart.
>
> ---------------------------------------------------------------------
> 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: Checkbox with multiple AnnotationWidgets
Posted by Maruan Sahyoun <sa...@fileaffairs.de>.
Hi Bart,
> Am 04.09.2015 um 20:50 schrieb Bart Taylor <ba...@gmail.com>:
>
> Hi,
>
> I have a simple document with two PDCheckbox fields, and one of those fields has two AnnotationWidgets. I am able to successfully call check() on the first field and see the result in the output document, but calling check() on the field with multiple AnnotationWidgets has no effect.
>
> My understanding of duplicated fields is that only a single PDField exists but that an AnnotationWidget kid will exist for each instance of the field in the document, so setting the PDField parent once should affect all of the children. Am I misunderstanding how this should work?
>
> Attached is the document I am testing as well as a small Java class that reproduces the issue by calling check() on everything in getFields(). I have tried this with PDFBox 1.8.9, 1.8.10, and the 09/03 Snapshot of 2.0.0. I am viewing the document with Adobe Acrobat Reader DC Version 2015.008.20082.
>
I've patched the 2.0.0 version. Could you give it a try as soon as the snapshot is available?
BR
Maruan
> Any insight would be appreciated.
>
> Thanks,
> Bart.
>
> ---------------------------------------------------------------------
> 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