Click or drag to resize

PdfSignatureFieldSign(FuncStream, Byte, PdfSignatureFormat, Int32) Method

Initiate signing of a PDF file using the specified delegate that does the actual signing in a format specified by signatureFormat.

The length of the signature returned by the signer delegate must be less than estimatedSignatureContentsLength.

The name of the preferred signature handler to use when validating the signature (Filter entry) is Adobe.PPKLite, the Format of the returned PdfSignature instance is signatureFormat and the ContentsLength is estimatedSignatureContentsLength bytes.

To finish the signing, call any of the Save. Next signing cannot be initiated before the current one is not finished.

The returned PdfSignature is set to the Value thus automatically updating the Appearance.

Note  Note
If the Value is not , then the method re-signs the PDF file directly and the Save should not be called. This behavior enables delay-sign and re-sign scenarios.

Namespace: SautinSoft.Pdf.Forms
Assembly: SautinSoft.Pdf (in SautinSoft.Pdf.dll) Version: 2024.11.26
Syntax
public PdfSignature Sign(
	Func<Stream, byte[]> signer,
	PdfSignatureFormat signatureFormat,
	int estimatedSignatureContentsLength
)

Parameters

signer  FuncStream, Byte
The signer delegate called when saving the PDF file that takes the PDF file stream (without Content entry) as an input and returns the signature that will be set as the value of the Content entry.
signatureFormat  PdfSignatureFormat
The encoding of the signature value and key information in the signature dictionary.
estimatedSignatureContentsLength  Int32
The estimated length of the Content entry (in bytes) that should be large enough to contain the entire data returned by the signer delegate.

Return Value

PdfSignature
A PdfSignature instance that contains signature properties (the time of signing, the name of the person or authority signing the document, the reason for the signing, the CPU host name or physical location of the signing); key information (the signing certificate used to verify the signature value and, optionally, other certificates used to verify the authenticity of the signing certificate); reference (describes the exact byte range for the digest calculation); and signature value (usually a DER-encoded PKCS#7 binary data object that conforms to RFC 5652 Cryptographic Message Syntax).
Exceptions
ExceptionCondition
ArgumentNullExceptionsigner is .
InvalidOperationExceptionThis PdfSignatureField is not contained in the Fields of this PDF document. -or- Signing/timestamping of the PDF file has already been initiated on some PdfSignatureField in this PDF document. Finish that signing/timestamping by calling any of the Save before initiating a new signing/timestamping on this PdfSignatureField.
See Also