Longterm Validation and Archival
We support creating PDF documents for long term archival as PAdES-LTV or PAdES-LTA compliant documents.
PAdES LTV document:
When a PDF is signed, it’s validation information is tend to live for a short time after which the signature cannot be verified. To avoid the issue the ETSI provides a specification by which the information required for validating the signature can be embedded into the PDF as a Document Security Store (DSS) by incrementally updating the document.
In order to mark a signature to as PAdES LTV complaint it has to be PAdES Enhanced complaint at the time of creating the signature. If not the reader will mark it as PAdES Basic complaint and there wont be any exception while creating/updating the document.
Below sample code is to create a PAdES-LTV compliant PDF from scratch.
Document document = new Document();
Page page = new Page();
document.Pages.Add(page);
page.Elements.Add(new TextArea("PAdES LTV Compiant document", 10, 10, 200, 50));
Signature signature = new Signature("SigningField", 10, 110, 100, 100);
page.Elements.Add(signature);
signature = new Signature("TimeStampField", 10, 400, 100, 100);
signature.Visible = false;
page.Elements.Add(signature);
// Specify a valid certificate
Certificate certificate = new Certificate("CERT WITH PRIVATE KEY");
// Set the signature type as PAdES-Enhances BES
certificate.SignatureType = SignatureType.PAdESEnhancedBES;
// Specify a TimestampServer. Else the signature will be marked as PAdES Basic
TimestampServer timestampServer = new TimestampServer("TIMESTAMP Server Address");
document.Sign("SigningField", certificate, timestampServer);
document.Draw(outputPath);
Dim document As Document = New Document()
Dim page As Page = New Page()
document.Pages.Add(page)
page.Elements.Add(New TextArea("PAdES LTV Compiant document", 10, 10, 200, 50))
Dim signature As Signature = New Signature("SigningField", 10, 110, 100, 100)
page.Elements.Add(signature)
signature = New Signature("TimeStampField", 10, 400, 100, 100)
signature.Visible = False
page.Elements.Add(signature)
'Specify a valid certificate
Dim certificate As Certificate = New Certificate("CERT WITH PRIVATE KEY")
'Set the signature type as PAdES-Enhances BES
certificate.SignatureType = SignatureType.PAdESEnhancedBES
'Specify a TimestampServer. Else the signature will be marked as PAdES Basic
Dim timestampServer As TimestampServer = New TimestampServer("TIMESTAMP Server Address")
document.Sign("SigningField", certificate, timestampServer)
document.Draw(outputPath)
Below sample code is to make an existing PDF as PAdES-LTV compliant.
//Create an IncrementalUpdateDocument object using the source PDF that is being updated incrementally.
//The source document should have the proper permissions to do the updates.
IncrementalUpdateDocument incrementalDocument = new IncrementalUpdateDocument(new PdfDocument(sourcePdfPath));
// Update all the signed fields to be PAdES-LTV complaint.
incrementalDocument.AddPadesLtv();
// Save the document
incrementalDocument.Draw(outPath);
'Create an IncrementalUpdateDocument object using the source PDF that Is being updated incrementally.
'The source document should have the proper permissions to do the updates.
Dim incrementalDocument As IncrementalUpdateDocument = New IncrementalUpdateDocument(New PdfDocument(sourcePdf))
'Update all the signed fields to be PAdES-LTV complaint.
incrementalDocument.AddPadesLtv()
' Save the document
incrementalDocument.Draw(outPath)
We can also use different Ltv embedding options using the class LtvEmbeddingOption. Below is a sample code.
//Create an IncrementalUpdateDocument object using the source PDF that is being updated incrementally.
//The source document should have the proper permissions to do the updates.
IncrementalUpdateDocument incrementalDocument = new IncrementalUpdateDocument(new PdfDocument(sourcePdfPath));
// Update the specified signed fields to be PAdES-LTV complaint.
incrementalDocument.AddPadesLtv(new LtvEmbeddingOption(fieldNames));
// Save the document
incrementalDocument.Draw(outPath);
'Create an IncrementalUpdateDocument object using the source PDF that Is being updated incrementally.
'The source document should have the proper permissions to do the updates.
Dim incrementalDocument As IncrementalUpdateDocument = New IncrementalUpdateDocument(New PdfDocument(sourcePdf))
'Update the specified signed fields to be PAdES-LTV complaint.
Dim veri As VerificationInformation = VerificationInformation.All
Dim sigField() As String = {"string Array of Signature Fields"}
Dim options As LtvEmbeddingOption = New LtvEmbeddingOption(sigField, veri)
incrementalDocument.AddPadesLtv(options)
' Save the document
incrementalDocument.Draw(outPath)
PAdES LTA document:
Adding document timestamp incrementally to the document containing PAdES LTV signatures will make it PAdES LTA compliant document. Adding a document timestamp is similar to signing and requires an unsigned signature field.
Adding document timestamp is required even if the signature contains a timestamped contents. (Which is required for PAdES Enhanced)
//Create an IncrementalUpdateDocument object using the source PDF that is being updated incrementally.
//The source document should have the proper permissions to do the updates.
IncrementalUpdateDocument incrementalDocument = new IncrementalUpdateDocument(new PdfDocument(sourcePDF));
// Specify a valid timestamp server to timestamp the document. If the existing signatures are PAdES-LTV compliant then this process will make it as LTA.
// The timestamp information can be added only to the existing signature fields of a document.
TimestampServer timeStampServer = new TimestampServer("Time Stamp Server Address");
incrementalDocument.Timestamp("TimeStampField", timeStampServer);
// Save the document
incrementalDocument.Draw(outPath);
'Create an IncrementalUpdateDocument object using the source PDF that Is being updated incrementally.
'The source document should have the proper permissions to do the updates.
Dim incrementalDocument As IncrementalUpdateDocument = New IncrementalUpdateDocument(New PdfDocument(sourcePdf))
'Specifying TimeStamp Server URL for Timestamping.
Dim timestampServer As TimestampServer = New TimestampServer("TimeStamp Server URL")
incrementalDocument.Timestamp("SignField", timestampServer)
' Save the document
incrementalDocument.Draw(outPath)