PDF: How to add an empty signature field to PDF document?
In This Topic
Here is C#/VB.NET code that demonstrates how to add an empty signature field to a PDF document for further document signing by user:
using System.Drawing;
using Vintasoft.Imaging.Pdf;
/// <summary>
/// Adds an empty signature field to a PDF page.
/// </summary>
public class PdfPageDigitalSignatureHelper_EmptySignatureField
{
public static void Run()
{
// create a helper that alows to add digital signature to a PDF document
PdfPageDigitalSignatureHelper digitalSignatureHelper =
new PdfPageDigitalSignatureHelper(null, new RectangleF(20, 20, 250, 100));
// set the appearance for signature field
digitalSignatureHelper.SignatureText = "Add your signature here";
digitalSignatureHelper.SignatureBackgoundColor = Color.Yellow;
// open PDF document
using (PdfDocument document = new PdfDocument("TestDocumentToSign.pdf"))
{
// add signature field to the first PDF page
digitalSignatureHelper.AddEmptySignatureField(document.Pages[0]);
// save PDF document to the output file
document.SaveChanges("TestDocumentToSign-output.pdf");
}
}
}
Imports System.Drawing
Imports Vintasoft.Imaging.Pdf
''' <summary>
''' Adds an empty signature field to a PDF page.
''' </summary>
Public Class PdfPageDigitalSignatureHelper_EmptySignatureField
Public Shared Sub Run()
' create a helper that alows to add digital signature to a PDF document
Dim digitalSignatureHelper As New PdfPageDigitalSignatureHelper(Nothing, New RectangleF(20, 20, 250, 100))
' set the appearance for signature field
digitalSignatureHelper.SignatureText = "Add your signature here"
digitalSignatureHelper.SignatureBackgoundColor = Color.Yellow
' open PDF document
Using document As New PdfDocument("TestDocumentToSign.pdf")
' add signature field to the first PDF page
digitalSignatureHelper.AddEmptySignatureField(document.Pages(0))
' save PDF document to the output file
document.SaveChanges("TestDocumentToSign-output.pdf")
End Using
End Sub
End Class