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!
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]