Skip to content
Advertisement

Accessing a COSArray for PDF fields with Apache PDFBox

I’m trying to access all form fields in a PDF file – so I can use code to fill them in – and this is as far as I’ve gotten:

JavaScript

which gives an output of:

JavaScript

Does anyone know how I can access the two COSObjects in the COSArray? I also don’t know what the notation COSObject{x, y} means, and can’t find any documentation on this. If those are dictionary or array values elements, I also want to know how to access those.

Advertisement

Answer

You get the object with get(index) to get the COSObject (an indirect reference) or getObject(index) to get the dereferenced object referenced by the COSObject.

COSObject{110, 0} is the object number and the generation number (usually 0). Open your PDF file with NOTEPAD++ and look for “110 0 obj” to find it, or “110 0 R” to see who references this object.

Advertisement