Digital Signature in PDF with BIRT
Comments
-
You should be able to do this with iText. Here's a snippet of the code that will sign the PDF<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
KeyStore ks = KeyStore.getInstance("pkcs12");
ks.load(new FileInputStream("my_private_key.pfx"), "my_password".toCharArray());
String alias = (String)ks.aliases().nextElement();
PrivateKey key = (PrivateKey)ks.getKey(alias, "my_password".toCharArray());
Certificate[] chain = ks.getCertificateChain(alias);
PdfReader reader = new PdfReader("original.pdf");
FileOutputStream fout = new FileOutputStream("signed.pdf");
PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0');
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
sap.setReason("I'm the author");
sap.setLocation("Lisbon");
// comment next line to have an invisible signature
sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null);
stp.close();
</pre>
<br />
There appears to be a lot of good information <a class='bbc_url' href='http://itextpdf.sourceforge.net/howtosign.html'>at this sourceforge page</a>Warning No formatter is installed for the format ipb0 -
<blockquote class='ipsBlockquote' data-author="'Elias123'" data-cid="110638" data-time="1350544234" data-date="18 October 2012 - 12:10 AM"><p>
Sorry I could not understand what is iText, is it a software to use with BIRT? Where should I insert this code?<br />
<br />
If you can send me the steps showing how to configure the report for this purpose.<br />
<br />
Thank you very much for your help.<br /></p></blockquote>
<br />
iText is a library that allows you to create and manipulate PDF documents. With BIRT you create your report (PDF) so after that you can use iText to attach a digital signature, downlaod the JAR from <a class='bbc_url' href='http://itextpdf.com/'>http://itextpdf.com/</a> and add to your projectWarning No formatter is installed for the format ipb0 -
Hello,
I included the JAR libraries in BIRT, still have to insert the below code, where should I insert it??
KeyStore ks = KeyStore.getInstance("pkcs12");
ks.load(new FileInputStream("my_private_key.pfx"), "my_password".toCharArray());
String alias = (String)ks.aliases().nextElement();
PrivateKey key = (PrivateKey)ks.getKey(alias, "my_password".toCharArray());
Certificate[] chain = ks.getCertificateChain(alias);
PdfReader reader = new PdfReader("original.pdf");
FileOutputStream fout = new FileOutputStream("signed.pdf");
PdfStamper stp = PdfStamper.createSignature(reader, fout, '\0');
PdfSignatureAppearance sap = stp.getSignatureAppearance();
sap.setCrypto(key, chain, null, PdfSignatureAppearance.WINCER_SIGNED);
sap.setReason("I'm the author");
sap.setLocation("Lisbon");
// comment next line to have an invisible signature
sap.setVisibleSignature(new Rectangle(100, 100, 200, 200), 1, null);
stp.close();
Thank you very much for your kind help!0 -
<blockquote class='ipsBlockquote' data-author="'smgomes'" data-cid="110644" data-time="1350550521" data-date="18 October 2012 - 01:55 AM"><p>
iText is a library that allows you to create and manipulate PDF documents. With BIRT you create your report (PDF) so after that you can use iText to attach a digital signature, downlaod the JAR from <a class='bbc_url' href='http://itextpdf.com/'>http://itextpdf.com/</a> and add to your project <br /></p></blockquote>
<br />
<br />
I have added the jar files in BIRT and I inserted the code in initialize, but I couldn't!<br />
<br />
It says that there is a ';' missing. Please check the attached screenshot.<br />
<br />
Plus I couldn't find what should be the instance (first line)<br />
<br />
<br />
Any help for this?0
Categories
- All Categories
- 108 Developer Announcements
- 53 Articles
- 106 General Questions
- 144 IM Services
- 43 OpenText Hackathon
- 32 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 899 Cloud Fax and Notifications
- 77 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 120 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management