How to apply one or more digital signatures to a PDF? | Syncfusion (2024)

Syncfusion Essential PDF is aASP.NET Core PDF libraryused to create, read, and edit PDF documents. Using this library, you can apply one or more digital signature to a PDF document using C# and VB.NET.

Steps to apply one or more digital signature to PDF document programmatically:

  1. Create a new C# ASP.NET Core Web application project. How to apply one or more digital signatures to a PDF? | Syncfusion (1)
  2. Select Web application pattern (Model-View-Controller) for the project. How to apply one or more digital signatures to a PDF? | Syncfusion (2)
  3. Install the Syncfusion.Pdf.Net.Core NuGet package as reference to your .NET Standard application from NuGet.org. How to apply one or more digital signatures to a PDF? | Syncfusion (3)
  4. A default controller with name HomeController.cs gets added on creation of ASP.NET Core project. Include the following namespaces in that HomeController.cs file.

C#

using Syncfusion.Pdf;using Syncfusion.Pdf.Parsing;using Syncfusion.Pdf.Security;using Syncfusion.Pdf.Graphics;

VB.NET

Imports Syncfusion.PdfImports Syncfusion.Pdf.ParsingImports Syncfusion.Pdf.SecurityImports Syncfusion.Pdf.Graphics
  1. A default action method named Index will be present in HomeController.cs. Right-click the Index method and selectGo To Viewwhere you will be directed to its associated view pageIndex.cshtml.
  2. Add a new button in theIndex.cshtmlas follows.
    <h2>Click the button to generate PDF</h2>@using (Html.BeginForm("GeneratePDF", "Home", FormMethod.Post)){ <input type="submit" value="GeneratePDF" />}
  1. Add a new action methodGeneratePDF inHomeController.csand include the following code snippetto create a PDF file and download it.

C#

//Load the PDF documentFileStream docStream = new FileStream("SignatureFields.pdf", FileMode.Open, FileAccess.Read);PdfLoadedDocument loadedDocument = new PdfLoadedDocument(docStream);//Gets the first page of the documentPdfLoadedPage page = loadedDocument.Pages[0] as PdfLoadedPage;//Gets the first signature field of the PDF documentPdfLoadedSignatureField signatureField1 = loadedDocument.Form.Fields[0] as PdfLoadedSignatureField;//Creates a certificateFileStream certificateStream1 = new FileStream("PDF.pfx", FileMode.Open, FileAccess.Read);PdfCertificate certificate1 = new PdfCertificate(certificateStream1, "syncfusion");signatureField1.Signature = new PdfSignature(loadedDocument, page, certificate1, "Signature", signatureField1);FileStream imageStream = new FileStream("Student Signature.jpg", FileMode.Open, FileAccess.Read);//Draw imagePdfBitmap signatureImage = new PdfBitmap(imageStream);signatureField1.Signature.Appearance.Normal.Graphics.DrawImage(signatureImage, 0, 0, 90, 20);//Save the document into streamMemoryStream stream = new MemoryStream();loadedDocument.Save(stream);//Load the signed PDF documentPdfLoadedDocument signedDocument = new PdfLoadedDocument(stream);//Load the PDF pagePdfLoadedPage loadedPage = signedDocument.Pages[0] as PdfLoadedPage;//Gets the first signature field of the PDF documentPdfLoadedSignatureField signatureField2 = signedDocument.Form.Fields[1] as PdfLoadedSignatureField;signatureField2.Signature = new PdfSignature(signedDocument, loadedPage, certificate1, "Signature", signatureField2);FileStream imageStream1 = new FileStream("Teacher Signature.png", FileMode.Open, FileAccess.Read);PdfBitmap signatureImage1 = new PdfBitmap(imageStream1);//Draw imagesignatureField2.Signature.Appearance.Normal.Graphics.DrawImage(signatureImage1, 0, 0, 90, 20);//Saving the PDF to the MemoryStreamMemoryStream signedStream = new MemoryStream();signedDocument.Save(signedStream);//Set the position as '0'.signedStream.Position = 0;//Download the PDF document in the browserFileStreamResult fileStreamResult = new FileStreamResult(signedStream, "application/pdf");fileStreamResult.FileDownloadName = "DigitalSignatureSample.pdf";return fileStreamResult;

VB.NET

