Author: tilman Date: Tue Mar 6 21:03:37 2018 New Revision: 1826044 URL: http://svn.apache.org/viewvc?rev=1826044&view=rev Log: PDFBOX-4020: add comment + reformat
Modified: pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateEmbeddedTimeStamp.java Modified: pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateEmbeddedTimeStamp.java URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateEmbeddedTimeStamp.java?rev=1826044&r1=1826043&r2=1826044&view=diff ============================================================================== --- pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateEmbeddedTimeStamp.java (original) +++ pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateEmbeddedTimeStamp.java Tue Mar 6 21:03:37 2018 @@ -194,11 +194,15 @@ public class CreateEmbeddedTimeStamp * Extracts last Document-Signature from the document * * @param document to get the Signature from - * @return the Signature, where a TimeStamp will be added. <code>null</code> when no Document-Signature available. - * @throws IOException + * + * @return the Signature, where a TimeStamp will be added. <code>null</code> when no + * Document-Signature is available. */ private void getRelevantSignature(PDDocument document) throws IOException { + // we can't use getLastSignatureDictionary() because this will fail (see PDFBOX-3978) + // if a signature is assigned to a pre-defined empty signature field that isn't the last. + // we get the last in time by looking at the offset in the PDF file. SortedMap<Integer, PDSignature> sortedMap = new TreeMap<Integer, PDSignature>(); for (PDSignature sig : document.getSignatureDictionaries()) {