I am currently working with Aspose.PDF for .NET version 22.2.0 in a .NET 9 project, and I have an important question regarding digital signature preservation when filling PDF form fields.
Current Situation: I need to fill form fields in PDF documents that already contain valid digital signatures. However, based on my testing and research, it appears that any form field modification using standard Aspose.PDF methods invalidates existing digital signatures in the document.
Specific Question: Is it accurate that in Aspose.PDF version 22.2.0, any form field filling operation will invalidate existing digital signatures? I have tried various approaches.
Any change in signed PDF document will revoke the signature is as per the Adobe Guidelines and Standards. Aspose.PDF is built on the same standards. Please let us know if you have any other questions.
PS: Please note that we recommend using the latest version of the API always as it contains maximum fixes and improvements.
This is not true - it is possible to save PDFs incrementally while preserving the document’s digital signatures.
We need a way to fill PDF form fields and save incrementally while preserving the signatures.
We have used the itext.pdf (https://itextpdf.com) library and successfully filled PDF form fields with incremental saving without invalidating existing signatures.
Aspose.PDF for .NET does support incremental saving. In order to save document incrementally we should open the document file for writing. Therefore Document must be initialized with writable stream like in the next code snippet:
Document doc = new Document(new FileStream(“document.pdf”, FileMode.Open, FileAccess.ReadWrite));
// make some changes and save the document incrementally
doc.Save();
However, about signature preserving, we already saw some issues in the past that any change in the signed document was causing revoking of the signatures or PDF/A compliance. Nevertheless, we will check further in details to verify this scenario and let you know.
We have confirmed that incremental saving can prevent the signature invalidation. However, if you are facing this issue, please share your sample PDF document along with the code snippet that you tried at your end. We will test the scenario in our environment and address it accordingly.
Attached is the PDF with one digital signature, and an example where we tried to fill in a field and save incrementally. This example invalidates the signature already present in the PDF, which does not happen if we use iText.pdf
static void Sample(string pdfPath)
{
using var fs = new FileStream(pdfPath, FileMode.Open, FileAccess.ReadWrite);
using var document = new Document(fs);
var field = document.Form.Fields.FirstOrDefault(x => x.FullName == "field1");
if (field is null)
{
throw new Exception("Field not found");
}
field.ReadOnly = false;
field.Value = "Test Value";
field.Flatten();
document.Save();
}
Would you please check the attached PDF document which was generated in our environment and see if signatures are valid in it? blank-aspose.pdf (181.7 KB)
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-60183
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.