'Load the PDF documentDim docStream As FileStream = New FileStream("SignatureFields.pdf", FileMode.Open, FileAccess.Read)Dim loadedDocument As PdfLoadedDocument = New PdfLoadedDocument(docStream)'Gets the first page of the documentDim page As PdfLoadedPage = TryCast(loadedDocument.Pages(0), PdfLoadedPage)'Gets the first page of the documentDim signatureField1 As PdfLoadedSignatureField = TryCast(loadedDocument.Form.Fields(0), PdfLoadedSignatureField)'Creates a certificateDim certificateStream1 As FileStream = New FileStream("PDF.pfx", FileMode.Open, FileAccess.Read)Dim certificate1 As PdfCertificate = New PdfCertificate(certificateStream1, "syncfusion")signatureField1.Signature = New PdfSignature(loadedDocument, page, certificate1, "Signature", signatureField1)Dim imageStream As FileStream = New FileStream("Student Signature.jpg", FileMode.Open, FileAccess.Read)'Draw imageDim signatureImage As PdfBitmap = New PdfBitmap(imageStream)signatureField1.Signature.Appearance.Normal.Graphics.DrawImage(signatureImage, 0, 0, 90, 20)'Save the document into streamDim stream As MemoryStream = New MemoryStream()loadedDocument.Save(stream)'Load the signed PDF documentDim signedDocument As PdfLoadedDocument = New PdfLoadedDocument(stream)'Load the PDF pageDim loadedPage As PdfLoadedPage = TryCast(signedDocument.Pages(0), PdfLoadedPage)Dim signatureField2 As PdfLoadedSignatureField = TryCast(signedDocument.Form.Fields(1), PdfLoadedSignatureField)signatureField2.Signature = New PdfSignature(signedDocument, loadedPage, certificate1, "Signature", signatureField2)Dim imageStream1 As FileStream = New FileStream("Teacher Signature.png", FileMode.Open, FileAccess.Read)'Draw imageDim signatureImage1 As PdfBitmap = New PdfBitmap(imageStream1)signatureField2.Signature.Appearance.Normal.Graphics.DrawImage(signatureImage1, 0, 0, 90, 20)'Saving the PDF to the MemoryStreamDim signedStream As MemoryStream = New MemoryStream()signedDocument.Save(signedStream)'Set the position as '0'.signedStream.Position = 0'Download the PDF document in the browserDim fileStreamResult As FileStreamResult = New FileStreamResult(signedStream, "application/pdf")fileStreamResult.FileDownloadName = "DigitalSignatureSample.pdf"Return fileStreamResult

A complete working sample can be downloaded from DigitalSignatureSample.zip.

By executing the program, you will get the PDF document as follows. How to apply one or more digital signatures to a PDF? | Syncfusion (4)

Note:

Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.

Conclusion

Ihope you enjoyed learning about how toapply one or more digitalsignatures to a PDF in ASP.NET Core.

Youcan refer to ourASP.NET Core PDFfeature tourpage toknow about its othergroundbreaking feature representationsanddocumentation,and how toquickly getstarted for configuration specifications. You can also explore ourASP.NET Core PDF exampleto understand how to createand manipulate data in the .NET PDF.

Forcurrent customers,you can check out ourDocument processinglibrariesfrom theLicense and Downloadspage.If you arenew to Syncfusion, you can try our 30-dayfree trialto check out ourASP.NET Core PDF and other .NET Core controls.

Ifyou have any queries or require clarifications, please let us know in thecomments section below.You can also contact us through oursupport forums,Direct-Trac,orfeedback portal.We are always happy to assist you!

How to apply one or more digital signatures to a PDF? | Syncfusion (2024)
Top Articles
A Ukrainian soldier said they were 'suffering' from Russia's use of night-vision drones, says report
Proof of Work: An Overview of PoW Blockchains
Woodward Avenue (M-1) - Automotive Heritage Trail - National Scenic Byway Foundation
Umbc Baseball Camp
Don Wallence Auto Sales Vehicles
Rainbird Wiring Diagram
Nc Maxpreps
The Idol - watch tv show streaming online
Embassy Suites Wisconsin Dells
Osrs But Damage
Tribune Seymour
Obituary | Shawn Alexander | Russell Funeral Home, Inc.
Premier Reward Token Rs3
Shreveport Active 911
Blackwolf Run Pro Shop
Destiny 2 Salvage Activity (How to Complete, Rewards & Mission)
Saatva Memory Foam Hybrid mattress review 2024
Eine Band wie ein Baum
Quadcitiesdaily
Scout Shop Massapequa
Never Give Up Quotes to Keep You Going
Ezel Detailing
6 Most Trusted Pheromone perfumes of 2024 for Winning Over Women
Kohls Lufkin Tx
Vera Bradley Factory Outlet Sunbury Products
Tactical Masters Price Guide
Ullu Coupon Code
Dailymotion
Rugged Gentleman Barber Shop Martinsburg Wv
Dentist That Accept Horizon Nj Health
Kaiser Infozone
Kids and Adult Dinosaur Costume
Moonrise Time Tonight Near Me
Emily Katherine Correro
15 Downer Way, Crosswicks, NJ 08515 - MLS NJBL2072416 - Coldwell Banker
How to Draw a Bubble Letter M in 5 Easy Steps
Solve 100000div3= | Microsoft Math Solver
Ark Unlock All Skins Command
Vivek Flowers Chantilly
Trizzle Aarp
Join MileSplit to get access to the latest news, films, and events!
Firestone Batteries Prices
2007 Jaguar XK Low Miles for sale - Palm Desert, CA - craigslist
Mississippi weather man flees studio during tornado - video
Juiced Banned Ad
Www Pig11 Net
Every Type of Sentinel in the Marvel Universe
Craiglist.nj
Google Flights Missoula
18443168434
Equinox Great Neck Class Schedule
Latest Posts
Article information

Author: Duncan Muller

Last Updated:

Views: 6203

Rating: 4.9 / 5 (59 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Duncan Muller

Birthday: 1997-01-13

Address: Apt. 505 914 Phillip Crossroad, O'Konborough, NV 62411

Phone: +8555305800947

Job: Construction Agent

Hobby: Shopping, Table tennis, Snowboarding, Rafting, Motor sports, Homebrewing, Taxidermy

Introduction: My name is Duncan Muller, I am a enchanting, good, gentle, modern, tasty, nice, elegant person who loves writing and wants to share my knowledge and understanding with you.