Hi guys. Which is the correct way to sort Signatures by revisions order?
With some signed documents the PdfBox method: PDDocument.getSignatureDictionaries() returns a Signatures list sorted by a different order from the signed revisions order. Is there a simple way to get the signed revision ordinal ? Thanks in advance Andrea On Thu, May 26, 2016 at 5:26 PM, Maruan Sahyoun <sahy...@fileaffairs.de> wrote: > Hi, > > > > Am 26.05.2016 um 14:26 schrieb Andrea Canu <andrea.c...@gmail.com>: > > > > 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. > > You are correct that the code only resturns top level signature fields and > not ones which are descendants. > > I've created https://issues.apache.org/jira/browse/PDFBOX-3364 to imrpove > that. > > BR > Maruan > > > > > The question is: > > Is that a forgetfulness of the 2.0 migration or is my workaround > incorrect > > to solve that issue? > > > > > > Kind regard > > > > Andrea > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org > For additional commands, e-mail: users-h...@pdfbox.apache.org > >