Hi PDFBox, I get this ClassCastException:
Exception in thread "main" java.lang.ClassCastException: org.apache.pdfbox.cos.COSDictionary cannot be cast to org.apache.pdfbox.cos.COSArray at org.apache.pdfbox.pdmodel.interactive.form.PDAcroForm.getFields(PDAcroForm.java:369) when reading this PDF document: https://www.dropbox.com/s/lr4u9voq07qr8wr/URLA.PDF?dl=0 using this code in PDFBox 2.0.5: public static void main(String[] args) { PDDocument pdDocument; try { pdDocument = PDDocument.load(new File("c:/temp/URLA.PDF")); } catch (Exception e) { throw new RuntimeException(e); } PDAcroForm pdAcroForm = pdDocument.getDocumentCatalog().getAcroForm(); if (pdAcroForm != null) { try { List<PDField> acroFields = pdAcroForm.getFields(); List<PDField> pdFields = new ArrayList<PDField>(); for (PDField pdField : acroFields) { // (modify fields) } pdAcroForm.setFields(pdFields); // flatten the document to get rid of the buttons pdAcroForm.flatten(); } catch (IOException e) { throw new RuntimeException(e); } } } What am I doing wrong? It might be related to the document restrictions. If so, could the exception message reflect that? Thanks, John Liston --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

