Home
Analytics
Digital Signature in PDF with BIRT
Pico
Hi,
Anyone knows if it`s possible generate pdf with digital signature usin BIRT?
Thanks in advance.
Find more posts tagged with
Comments
mwilliams
Hi Pico,
Can you explain what you're wanting exactly for your digital signature?
Elias123
Please I need to find out how to generate and attach a
digital signature to a report?
The standard to use is X 509.
Please I need your help urgently.
Thank you in advance!
kclark
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>
Elias123
Sorry I could not understand what is iText, is it a software to use with BIRT? Where should I insert this code?
If you can send me the steps showing how to configure the report for this purpose.
Thank you very much for your help.
smgomes
<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 project
Elias123
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!
Elias123
<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?