PDFRasterizer.NET 4.0 is now available. Supports .NET Core. Renders pixel-perfectly.
- How to use a system font for rendering text
- Customize the GUI interaction of a radio button
- Customize the UI interaction of a check box
- How to reduce PDF file size
- How do I create graphics with Icc based colors
- Draw interactively on a PDF page
- Verify a custom digital PDF signature
- How do I use PDFControls.NET in a WPF application
- Fill PDF form
- Flatten PDF form
- Digitally sign a PDF form in C# or VB.NET
- C# render pdf in browser using MVC
- Add hyperlink to PDF
- Rotate a PDF page
- Change the formatting of a numeric field
- Override MouseWheel event
- How to create a thumbnail viewer
- EMF to PDF as vector image
- EMF to PDF as raster image
- Add a rubber stamp annotation with a custom icon
- Create a text annotation in PDF with rich text
- Read and write meta data from PDF
- Use multiple licenses
Digitally sign a PDF form in C# or VB.NET
Import a digital signature and sign a PDF.
Digital signatures can be used for many types of documents where traditional hand written signatures were used in the past. This code sample shows you how you can import a digital signature and use it to sign a PDF document in C# or VB.NET.
using (FileStream inFile = new FileStream("f1040a.pdf", FileMode.Open, FileAccess.Read))
{
// open document with signature fioeld
Document document = new Document(inFile);
// retrieve signature field
SignatureField field = document.Fields["SignHere"] as SignatureField;
// open certicate store.
Pkcs12Store ks = null;
using (FileStream file = new FileStream("ChrisSharp.pfx", FileMode.Open, FileAccess.Read))
{
ks = new Pkcs12Store(file, "Sample");
}
// let the SignatureHandler factory decide which type should be used.
SignatureHandler handler = StandardSignatureHandler.Create(ks);
field.SignatureHandler = handler;
// set some optional info.
field.ContactInfo = "+31 (0)77 4748677";
field.Location = "The Netherlands";
field.Reason = "I fully agree!";
// optional code to set image:
// enumerate widgets
foreach (SignatureWidget widget in field.Widgets)
{
SignatureAppearance signedAppearance = new SignatureAppearance();
signedAppearance.Style = SignatureAppearanceStyle.ImageAndText;
signedAppearance.Bitmap = new System.Drawing.Bitmap("logo.gif");
widget.SignedAppearance = signedAppearance;
widget.BackgroundColor = System.Drawing.Color.LightPink;
}
// write the modified document to disk
// note: signing requires read-write file access
using (FileStream outFile = new FileStream("signed.pdf", FileMode.Create, FileAccess.ReadWrite))
{
document.Write(outFile);
}
}
Sub Main()
Using inFile As New FileStream("f1040a.pdf", FileMode.Open, FileAccess.Read)
' open document with signature fioeld
Dim document As New Document(inFile)
' retrieve signature field
Dim field As SignatureField = TryCast(document.Fields("SignHere"), SignatureField)
' open certicate store.
Dim ks As Pkcs12Store = Nothing
Using file As New FileStream("..\..\../inputdocuments/ChrisSharp.pfx", FileMode.Open, FileAccess.Read)
ks = New Pkcs12Store(file, "Sample")
End Using
' let the SignatureHandler factory decide which type should be used.
Dim handler As SignatureHandler = StandardSignatureHandler.Create(ks)
field.SignatureHandler = handler
' set some optional info.
field.ContactInfo = "+31 (0)77 4748677"
field.Location = "The Netherlands"
field.Reason = "I fully agree!"
' optional code to set image:
' enumerate widgets
For Each widget As SignatureWidget In field.Widgets
Dim signedAppearance As New SignatureAppearance()
signedAppearance.Style = SignatureAppearanceStyle.ImageAndText
signedAppearance.Bitmap = New System.Drawing.Bitmap("..\..\../inputdocuments/logo_pdfkit.gif")
widget.SignedAppearance = signedAppearance
widget.BackgroundColor = System.Drawing.Color.LightPink
Next
' write the modified document to disk
' note: signing requires read-write file access
Using outFile As New FileStream("..\..\signed.pdf", FileMode.Create, FileAccess.ReadWrite)
document.Write(outFile)
End Using
End Using
End Sub
The signature field in the PDF now looks like this:

Download PDFControls.NET 2.0
We will send you a download link
Why do we ask your email address?
We send tips that speed up your evaluation
We let you know about bug fixes
You can always unsubscribe with one click
We never share your address with a 3rd party
Thank you for your download
We have sent an email with a download link.