Blog Detail


Sign Docs & Generate Certified PDFs with Laravel Sign Pad cover image

Sign Docs & Generate Certified PDFs with Laravel Sign Pad

Laravel pad signature is an awesome Laravel package that helps you to sign documents and optionally generate certified PDFs associated with an Eloquent model. Laravel pad signature requires PHP 8.0 or 8.1 and Laravel 8 or 9.


You can install the package via composer:

composer require creagia/laravel-sign-pad

Publish the config and the migration files and migrate the database

php artisan sign-pad:install

Publish the .js assets:

php artisan vendor:publish --tag=sign-pad-assets

This will copy the package assets inside the public/vendor/sign-pad/ folder.


At this point, all you need is to create the form with the sign pad canvas in your template. For the route of the form, you have to call the method getSignatureUrl() from the instance of the model you prepared before:

@if (!$myModel->hasBeenSigned())
    <form action="{{ $myModel->getSignatureRoute() }}" method="POST">
        <div style="text-align: center">
            <x-creagia-signature-pad />
    <script src="{{ asset('vendor/sign-pad/sign-pad.min.js') }}"></script>

Retrieving signatures

You can retrieve your model signature using the Eloquent relation $myModel->signature. After that, you can use

  • getSignatureImagePath() method in the relation to get the signature image.
  • getSignedDocumentPath() method in the relation to get the generated PDF document.
echo $myModel->signature->getSignatureImagePath();
echo $myModel->signature->getSignedDocumentPath();

Customizing the component

From the same template, you can change the look of the component by passing some properties:

  • border-color (hex) to change the border color of the canvas
  • pad-classes and button-classes (strings) indicate which classes will have the sign area or the submit & clear buttons
  • clear-name and submit-name (strings) allow you to modify de default "Submit" and "Clear" values of the buttons.

Certifying the PDFs

To certify your signature with TCPDF, you will have to create your own SSL certificate with OpenSSL. Otherwise, you can find the TCPDF demo certificate here: TCPDF Demo Certificate

To create your own certificate use this command:

cd storage/app
openssl req -x509 -nodes -days 365000 -newkey rsa:1024 -keyout certificate.crt -out certificate.crt

After generating the certificate, you'll have to change the value of the variable certify_documents in the config/sign-pad.php file and set it to true.

When the variable certify_documents is set to true, the package will search the file allocated in the certificate_file path to sign the documents. Feel free to modify the location or the name of the certificate file by changing its value.

Inside the same config/sign-pad.php we encourage you to fill all the fields of the array certificate_info to be more specific with the certificate.

Finally, you can change the certificate type by modifying the value of the variable cert_type (by default 2). You can find more information about certificate types at TCPDF setSignature reference.

For more details, Please visit Github.

Published at : 12-10-2022

Author : Rizwan Aslam
Rizwan Aslam

I am a highly results-driven professional with 12+ years of collective experience in the grounds of web application development especially in laravel, native android application development in java, and desktop application development in the dot net framework. Now managing a team of expert developers at Codebrisk.

Launch project