Hi all.

I'm tying to rewrite my code in order to use the PDFBox in place of the
current library.
First of all, thank you for the great work you are doing!


I'm trying to manage signatures of a PDFdocuments and the method that I use
to obtain the Signatures' list from the PDDocument is:

public List<PDSignature> *getSignatureDictionaries *() throws IOException

I'm in trouble with a specific signed PDF document because this method
returns an empty signature list.

>From the PDFBox migration
<https://pdfbox.apache.org/2.0/migration.html>documentation
I've read that for PDFBox 2.0.0 and the PDNonTerminalField class the
preferred way to iterate through the fields is:

PDAcroForm form;...for (PDField field : form.getFieldTree()){
    ... (do something)}


Looking inside on the *getSignatureDictionaries *'s code I was very
surprised to see that the AcroField was iterated with this code:

public List<PDSignatureField> *getSignatureFields*() throws IOException
{
    List<PDSignatureField> fields = new ArrayList<PDSignatureField>();
    PDAcroForm acroForm = getDocumentCatalog().getAcroForm();
    if (acroForm != null)
    {
        // fixme: non-terminal fields are ignored, could have
descendant signatures
        for (PDField field : *acroForm*.*getFields*())
        {
            if (field instanceof PDSignatureField)
            {
                fields.add((PDSignatureField)field);
            }
        }
    }
    return fields;
}


I modified that *getSignatureFields *method replecing the
*acroForm.getFields()* call with the suggested *acroForm.getFieldTree()*
and all the signatures are revealed.

The question is:
Is that a forgetfulness of the 2.0 migration or is my workaround incorrect
to solve that issue?


Kind regard

Andrea

Reply via email to