Digital Signing Signer.Digital.WebLib .NET Integration Source Code Explained
NOTE: Signer.Digital Browser Extension is completely free for unlimited uses.
NOTE: This section is for Software Developers. If you are looking for ready to use software solution, please Contact Us.
If you are here looking to Digitally Sign your PDF online (causally) using Digital Signature from your USB Token or Smartcard, please visit Online PDF Signing
Download the sample .NET Integration Project for Signer.Digital.Weblib with complete Source Code.
-
Download and install Signer.Digital Browser Extension from CNet Download.
-
Enable extension by clicking exclamation sign on top right corner of your browser or restart browser and check Signer.Digital Extension has been enabled.
-
Create Folder (Say Signer.Digital.Web.NET.Demo) (or use any of your existing project folder).
-
Extract the downloaded Signer.Digital.Web.NET.Demo.zip to above created folder.
-
Open the project in Visual Studio 2015 and save the Solution.
-
For Web Forms project, click Open Website, select Web Forms project folder and save the solution.
-
Open NuGet Package Manager and RESTORE the NuGet Packages, if not done automatically.
-
Restart Visual Studio, if required, and open Solution again after checking all References are ok.
-
CODE LOGIC FLOW:
STEP 1: Web browser triggers the request to (generate) and sign PDF File.
Ref Code File: MVC Project - \Views\index.cshtml - function InitiateSignPDF()
InitiateSignePDF() method checks for SD Extension, and calls
//Call method from Extension SignerDigital to get Selected Certificate Subject and SerialNumber
SignerDigital.getSelectedCertificate() - use stored CertThumbprint as optional param to select certificate silently.
On Success, above method returns CertInfo
Further to this, JavaScript calls ServerAction with CertInfo.SelCertSubject and 'sdHubConnectionId' as parameter
Note: If you want signing on page load, especially Web Forms developers, do not code anything in Page_Load on server side, instead, use window.onload or body onload events to call InitiateSignPDF() Javascript function.
SETP 2: Action method on Server processes PDF File and Returns Signed File
Ref Code File: MVC Project - \Controllers\HomeController.cs
Action method SignPDF recives SelCertSubject and SDHubConnectionId as post parameters
Create instance of Class SDSignerWeb by injecting SDHubConnectionId (from library Signer.Digital.Weblib.dll)
Build PDFSignatureAppearence object pdfSAP using method GetPDFSignatureAppearence()
//Call actual method to sign from Signer.Digital.Weblib - SdSignerWeb.SignPDFFromBrowser
//=========== Method for Signing is just one line of code !!! =================================
txnResp = await SdSignerWeb.SignPDFFromBrowser(sourcefile, pdfSAP, "", "", "", SelCertSubject);
On Success, above method returns byte array of signed pdf file in SignedPDFFile property of response object.
SETP 3: Display Return response in ajax call in JavaScript method InitiateSignPDF()
............
success: function (data) {
//Signing Operation Completed
$("#ResultDisplay").html(data);
}
..........
The actual working of this project is illustrated here
If you found this (Digital Signing from Web Application) project and discussion useful, please rate use Good at Review us on Google now
---------------