I need to sign an existing pdf.
I'm using Symfony 3.4.12 and the bundle https://packagist.org/packages/whiteoctober/tcpdf-bundle to sign pdf's.
Inside the services I added this part:
AppBundle\Controller\AController:
class: AppBundle\Controller\AController
arguments: ['@white_october.tcpdf']
Inside the Controller I'm using this;
use WhiteOctober\TCPDFBundle\Controller\TCPDFController;
And with this code I can download a created pdf signed correctly:
private $tcpdf;
public function __construct(TCPDFController $tcpdf)
{
$this->tcpdf = $tcpdf;
}
public function aAction ()
{
$pdf = $this->tcpdf->create(
'LANDSCAPE',
PDF_UNIT,
PDF_PAGE_FORMAT,
true,
'UTF-8',
false
);
$pdf->SetAuthor('qweqwe');
$pdf->SetTitle('Prueba TCPDF');
$pdf->SetSubject('Your client');
$pdf->SetKeywords('TCPDF, PDF, example, test, guide');
$pdf->setFontSubsetting(true);
// set additional information
$info = array(
'Name' => 'xxx',
'Location' => 'xxx',
'Reason' => 'xxx xxxx',
'ContactInfo' => 'http://www.xxx.xx',
);
// set document signature
$pdf->setSignature('file:///var/www/html/publicCert.pem', 'file:///var/www/html/privateKey_cert.pem', 'xxxx', '', 2, $info, 'A');
$pdf->SetFont('helvetica', '', 11, '', true);
$pdf->AddPage();
$html = '<h1>Working on Symfony</h1>';
$pdf->writeHTMLCell(
$w = 0,
$h = 0,
$x = '',
$y = '',
$html,
$border = 0,
$ln = 1,
$fill = 0,
$reseth = true,
$align = '',
$autopadding = true
);
$pdf->Output("example.pdf", 'I');
}
My objective is try to sign an existing pdf, so I tried to use FPDI to import it but I get confused because I know I can import a pdf with PDFI but I can't sign it and the opposite with the TCPDF, I can't import the pdf but I can sign a created one. And apparently I can't use functions from one to the other.
So, how I should fix this problem? Any idea? Could you show me an example?