![]() New FileStream( this.outputPDF, FileMode.Create, FileAccess.Write), ' \0', null, true) PdfStamper st = PdfStamper.CreateSignature(reader, PdfReader reader = new PdfReader( this.inputPDF) Public void Sign( string SigReason, string SigContact, string SigLocation, bool visible) The most important method here is the Sign method (will be explained below). PDFSigner: the construction of this class takes a Cert object and, if needed, a MetaData object.Cert: this class is used to hold a certificate and extract the needed information for the signature the most important method in this class is processCert (will be explained below).It’s a helper package that uses iTextSharp and doed everything you need for digital signatures. In the source code provided with this article, I wrote a library called PDFSigner. If everything goes well, open your explorer and browse to the location you entered for the target file, open this file with Adobe Acrobat reader, and your document is signed! =). In the debug box, you’ll see the operation’s progress. Add signature information if needed (reason, contact, and location).Give the password you used to extract the certificate.pfx file) you just extracted and choose it. Add/modify the PDF meta data if you want.Browse and choose a destination PDF file.Browse to the PDF source file you want to sign.You are now ready to use the code provided in this article. Enter a password when prompted (don't give an empty one!!!).Follow the wizard, and when asked, choose to include private key with the extracted certificate.Choose a certificate from the list and click Export.Go to the 'Content' tab and click 'Certificates'.Open Internet Explorer and click on Tools, then Internet Options.Then, extract the PKCS#12 certificate as described below: If you don’t have one, you can install the demo certificate from here. So the first thing you have to do is to install a certificate on your browser. I 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. ITextSharp provides a lot of interesting features to create and manipulate PDF documents, but in this article, we will only use digital signature functions. If you don’t know what digital signatures are or how they work, you can go here or here, or simply ask Google :) You'll need Visual Studio 2005 to be able to open and build the project. ![]() I will use the excellent and free port of iText library: iTextSharp that can be downloaded here. In this article, I will present a simple source code allowing you to digitally sign a PDF document and modify its metadata.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |