- Category: ASP.NET
Try below links..
You can do it using itextSharp, a free pdf operations library.
Please find code for implementing digital signatures using iTexstSharp:
- #766110Dotnet does not have a API to interact with PDF files directly, you need to take support of some third party DLL to deal with PDF
you can use iTextSharp dll, this library will allow you to do this. iTextSharp provides a lot of interesting features to create and manipulate PDF documents, you will also use some function to manipulate PKCS#12 certificates; the only thing you need to know here is that our digital signature will use a private key extracted from a PKCS#12 certificate.
see below links
alternatively, you can use
.NET Digital Signature Library, its used to to digitally sign files in PDF, CAdES or PKCS#7 cryptographic standard (.P7S or .P7M files) using X.509 certificates stored on PFX files or smart cards, USB tokens, HSM's (Hardware Security Modules) stored on Microsoft Certificate Store. see below snippet
Editor, DotNetSpider MVM
Microsoft MVP 2014 [ASP.NET/IIS]
- #766119There are lot of 3rd party DLL to create PDF files. But you can use "iTextSharp". This is open source. It is very simple to create the PDF
You can create the PDF by using simple MemoryStream also.
using (MemoryStream ms = new MemoryStream())
Document document = new Document(PageSize.A4, 25, 25, 30, 30);
PdfWriter writer = PdfWriter.GetInstance(document, ms);
document.Add(new Paragraph("Hello World"));
Response.ContentType = "pdf/application";
"attachment;filename=First PDF document.pdf");
Response.OutputStream.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length);
Direction is important than speed
Here is a step by step guidance for implementing digital signature in a pdf file in C# using a free .NET pdf library for your reference:
- #766189Firstly, thanks for all who have guided me. Hi bharati, I have tried the examples listed in the link: http://www.signfiles.com/manuals/SignatureLibraryUserManual.pdf and also able to place the signature in PDF file. But I could not place the signature wherever I want. I will explain my process. I had developed the software in vb6 which generates monthly invoices. Once we generates the invoices, we are converting those invoices into pdf files through software. Now I want to place signature at the end of the invoice. The end of the invoice may come to half of first page in pdf file or half of the second page in pdf file or at the end of the second page in pdf file. It is based on the length of the invoice. You please guide me how to place the signature in pdf at particular point.
have you tried
PdfSignature.SignaturePosition = SignaturePosition.TopRight/TopMiddle/BottomRight ?
Or if you are using rectangle for signature positioning, then pass proper calculated height and width to it.