Is it possible to generate PDF file in PHP with digital signature? An open-source solution is preferred.
There's something called SetaPDF-Signer. It's not free though :S
The SetaPDF-Signer API allows PHP developers to digital sign PDF documents in pure PHP.
The VersyPDF PHP library (Commercial) will also sign documents
It is also possible to use the open source iText java library and a PHP-Java bridge to allow communication. See the iText FAQ on this
iText can sign documents by self signing, veriSign plug-in or windows Certificate Security. When I've used it in the past on Java projects, signing documents is just coping examples and usually takes under a hundred lines. The hardest bit is getting the right certificates to sign it with.
It'd suggest you to try DOM PDF which is for PHP5, it's really easy to use, well documented and open-source
TCPDF starting from version 5.5.001 (released 2010-06-23) can sign generated PDF documents.
It can also place transparent signature rectangle field over any bitmap/text, so clicking on the signature field brings up signature panel - cool feature. That same does seta-PDF signer, however you have to pay:-)
If TCPDF extended with FPDI bridge, it can also parse already existing documents with PDF version up to 1.7 and sign it with X.509 certificate. It can 100% parse PDF documents generated by itself or pdf document craeted by any other PHP PDF tool (e.g. FPDF, DOM PDF, mPDF, ..), calculate PDF signature and write back the same signed PDF document.
If, however, you want to parse PDF document created by other (e.g. binary) PDF generator (iText, ..), it may not be able to parse the document. You may try another PDF parser (I only know Zend Framework PDF Parser worth of trying), however it may not read and decompile whole structure of PDF document since PHP has limited implementation of PDF definitions (PHP is primary textual scripting language, cannot handle binary stuff easily, so this is the root of the limitation).
So if you are thinking about generating PDF on your web site, use the same tool for creating PDF document and signing - best I can recommend here is TCPDF. Look for it over google, if you haven't heard of it yet (:-o)
At the time being, I dont think DOM PDF can sign PDF documents.
VersyPDF is .dll/.so PHP extension and is VERY BADLY supported, is expensive, and really POORLY documented. You may experience silent crashes without error messages... It also does not support 256-bit AES certificates, which are now standard. And you have to get different recompiled version if you are running on 32bit machines as developer and 64bit machines in production. We replaced VersyPDF with TCPDF. Performace penalty is hardly notable, we are able to generate dynamically 300 - 600 kB PDF signed documents. It's a pity, coz otherwise VersyPDF has somewhat nice API if you play with it and good performance. It's a one-man show I guess from my experience...
Cheers Lubos