- Home
- Testimonials
- Purchase
- Developer Tools
- Desktop Utilities
- Download
- Support
- Blog
- Company
Sign and add visible digital signature to the rectangle area in existing PDF document with C# and Bytescout.PDF library for .NET
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)

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)
Filed in:
PDF SDK for .NET
Tutorials:


