jeidison/jsignpdf-php

jsignpdf-php

v1.2.5 2024-04-24 17:19 UTC

README

This package is only wrapper of JSignPdf to use in PHP

Installation:

$ composer require jeidison/jsignpdf-php

Examples

use Jeidison\JSignPDF\JSignPDF;
use Jeidison\JSignPDF\Sign\JSignParam;

$param = JSignParam::instance();
$param->setCertificate(file_get_contents('/path/to/file/certificate.pfx'));
$param->setPdf(file_get_contents('/path/to/file/pdf_to_sign.pdf'));
$param->setPassword('certificate_password');

$jSignPdf   = new JSignPDF($param);
$fileSigned = $jSignPdf->sign();
file_put_contents('/path/to/file/file_signed.pdf', $fileSigned);

With Java Installed:

$param->setIsUseJavaInstalled(true);

With standalone Java:

$param->setJavaPath('/path/to/bin/java');

With JSignPDF bin:

$param->setjSignPdfJarPath('/path/to/jsignpdf');

Without JSignPDF bin:

composer require jsignpdf/jsignpdf-bin

File signed as base64:

$param->setIsOutputTypeBase64(true);

Change temp directory:

$param->setTempPath('/path/temp/to/sign/files/');

Change parameters of JSignPDF:

$param->setJSignParameters("-a -kst PKCS12 -ts https://freetsa.org/tsr");

Credits