Hi Andy, would it be possible to get a sample form uploaded to a public location? (if there are only confidential PDFs you could also mail them to me).
It's easier to look at what's going on and get the correct workaround/solution/bug fix. BTW did you have time to test PDFBox 2.0? Do you have the same issues there? BR Maruan > Am 03.09.2015 um 14:08 schrieb Andrew Crowe <[email protected]>: > > Just continuing this work around a bit after some more investigation... > > The work around is fine if the Item name selected is the same as the value, > e.g. > > Item Name = Dr, Item Value = Dr [getValue() returns 'Dr'] > > But if the value is different from the name as I am using then the getValue() > returns the item name, and not the actual value stored, e.g. > > Item Name = Dr, Item Value = 12345 [getValue() returns 'Dr'] > > This is only when the ChoiceField or Checkbox are returned as > 'PDAnnotationWidget'. If they return as ChoiceField then I can iterate > around the getSelectedOptions() and get the correct values. > > I'm not sure why sometimes the ChoiceField and CheckBox are returned as > 'PDAnnotationWidget' and sometimes as the ChoiceField/Checkbox!? > > Is there a work around when they are 'PDAnnotationWidget' that will get the > actual field item value, and not its displayed name? > > Many thanks > > Andy. > > > > On 25/08/2015 14:20, Andrew Crowe wrote: >> Hi Maruan, >> >> That's great thanks, and many thanks for the fast response. >> >> Thanks again. >> >> Andy. >> >> On 25/08/2015 14:07, Maruan Sahyoun wrote: >>> Hi, >>> >>>> Am 25.08.2015 um 14:55 schrieb Andrew Crowe <[email protected]>: >>>> >>>> Hi, >>>> >>>> I am using version 1.8.9. I've been trying to track down the issue, and >>>> although the drop downs and check boxes appear correctly in the PDF, it >>>> seems that they are being treated as either 'PDChoiceField' or >>>> 'PDCheckBox', but with a child that is an ' >>>> org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationWidget'! >>>> >>>> So I have put in a work around that if its an 'PDAnnotationWidget' child >>>> then forget the child and just get the value of the parent PDField. This >>>> seems to work, but I'm not sure that it should have to be like this! I'm >>>> guessing that it might be something with the tool that created the >>>> original PDF. When I created the same document in Adobe DC then it all >>>> worked fine with the code below, so I'm putting this one down to >>>> differences in PDF creation tools! >>> Your workaround is correct as is as it should be as the PDAnnotationWidget >>> is the visible representation of the field (there can be many >>> PDAnnotationWidgets assigned to one field) but the fields value is stored >>> with the field. Now if there is only one PDAnnotationWidget it's entries >>> and the field entries ca be combined into one dictionary So that is why it >>> might work in one case and doesn't in the other. >>> >>> BR >>> Maruan >>> >>> >>>> If I'm just hiding the true cause then it would be great to know. >>>> Otherwise I'll go with my work around. >>>> >>>> Many thanks >>>> >>>> Andy. >>>> >>>> On 24/08/2015 14:55, Maruan Sahyoun wrote: >>>>> Hi, >>>>> >>>>>> Am 24.08.2015 um 15:23 schrieb Andrew Crowe <[email protected]>: >>>>>> >>>>>> >>>>>> Hi, >>>>>> >>>>>> I have a service that takes in a PDF document and returns it as an >>>>>> XML document with the parameter name/values. This works great except >>>>>> for PDChoiceFields. Sometimes they come back ok, but other times they >>>>>> don't. My code for returning the values is, >>>>>> >>>>> which version of PDFBox are you using? Would it be possible to attach the >>>>> print out of PDField.getDictionary() for the field where you would expect >>>>> a value to be returned? >>>>> >>>>> BR >>>>> Maruan >>>>> >>>>>> ------------ >>>>>> ... >>>>>> ... >>>>>> ... >>>>>> } else if (field instanceof PDChoiceField) { >>>>>> >>>>>> PDChoiceField cf = (PDChoiceField) field; >>>>>> >>>>>> COSArray caAll = cf.getOptions(); >>>>>> COSArray caSelected = cf.getSelectedOptions(); >>>>>> >>>>>> if (caSelected != null) >>>>>> { >>>>>> for (int i=0; i < caSelected.size(); i++) >>>>>> { >>>>>> COSBase cb = caSelected.get(i); >>>>>> COSInteger cbInt = (COSInteger) cb; >>>>>> >>>>>> COSBase cb2 = caAll.get(cbInt.intValue()); >>>>>> >>>>>> // Check its an array. If its not then the >>>>>> selected item has no value >>>>>> if (cb2 instanceof COSArray) >>>>>> { >>>>>> COSArray vals = (COSArray) cb2; >>>>>> >>>>>> fieldValue = vals.getString(0); >>>>>> } >>>>>> } >>>>>> >>>>>> } else { >>>>>> >>>>>> fieldValue = field.getValue(); >>>>>> } >>>>>> >>>>>> -------------- >>>>>> >>>>>> This is returning null, even if there are values in the field. I cant >>>>>> attach the example file as its too large. >>>>>> >>>>>> Has anyone come across this, or know how to solve the issue? >>>>>> >>>>>> Many thanks >>>>>> >>>>>> Andy Crowe >>>>>> -- >>>>>> ------------------------------------------------------------------------------ >>>>>> >>>>>> Andrew Crowe, >>>>>> T H E Senior Software Developer >>>>>> O P E N Apex Plaza,Forbury Road,Reading,Berkshire RG1 ALX >>>>>> G R O U P Mailto:[email protected] Tel: +44 118 902 3033 >>>>>> WWW: http://www.opengroup.org Fax: +44 118 950 0110 >>>>>> >>>>>> UNIX is a registered trademark of The Open Group in the US and other >>>>>> countries >>>>>> ------------------------------------------------------------------------------ >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> --------------------------------------------------------------------- >>>>>> To unsubscribe, e-mail: [email protected] >>>>>> For additional commands, e-mail: [email protected] >>>>>> >>>>> --------------------------------------------------------------------- >>>>> To unsubscribe, e-mail: [email protected] >>>>> For additional commands, e-mail: [email protected] >>>>> >>>> -- >>>> ------------------------------------------------------------------------------ >>>> >>>> Andrew Crowe, >>>> T H E Senior Software Developer >>>> O P E N Apex Plaza,Forbury Road,Reading,Berkshire RG1 ALX >>>> G R O U P Mailto:[email protected] Tel: +44 118 902 3033 >>>> WWW: http://www.opengroup.org Fax: +44 118 950 0110 >>>> >>>> UNIX is a registered trademark of The Open Group in the US and other >>>> countries >>>> ------------------------------------------------------------------------------ >>>> >>>> >>>> >>>> --------------------------------------------------------------------- >>>> To unsubscribe, e-mail: [email protected] >>>> For additional commands, e-mail: [email protected] >>>> >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: [email protected] >>> For additional commands, e-mail: [email protected] >>> >> > > -- > ------------------------------------------------------------------------------ > Andrew Crowe, > T H E Senior Software Developer > O P E N Apex Plaza,Forbury Road,Reading,Berkshire RG1 ALX > G R O U P Mailto:[email protected] Tel: +44 118 902 3033 > WWW: http://www.opengroup.org Fax: +44 118 950 0110 > > UNIX is a registered trademark of The Open Group in the US and other countries > ------------------------------------------------------------------------------ > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

