Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to add a signature field in a pdf document using PHP? I haven't to "digital sign" document. I only add a signature field.

I have to generate a PDF document and add a "signature field".

A signature field is a field that allow to third party service to digitally sign document.

Is it possible to do this in PHP with an open source solution ?

I saw https://manuals.setasign.com/setapdf-signer-manual/create-a-signature-field/.

I try to use tcpdf but i have no success.

Thanks.

like image 501
Riccardo Franconi Avatar asked Sep 08 '25 11:09

Riccardo Franconi


1 Answers

As you already told that you have already gone through seta sign library documentation here

using setasign you can create a pdf document or use an existing one to create a digital signature field on it. Below is a code example:-

<?php
require_once('library/SetaPDF/Autoload.php');

// create a writer
$writer = new SetaPDF_Core_Writer_Http('visible-field.pdf', true);
// create a new document instance
$document = new SetaPDF_Core_Document($writer);
// create at least a single page
$document->getCatalog()->getPages()->create(SetaPDF_Core_PageFormats::A4);

// add a field left top with an offset of 10 points
SetaPDF_Signer_SignatureField::add(
        $document,
        'Signature field 1',
        1,
        SetaPDF_Signer_SignatureField::POSITION_LEFT_TOP,
        array('x' => 10, 'y' => -10),
        180,
        70
 );


 // add a field absolutely position on the bottom left with an offset of 10 points
 SetaPDF_Signer_SignatureField::add($document, 'Signature field 1', 1, 10, 10, 180, 70);

 // save and finish
 $document->save()->finish();

Note:- Use Adobe Acrobat Reader to open the generated document so you can see the digital signature field on pdf.

like image 94
Rohit Yadav Avatar answered Sep 11 '25 00:09

Rohit Yadav