Sign a PDF document with JavaScript and PHP
This script allows your users to review and sign a PDF, such as a contract, invoice, bill, ...
First, it will display a pdf file from your server, whether it contains only one, or several pages.
Then, the script will automatically look for a string of text, such as "Signature" to identity where the signature should be placed on the document, and adds a "Sign the contract" button at this position, in addition to the button in the fixed navbar at the bottom of the screen.
When your user clicks one of these two buttons, a drawing pad is displayed and your user can either draw with their mouse, or their finger, if they see the document from a smartphone/tablet (yes, the whole script is responsive and mobile friendly!).
Alternatively, they can also write their name and select the font they want to use for their name. Adding more fonts and/or removing the included ones is easy and I explain how to do so.
The script validates different points and either returns an error if something happened, or if your user have tricked the code (ahhhhhh!!!), or will generate the signed PDF and redirect to a confirmation page, that offers a link to download a copy of the PDF.
When your user confirm their signature, a new PDF is generated PDF, their signature and a signing date is added, to the template, as well as an additional page at the end of the file, with some details about the contract and a history of the signing process, plus your logo at the bottom of this additional page. The idea being to help you to see a working example of how to do that, if you don't need this, of course, you will remove that part of the code.
The code is kept as simple as possible while being quite complete, the idea is for you to be able to customize it easily to fit your own needs and adjust it to your own branding etc.
Expect a clean code, with a html file, a little css file (bootstrap 5 is loaded, and does most of the styling/reponsive job), a javascript file, as well as a php file to generate the signed pdf file.
All the librairies used in the script are included using composer.
I'm already sure that you will quickly feel at ease to modify this code, and to save you even more time, I added a "Read me" file with some helpful tips to modify the code and do your thing.
Enjoy the time you saved, and have a good day! :-)
After buying this script, you will get a .zip file containing the code of the script, as well as a a "Read me" file containing useful tips on how to customize this script. Buying this script gives you a licence for one website, you need to buy an additional licence per website you build using it.