Home

Bytescout.PDF for .NET



Bytescout.PDF library for .NET - add visible digital signature to existing PDF document

Download Free Trial Buy Now More Information
For HTML2PDF and XML2PDF solution check our PDFDoc Scout ActiveX library instead

Adding visible digital signature to an existing PDF document file

This example teaches how to open existing PDF and add visible digital signature to the rectangle area in existing PDF document using Bytescout.PDF library for NET

Download example source code: bytescoutpdf_add_visible_digital_signature_to_pdf.zip (14 KB)

screenshot of pdf with visible digital signature added to existing PDF using Bytescout.PDF library for .NET

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using Bytescout.PDF;

namespace DigitalSignature
{
class Program
{
static void Main(string[] args)
{
// Create main PDF Doc Engine
PDFDocEngine engine = new PDFDocEngine("demo", "demo");

// Open existing document
Document document = engine.AddDocument("HelloWorld.pdf");

// add digital signature from file
document.AddSignature("dig-signature.pfx", "John Doe", "Approved", false, "123456");

// now add visible signature drawing
Rectangle R;
R.Left = 10;
R.Top = 10;
R.Right = 800;
R.Bottom = 300;
// add signature for the rectangle
// IMPORTANT NOTE: Y scale of the rectangle is inverted due to the PDF nature ( 0,0 point in PDF starts at left bottom corner)
Drawing SignatureDrawing = document.GetPage(0).AddVisibleSignature(R);

// Add standard font
uint font = document.AddFontStandard(StandardFontType.Courier, FontEncodingType.WinAnsi);

// Set Active Font
SignatureDrawing.SetActiveFont(font, 50, false, false);

// draw a text
SignatureDrawing.PlaceText(10, 10, 0, "Approved by John Doe");
SignatureDrawing.Close();

// Save document
document.Save("signedWithVisibleSignature.pdf");

// open generated PDF document in default PDF viewer installed in Windows
Process.Start("signedWithVisibleSignature.pdf");
}
}
}

Download example source code: bytescoutpdf_add_visible_digital_signature_to_pdf.zip (14 KB)

Download Free Trial Buy Now More Information
For HTML2PDF and XML2PDF solution check our PDFDoc Scout ActiveX library instead

"Hello, World!" quick start step-by-step tutorials:

Advanced Examples:
Products  |  Download  |  Purchase  |  Support  |  Contacts  |  Testimonials |  

ByteScout, 2003-2008. All other company and product names may be trademarks of their respective companies. Privacy Statement