1

I'm making an application in Python where I have to digitally sign some PDF files.

I managed to sign the files using this code: os.system('java -jar PortableSigner.jar -n -t /Users/pfp/Desktop/unsigned.pdf -o /Users/pfp/Desktop/signed.pdf -s /Users/pfp/Desktop/pfp.p12 -p MySecretPassword') (I learned this in this link)

The problem is that I need to put a little clickable JPG image in the top of the first page of the PDF files so the clients can click in it and see the signing properties of the PDF.

I tried to look for something but couldn't find anything really specific for my needs.

Can anyone point me in the right path?

undisp
  • 711
  • 3
  • 11
  • 34
  • PDF viewers should have options to display the signature; isn't that enough? – Aaron Digulla May 22 '15 at 10:18
  • No, the client wants to have a clickable button that when you click something like [this](http://s16.postimg.org/om5qwpyit/img.jpg) appears. – undisp May 22 '15 at 10:27

1 Answers1

1

If the files in question are already signed and you want to add such a button post-facto... this is not possible without invalidating the original signature.

If you need that button for new signatures yet to be created... According to the PortableSigner site you link to, such an active signature visualization can be added, by default it is positioned on an additional, new page.

The GUI is documented to allow putting it alternatively on the first or last existing page at a given position. I cannot find any documentation on the site indicating the same is possible on the command line, only the following parameters currently are documented there:

 -b <arg>              Append signature block [german|english|polish] as
                       parameter
 -c <arg>              Comment under signature block (text)
 -f                    If this is set, the document is NOT finalized
 -h                    Help (this page)
 -i <arg>              Image file for signature block
 -l <arg>              Contents of "Location" - field (text)
 -n                    Without GUI
 -o <arg>              Outputfile (PDF)
 -ownerpwd <arg>       Owner password
 -ownerpwdfile <arg>   Owner password file
 -p <arg>              Signaturepassword
 -pwdfile <arg>        Password file
 -r <arg>              Contents of "Reason" - field (text)
 -s <arg>              Signaturefile (P12 or PFX)
 -t <arg>              Inputfile (PDF)

But probably that part of the documentation is out of date. At first glance the source additionally seems to know a -e (embedding parameters: 3 floats separated by commas: vertical position, left margin, right margin) and a -z (first page) option.

So I assume adding the options

-z
-e 15,3,3
-i imagefile

will do the trick. (Maybe -b is required, too.)

PS: For an overview which changes to a signed PDF are allowed or disallowed, cf. this answer.

Community
  • 1
  • 1
mkl
  • 90,588
  • 15
  • 125
  • 265
  • Well, this deffenitely is the right path to follow, but here is still a problem: I used this command `os.system('java -jar PortableSigner.jar -b en -z -e 15,3,3 -i /home/username/image.jpg -n -t /Users/pfp/Desktop/unsigned.pdf -o /Users/pfp/Desktop/signed.pdf -s /Users/pfp/Desktop/pfp.p12 -p MySecretPassword')` and it signed the PDF with the button, but it ended up like [this](http://s14.postimg.org/n05max435/imagem.jpg) . Basically, the "content of the button" is written in the PDF even without me clicking on it. Do you know how can I solve this? Make it only appear onclick? – undisp May 22 '15 at 14:56
  • I don't know the PortableSigner tool beyond a short glance at it. You might need to tweak it a bit. As it is open source that shouldn't prove to be too difficult. – mkl May 22 '15 at 20:41
  • 1
    Ok, I'll try and if I can I'll post the answer here. Thanks again. – undisp May 23 '15 at 13:48