Table of Contents

Class PdfSignatureEventArgs

Namespace
Syncfusion.Pdf.Security
Assembly
Syncfusion.Pdf.Portable.dll

Represents the arguments of PdfSignature event.

public class PdfSignatureEventArgs : EventArgs
Inheritance
PdfSignatureEventArgs
Inherited Members

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.

public byte[] Data { get; }

Property Value

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.

public byte[] SignedData { get; set; }

Property Value

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