How to sign pdf created with FPDF instead of TCPDF
<?php
require_once('fpdf.php');
// crie uma instância do FPDF
$pdf = new fpdf();
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 14);
// escreva algum conteúdo
$text = 'This document is created with FPDF on '
. date('r')
. ' and digital signed with the SetaPDF-Signer component.';
$pdf->MultiCell(0, 8, $text);
// Configura a saída do documento para ser string
$fpdf = $pdf->Output('', 'S');
require_once('library/SetaPDF/Autoload.php');
// or if you use composer require_once('vendor/autoload.php');
// crie um Http writer
$writer = new SetaPDF_Core_Writer_Http('fpdf-sign-demo.pdf', true);
// carregue o documento pelo seu caminho
$document = SetaPDF_Core_Document::loadByString($fpdf, $writer);
// crie uma instância da assinatura para o documento
$signer = new SetaPDF_Signer($document);
// configure algumas propriedades da assinatura
$signer->setReason('Demo with FPDF');
$signer->setLocation('setasign.com');
// crie uma instância OpenSSL
$module = new SetaPDF_Signer_Signature_Module_OpenSsl();
// configure o certificado de assinatura
$module->setCertificate(file_get_contents('certificate.pem'));
// configura a chave privada para o certificado de assinatura
$module->setPrivateKey(array(file_get_contents('private-key.pem'), 'password'));
// assine o documento
$signer->sign($module);
Source
Did you get Junior? I’m looking for this too with the A1 certificate.
– user37041
I don’t know if this will help but I found that answer in the English OS
– Leandro RR
I’ve performed this procedure using Java with the iText Library and it worked perfectly. If it fits you can take a look at iText in Action that has examples.
– Jeremias Santos
Try using http://portablesigner.sourceforge.net/. It’s a java app that you can call from the command line by passing the parameters. We use it to sign the Pdfs.
– cantoni
There is no more elaborate answer @Cantoni?
– gustavox
Waiting here until the last minute :) Missing 5. :)
– gustavox
@gustavox, I can elaborate an answer, but for this I need to see again how we did it, has long this. At the moment, I lack time. :-)
– cantoni
OK @Cantoni, when you get there, and if the community approves (+2 at least) the reward will come in double (pq has to be at least 200 now rsrs, but no problem, I have quite an interest in this subject, and I think it will greatly enrich the community - see positive votes in the question...). Hugs!
– gustavox