I have many PDFs (Version: 4) from 2007 which obviously have forms, but the AcroForm object in pdfbox and iText 5 is either empty or null.
Why do I believe that the PDFs contains forms? Because in the metadata I see references to XFD-files
For data privacy reason, I cannot provide the PDF files.
AcroFields acroFields = reader.getAcroFields();
if (acroFields.getFields().size() == 0) {
System.err.println("No acroFields");
return;
}
output: No acroFields
PDDocumentCatalog docCatalog = doc.getDocumentCatalog();
PDAcroForm acroForm = docCatalog.getAcroForm();
if (acroForm == null) {
System.err.println("No AcroForm");
return;
}
if (acroForm.hasXFA()) {
System.out.println("doc has XFA");
acroForm.getXFA();
return;
}
output No AcroForm
PDF-Version: 4
CreationDate = D:20071019093057-04'00'
Producer = Acrobat Distiller 7.0 (Windows)
Author = name
Title = filename.xfd
Creator = PScript5.dll Version 5.2
ModDate = D:20071019093057-04'00'
XMP output
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="3.1-701">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:pdf="http://ns.adobe.com/pdf/1.3/">
<pdf:Producer>Acrobat Distiller 7.0 (Windows)</pdf:Producer>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:xap="http://ns.adobe.com/xap/1.0/">
<xap:CreatorTool>PScript5.dll Version 5.2</xap:CreatorTool>
<xap:ModifyDate>2007-10-19T09:30:57-04:00</xap:ModifyDate>
<xap:CreateDate>2007-10-19T09:30:57-04:00</xap:CreateDate>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:format>application/pdf</dc:format>
<dc:title>
<rdf:Alt>
<rdf:li xml:lang="x-default">filename.xfd</rdf:li>
</rdf:Alt>
</dc:title>
<dc:creator>
<rdf:Seq>
<rdf:li>name</rdf:li>
</rdf:Seq>
</dc:creator>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:xapMM="http://ns.adobe.com/xap/1.0/mm/">
<xapMM:DocumentID>uuid:6161773b-92f4-4954-a368-eed868c10438</xapMM:DocumentID>
<xapMM:InstanceID>uuid:7737a837-0df8-4daa-9683-3547663fccaa</xapMM:InstanceID>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
Why do I believe that the PDFs contains forms? Because in the metadata I see references to XFD-files
That merely means that the pdfs have been generated from some xfd file but they can simply contain a flat copy of the current contents of the xfd.
acroForm == null
indicates that there is no valid central form structure in the pdf. There might at most be some lost form field widgets associated with some pages.