Open garethellis36 opened 3 years ago
Try something this:
composer.json
"iio/libmergepdf": "^4.0",
"tecnickcom/tcpdf": "6.3.*",
"setasign/fpdi": "^2.0"
Using Fpdi to sign a pdf
use setasign\Fpdi\Tcpdf\Fpdi;
...
$pdf = new Fpdi('P', 'mm', 'A4');
$pages = $pdf->setSourceFile('file.pdf');
$certificate = file_get_contents('certificate.crt');
for ($i = 1; $i <= $pages; $i++) {
$pdf->AddPage();
$page = $pdf->importPage($i);
$pdf->useTemplate($page, 0, 0);
$pdf->setSignature($certificate, $certificate, 'tcpdfdemo', '', 2, array());
}
$pdf->Output($path, 'F');
Using libmergepdf to merge two pdfs
use iio\libmergepdf\Merger;
use iio\libmergepdf\Driver\TcpdiDriver;
...
$merger = new Merger(new TcpdiDriver);
$merger->addFile('file1.pdf');
$merger->addFile('file2.pdf');
$mergedPdf = $merger->merge();
return $mergedPdf;
I want to use the commercial FPDI PDF parser from setasign. In order to do this, I have to use
Fpdi2Driver
and pass in an instance ofFpdi
fromsetasign/fpdi
:Fpdi
extendsFpdfTpl
(both fromsetasign/fpdi
)FpdfTpl
extends\FPDF
This library provides an alias of\FPDF
which extends fromTCPDF
(tecnickcom/tcpdf
).Fpdi
andTCPDF
have incompatible method signatures on these methods:Probably others, I lost interest in manually fixing them just to get a different error message.
This generates a warning in PHP 7.4 and fatal errors in PHP 8.