pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Crowe <a.cr...@opengroup.org>
Subject PDChoiceField values not being returned
Date Mon, 24 Aug 2015 13:23:51 GMT


      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,

              } 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:a.crowe@opengroup.org     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

To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org

View raw message