officefileapi-devexpress-dot-pdf-dot-pdfdocumentsigner-dot-savedocument-x28-system-dot-io-dot-stream-devexpress-dot-pdf-dot-pdfsignaturebuilder-x29.md
Saves the PDF document to a stream with the specified document signatures.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Docs.v25.2.dll
NuGet Package : DevExpress.Document.Processor
public void SaveDocument(
Stream stream,
params PdfSignatureBuilder[] signatures
)
Public Sub SaveDocument(
stream As Stream,
ParamArray signatures As PdfSignatureBuilder()
)
| Name | Type | Description |
|---|---|---|
| stream | Stream |
The stream to which to save the document.
| | signatures | PdfSignatureBuilder[] |
An array of signatures to apply to the document.
|
Call the SaveDocument method to apply one or more signatures to the PDF document. Specify the document to be signed in the PdfDocumentSigner object’s constructor.
You can add a signature to the existing signature field. Create a new PdfSignatureBuilder object with the signature field’s name passed as the constructor’s parameter.
Use the PdfSignatureFieldInfo instance in the PdfSignatureBuilder object constructor to create a new signature field. You can specify the field’s name, bounds, and rotation angle.
The PDF Document API supports PKCS#7 signatures. The Pkcs7Signer class allows you to create this signature type. You can create a Pkcs7SignerBase descendant to use a custom object to create the PKCS#7 signature.
using DevExpress.Pdf;
using DevExpress.Office.DigitalSignatures;
// Load a document to be signed
using (var signer = new PdfDocumentSigner("Document.pdf"))
{
// Create a PKCS#7 signature
Pkcs7Signer pkcs7Signature = new Pkcs7Signer("Signing Documents//testcert.pfx", "123", HashAlgorithmType.SHA256);
// Apply a signature to the Sign form field
var signatureBuilder = new PdfSignatureBuilder(pkcs7Signature, "Sign");
// Specify the signature's image and signer information:
signatureBuilder.SetImageData(System.IO.File.ReadAllBytes("Signing Documents//Jane Cooper.jpg"));
signatureBuilder.Location = "USA";
signatureBuilder.Name = "Jane Cooper";
signatureBuilder.Reason = "I Agree";
// Sign and save the document
signer.SaveDocument("SignedDocument.pdf", signatureBuilder);
}
Imports DevExpress.Pdf
Imports DevExpress.Office.DigitalSignatures
' Load a document to be signed
Using signer = New PdfDocumentSigner("Document.pdf")
' Create a PKCS#7 signature
Dim pkcs7Signature As New Pkcs7Signer("Signing Documents//testcert.pfx", "123", HashAlgorithmType.SHA256)
' Apply a signature to the Sign form field
Dim signatureBuilder = New PdfSignatureBuilder(pkcs7Signature, "Sign")
' Specify the signature's image and signer information:
signatureBuilder.SetImageData(System.IO.File.ReadAllBytes("Signing Documents//Jane Cooper.jpg"))
signatureBuilder.Location = "USA"
signatureBuilder.Name = "Jane Cooper"
signatureBuilder.Reason = "I Agree"
' Sign and save the document
signer.SaveDocument("SignedDocument.pdf", signatureBuilder)
End Using
See Also