You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Kacer-EXTERNAL Jaroslav <Ja...@gemalto.com> on 2013/08/15 09:50:51 UTC

Visible signature using PDF Box - Content of SignatureOptions.visualSignature

Dear colleagues,

I'm trying to create a visual signature in a PDF document using PDF Box like this:

PDDocument.addSignature(signature, signItfc, signatureOptions);

Unfortunately I'm not sure what the content of signatureOptions.visualSignature should be. I went through this mailing list, the PDF Box Examples project, StackOverflow and I googled a lot but unfortunately I was not able to find any piece of example code or documentation on this. The only mention is in a post in from 2011-11-03, saying one should be able to use iText to generate it.

I also tried to generate the content using createPDocumentSignature() from the 2011-11-03 post but no luck, I'm getting ClassCastException (although the structure built up in createPDocumentSignature looks like what PDF Box wants, at the first sight).

Is there anyone who has succeeded generating the right content of the input stream? Not necessarily using iText, in fact we are trying to replace iText with PDF Box.

Any help, example or hint would be much appreciated.
Are there any plans to update the SignatureOptions class to accept a structured Java object instead of an InputStream? That would make things a lot easier.

Thank you very much!
 Jarda


IIII Jaroslav Kacer
ICS R&D Software Engineer
Mail: jaroslav.kacer-external@gemalto.com
Phone: +420 241 051 721
Mobile: +420 723 914 123
Zeletavska 7/1448 
Praha 4, 140 00, Czech Republic
www.gemalto.com or www.justaskgemalto.com




Re: Visible signature using PDF Box - Content of SignatureOptions.visualSignature

Posted by Thomas Chojecki <in...@rayman2200.de>.
Zitat von Kacer-EXTERNAL Jaroslav <Ja...@gemalto.com>:

> Dear colleagues,
Hi,

>
> I'm trying to create a visual signature in a PDF document using PDF  
> Box like this:
>
> PDDocument.addSignature(signature, signItfc, signatureOptions);
>
> Unfortunately I'm not sure what the content of  
> signatureOptions.visualSignature should be. I went through this  
> mailing list, the PDF Box Examples project, StackOverflow and I  
> googled a lot but unfortunately I was not able to find any piece of  
> example code or documentation on this. The only mention is in a post  
> in from 2011-11-03, saying one should be able to use iText to  
> generate it.

The visualSignature object / inputStream need to contain (I guess) an  
AppearanceDictionary with a visual representation. The problem is,  
that the needed helper for creating a table with text, image or both  
contents were missing in the pdfbox. So I used a fallback to iText and  
created the visual representation there and give pdfbox the file as  
inputstream.

So this undocumented feature was a hook and not a real solution for  
creating visual signatures. I've read that someone implemented helper  
for adding tables or some other elements to a page. Maybe this can be  
used for creating a visual representation, but I haven't evaluate this  
yet.

>
> I also tried to generate the content using  
> createPDocumentSignature() from the 2011-11-03 post but no luck, I'm  
> getting ClassCastException (although the structure built up in  
> createPDocumentSignature looks like what PDF Box wants, at the first  
> sight).
>

There should be a jar with runnable examples on the svn. Maybe you  
could look there for a signature creation example.

> Is there anyone who has succeeded generating the right content of  
> the input stream? Not necessarily using iText, in fact we are trying  
> to replace iText with PDF Box.
>

Good question, maybe someone can provide such implementation. So we  
can update and build a user friendly interface for this purpose.

> ...
> Are there any plans to update the SignatureOptions class to accept a  
> structured Java object instead of an InputStream? That would make  
> things a lot easier.
>
As far as there is a suitable solution. Maybe a first step would be to  
use something like PDAppearanceDictionary. But I haven't spend this  
year much time with the implementation, so I forgot how I solved the  
visualisation of the signature.

> Thank you very much!
>  Jarda

Best regards
Thomas