You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Ruben Lagar <ru...@gmail.com> on 2014/08/07 21:35:03 UTC
Visual signature signer name, location and reason
Hello all,
I am using the latest snapshot of version 2 to sign a PDF and everything is
working smoothly.
I am now trying to modify my code so the signature includes a visual
element in one page of the PDF. I have been able to add a JPG image,
however I don´t understand very well the purpose of many of the properties
that can be tuned.
For example, signerName(), signerLocation() and signatureReason() in the
class PDVisibleSigProperties don´t seem to have any effect. Also, no matter
what page I set on the constructor of PDVisibleSignDesigner, the image is
always added in the first page. And finally, I tried to use signatureText()
on PDVisibleSignDesigner, but that method is not implemented.
My code is
*PDVisibleSigProperties signatureProperties = new PDVisibleSigProperties();*
*FileInputStream imageInputStream = new FileInputStream("myImage.gif"); *
*PDVisibleSignDesigner visibleSig = new PDVisibleSignDesigner(new
ByteArrayInputStream(content), imageInputStream, 3)*
*
.signatureFieldName("signature").xAxis(10).yAxis(10).height(82).width(200);*
*signatureProperties.signerName("name").signerLocation("location").signatureReason("Security").preferredSize(0)*
*
.visualSignEnabled(true).setPdVisibleSignature(visibleSig).buildSignature();*
*options.setVisualSignature(signatureProperties);*
*...*
*PDDocument doc = null;*
*ByteArrayInputStream bais = null;*
*try {*
* bais = new ByteArrayInputStream(content);*
* doc = PDDocument.load(bais);*
* doc.addSignature(signature, this, options);*
*} finally {*
* IOUtils.closeQuietly(bais);*
*}*
*...*
*FileOutputStream fos = null;ByteArrayInputStream bais2 = null;try {
// Write the array to a file fos = new
FileOutputStream(outputDocument); bais2 = new
ByteArrayInputStream(content); doc.saveIncremental(bais2, fos);}
finally { IOUtils.closeQuietly(bais2);
IOUtils.closeQuietly(fos); }*
Any idea what these methods are for? Am I doing something wrong? If these
methods are not yet implemented but they are there for a planned feature I
could help coding...
Also, I don´t understand why I need to create 2 inputstreams, the first one
to load the PDDocument, and the second one to pass as a parameter to
saveIncremental.
Lots of questions, sorry! Thanks,
Rubén.