You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2018/03/06 21:03:37 UTC
svn commit: r1826044 -
/pdfbox/branches/2.0/examples/src/main/java/org/apache/pdfbox/examples/signature/CreateEmbeddedTimeStamp.java
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())
{