Skip to content

Commit 7d49340

Browse files
committed
1 parent e8fbd04 commit 7d49340

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

sign/src/main/java/com/itextpdf/signatures/PdfSigner.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -829,10 +829,11 @@ protected void preClose(Map<PdfName, Integer> exclusionSizes) throws IOException
829829

830830
ap.put(PdfName.N, appearance.getAppearance().getPdfObject());
831831
acroForm.addField(sigField, document.getPage(pagen));
832-
if(acroForm.getPdfObject().isIndirect()) {
833-
acroForm.setModified(); // TODO: test this (ain't sure whether I need this)
834-
}else{
835-
//Acroform dictionary is a Direct dictionary, for proper flushing, catalog needs to be marked as modified
832+
if (acroForm.getPdfObject().isIndirect()) {
833+
acroForm.setModified();
834+
} else {
835+
//Acroform dictionary is a Direct dictionary,
836+
//for proper flushing, catalog needs to be marked as modified
836837
document.getCatalog().setModified();
837838
}
838839
}
@@ -851,18 +852,21 @@ protected void preClose(Map<PdfName, Integer> exclusionSizes) throws IOException
851852
if (certificationLevel > 0) {
852853
addDocMDP(cryptoDictionary);
853854
}
854-
if (fieldLock != null)
855+
if (fieldLock != null) {
855856
addFieldMDP(cryptoDictionary, fieldLock);
856-
if (signatureEvent != null)
857+
}
858+
if (signatureEvent != null) {
857859
signatureEvent.getSignatureDictionary(cryptoDictionary);
860+
}
858861

859862
if (certificationLevel > 0) {
860863
// add DocMDP entry to root
861864
PdfDictionary docmdp = new PdfDictionary();
862865
docmdp.put(PdfName.DocMDP, cryptoDictionary.getPdfObject());
863-
document.getCatalog().put(PdfName.Perms, docmdp); // TODO: setModified?
866+
document.getCatalog().put(PdfName.Perms, docmdp);
867+
document.getCatalog().setModified();
864868
}
865-
869+
cryptoDictionary.getPdfObject().flush(false);
866870
document.close();
867871

868872
range = new long[exclusionLocations.size() * 2];
@@ -906,11 +910,11 @@ protected void preClose(Map<PdfName, Integer> exclusionSizes) throws IOException
906910
} catch (IOException e) {
907911
try {
908912
raf.close();
909-
} catch (Exception ee) {
913+
} catch (Exception ignored) {
910914
}
911915
try {
912916
tempFile.delete();
913-
} catch (Exception ee) {
917+
} catch (Exception ignored) {
914918
}
915919
throw e;
916920
}

0 commit comments

Comments
 (0)