@@ -829,10 +829,11 @@ protected void preClose(Map<PdfName, Integer> exclusionSizes) throws IOException
829
829
830
830
ap .put (PdfName .N , appearance .getAppearance ().getPdfObject ());
831
831
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
836
837
document .getCatalog ().setModified ();
837
838
}
838
839
}
@@ -851,18 +852,21 @@ protected void preClose(Map<PdfName, Integer> exclusionSizes) throws IOException
851
852
if (certificationLevel > 0 ) {
852
853
addDocMDP (cryptoDictionary );
853
854
}
854
- if (fieldLock != null )
855
+ if (fieldLock != null ) {
855
856
addFieldMDP (cryptoDictionary , fieldLock );
856
- if (signatureEvent != null )
857
+ }
858
+ if (signatureEvent != null ) {
857
859
signatureEvent .getSignatureDictionary (cryptoDictionary );
860
+ }
858
861
859
862
if (certificationLevel > 0 ) {
860
863
// add DocMDP entry to root
861
864
PdfDictionary docmdp = new PdfDictionary ();
862
865
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 ();
864
868
}
865
-
869
+ cryptoDictionary . getPdfObject (). flush ( false );
866
870
document .close ();
867
871
868
872
range = new long [exclusionLocations .size () * 2 ];
@@ -906,11 +910,11 @@ protected void preClose(Map<PdfName, Integer> exclusionSizes) throws IOException
906
910
} catch (IOException e ) {
907
911
try {
908
912
raf .close ();
909
- } catch (Exception ee ) {
913
+ } catch (Exception ignored ) {
910
914
}
911
915
try {
912
916
tempFile .delete ();
913
- } catch (Exception ee ) {
917
+ } catch (Exception ignored ) {
914
918
}
915
919
throw e ;
916
920
}
0 commit comments