|
C# PDF Document Process Library
How to add, remove, update PDF file digital signatures using C#.net
C# Solutions for Improving the Security of Your PDF File by Adding Digital Signatures in Visual C#.NET Class
In this C# tutorial, you learn how to manage PDF document digital signature
- Add digital signature to PDF
- Prepare a certification
- Add a signature
- Sign a PDF document
How to create digital signature for PDF document using C#
- Best .NET framework PDF SDK library for PDF signature manipulation in Visual C# .NET WinForms and ASP.NET WebForm project
- Provide free PDF signing application component to add signature to PDF file in C#.NET project
- Able to use online C# source code to create a signature for PDF document in Visual Studio .NET program
- Support .NET WinForms, ASP.NET MVC in IIS, ASP.NET Ajax, Azure cloud service, DNN (DotNetNuke), SharePoint
- Able to digitally sign a PDF file without adobe reader installed
- Add a signature or an empty signature field in any PDF file page
- Ability to insert signature in PDF form
- Detect and search signature field in PDF document
- Insert PDF signature certificate to sign PDF file
- Verify the validity of PDF signature
- Remove signature from PDF document
C# add digital signature to PDF document
#region add digital signature to PDF document
internal static void addDigitalSignature()
{
String inputFilePath = @"...";
String outputFilePath = @"...";
String imagePath = @"...";
String certSubjectName = @"...";
String fieldID = @"...";
X509Cert cert = PDFDigitalSignatureHandler.MakeCert(StoreName.My, StoreLocation.CurrentUser, certSubjectName);
// Set cert properties.
cert.Location = "CHINA SHANGHAI";
cert.Reason = "Reason";
cert.APMode = APMode.Text; // APMode.Text | APMode.Image.
cert.Image = new Bitmap(imagePath);
if (PDFDigitalSignatureHandler.Sign(inputFilePath, outputFilePath, cert, fieldID) == 0)
{
Console.WriteLine("[SUCCESS]");
}
else
{
Console.WriteLine("[FAILED]");
}
}
#endregion
C# search unsigned signature field in the PDF document
String inputFilePath = @"...";
List<SignatureField> vals = PDFDigitalSignatureHandler.SearchUnsignedFields(inputFilePath);
if (vals == null || vals.Count == 0)
{
Console.WriteLine("No Signature Field");
}
else
{
Console.WriteLine("Signature Fields");
for (int i = 0; i < vals.Count; i++)
{
Console.WriteLine(i + ": " + vals[i].ID + " (Pg " + vals[i].PageIndex + ")");
}
}
C# prepare a certification which used to sign a document
StoreName storeName = StoreName.My;
StoreLocation storeLocation = StoreLocation.CurrentUser;
String subjectName = "";
List<String> allSubjects = PDFDigitalSignatureHandler.GetAllSubjectNames(storeName, storeLocation, true);
foreach (String str in allSubjects)
{
Console.WriteLine("Make certification by name: " + str);
X509Cert cert = PDFDigitalSignatureHandler.MakeCert(storeName, storeLocation, str);
//
}
C# add an empty signature field to pdf document
String inputFilePath = @"...";
String outputFilePath = @"...";
PDFSignature signature = new PDFSignature(new RectangleF(10F, 10F, 250F, 150F));
if (PDFDigitalSignatureHandler.CreateSignatureField(inputFilePath, outputFilePath, signature, 0) == 0)
{
Console.WriteLine("[SUCCESS]");
}
else
{
Console.WriteLine("[FAILED]");
}
C# sign a PDF document
String inputFilePath = @"...";
String outputFilePath = @"...";
String imagePath = @"...";
String certSubjectName = @"...";
String fieldID = @"...";
X509Cert cert = PDFDigitalSignatureHandler.MakeCert(StoreName.My, StoreLocation.CurrentUser, certSubjectName);
// set cert properties
cert.Location = "CHINA SHANGHAI";
cert.Reason = "Reason";
cert.APMode = APMode.Text; // APMode.Text | APMode.Image
cert.Image = new Bitmap(imagePath);
if (PDFDigitalSignatureHandler.Sign(inputFilePath, outputFilePath, cert, fieldID) == 0)
{
Console.WriteLine("[SUCCESS]");
}
else
{
Console.WriteLine("[FAILED]");
}
|