Class PdfSignatureEventArgs
Represents the arguments of PdfSignature event.
Inheritance
System.Object
System.EventArgs
PdfSignatureEventArgs
Inherited Members
System.EventArgs.Empty
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Syncfusion.Pdf.Security
Assembly: Syncfusion.Pdf.Base.dll
Syntax
public class PdfSignatureEventArgs : EventArgs
Examples
//Load the existing PDF documnt.
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Get the page.
PdfLoadedPage page = document.Pages[0] as PdfLoadedPage;
//Create a new PDF signature instance.
PdfSignature signature = new PdfSignature(document, page, null, "Sig1");
//Set the signature bounds.
signature.Bounds = new RectangleF(0, 0, 200, 100);
//Call the compute hash event.
signature.ComputeHash += Signature_ComputeHash;
//Save the document.
document.Save("output.pdf");
//Close the document.
document.Close(true);
//ComputeHash event handler.
private void Signature_ComputeHash(object sender, PdfSignatureEventArgs ars)
{
//Get the document bytes.
byte[] documentBytes = ars.Data;
//Generate hash.
byte[] hash = SHA256.Create().ComputeHash(ars.Data);
//Include the signed data to PDF.
ars.SignedData = GetSignature(hash);
}
'Load the existing PDF documnt.
Dim document As New PdfLoadedDocument("Input.pdf")
'Get the page.
Dim page As PdfLoadedPage = TryCast(document.Pages(0), PdfLoadedPage)
'Create a new PDF signature instance.
Dim signature As New PdfSignature(document, page, Nothing, "Sig1")
'Set the signature bounds.
signature.Bounds = New RectangleF(0, 0, 200, 100)
'Call the compute hash event.
AddHandler signature.ComputeHash , AddressOf Signature_ComputeHash
'Save the document.
document.Save("output.pdf")
'Close the document.
document.Close(True)
//ComputeHash event handler.
Private Sub Signature_ComputeHash(ByVal sender As Object, ByVal ars As PdfSignatureEventArgs)
'Get the document bytes.
Dim documentBytes As Byte() = ars.Data
'Generate hash.
Dim hash As Byte() = SHA256.Create().ComputeHash(ars.Data)
'Include the signed data to PDF.
ars.SignedData = GetSignature(hash)
End Sub
Properties
Data
Current PDF document range data for computing hash.
Declaration
public byte[] Data { get; }
Property Value
Type |
---|
System.Byte[] |
Examples
//Load the existing PDF documnt.
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Get the page.
PdfLoadedPage page = document.Pages[0] as PdfLoadedPage;
//Create a new PDF signature instance.
PdfSignature signature = new PdfSignature(document, page, null, "Sig1");
//Set the signature bounds.
signature.Bounds = new RectangleF(0, 0, 200, 100);
//Call the compute hash event.
signature.ComputeHash += Signature_ComputeHash;
//Save the document.
document.Save("output.pdf");
//Close the document.
document.Close(true);
//ComputeHash event handler.
private void Signature_ComputeHash(object sender, PdfSignatureEventArgs ars)
{
//Get the document bytes.
byte[] documentBytes = ars.Data;
//Generate hash.
byte[] hash = SHA256.Create().ComputeHash(ars.Data);
//Include the signed data to PDF.
ars.SignedData = GetSignature(hash);
}
'Load the existing PDF documnt.
Dim document As New PdfLoadedDocument("Input.pdf")
'Get the page.
Dim page As PdfLoadedPage = TryCast(document.Pages(0), PdfLoadedPage)
'Create a new PDF signature instance.
Dim signature As New PdfSignature(document, page, Nothing, "Sig1")
'Set the signature bounds.
signature.Bounds = New RectangleF(0, 0, 200, 100)
'Call the compute hash event.
AddHandler signature.ComputeHash , AddressOf Signature_ComputeHash
'Save the document.
document.Save("output.pdf")
'Close the document.
document.Close(True)
//ComputeHash event handler.
Private Sub Signature_ComputeHash(ByVal sender As Object, ByVal ars As PdfSignatureEventArgs)
'Get the document bytes.
Dim documentBytes As Byte() = ars.Data
'Generate hash.
Dim hash As Byte() = SHA256.Create().ComputeHash(ars.Data)
'Include the signed data to PDF.
ars.SignedData = GetSignature(hash)
End Sub
SignedData
Signed document data.
Declaration
public byte[] SignedData { get; set; }
Property Value
Type |
---|
System.Byte[] |
Examples
//Load the existing PDF documnt.
PdfLoadedDocument document = new PdfLoadedDocument("Input.pdf");
//Get the page.
PdfLoadedPage page = document.Pages[0] as PdfLoadedPage;
//Create a new PDF signature instance.
PdfSignature signature = new PdfSignature(document, page, null, "Sig1");
//Set the signature bounds.
signature.Bounds = new RectangleF(0, 0, 200, 100);
//Call the compute hash event.
signature.ComputeHash += Signature_ComputeHash;
//Save the document.
document.Save("output.pdf");
//Close the document.
document.Close(true);
//ComputeHash event handler.
private void Signature_ComputeHash(object sender, PdfSignatureEventArgs ars)
{
//Get the document bytes.
byte[] documentBytes = ars.Data;
//Generate hash.
byte[] hash = SHA256.Create().ComputeHash(ars.Data);
//Include the signed data to PDF.
ars.SignedData = GetSignature(hash);
}
'Load the existing PDF documnt.
Dim document As New PdfLoadedDocument("Input.pdf")
'Get the page.
Dim page As PdfLoadedPage = TryCast(document.Pages(0), PdfLoadedPage)
'Create a new PDF signature instance.
Dim signature As New PdfSignature(document, page, Nothing, "Sig1")
'Set the signature bounds.
signature.Bounds = New RectangleF(0, 0, 200, 100)
'Call the compute hash event.
AddHandler signature.ComputeHash , AddressOf Signature_ComputeHash
'Save the document.
document.Save("output.pdf")
'Close the document.
document.Close(True)
//ComputeHash event handler.
Private Sub Signature_ComputeHash(ByVal sender As Object, ByVal ars As PdfSignatureEventArgs)
'Get the document bytes.
Dim documentBytes As Byte() = ars.Data
'Generate hash.
Dim hash As Byte() = SHA256.Create().ComputeHash(ars.Data)
'Include the signed data to PDF.
ars.SignedData = GetSignature(hash)
End Sub