Я пытаюсь сгенерировать и подписать pdf с использованием библиотеки TCPDF на PHP. PDF также создается и подписывается, но видимая подпись в любом случае не отображается.
При открытии PDF в Adobe Viewer появляется панель подписи, которая сообщает, что подпись действительна, но видимая подпись не отображается.
Мне нужны свойства подписи по умолчанию в видимой области подписи, такие как желтый знак вопроса или зеленая галочка.
Я использую коммерческую подпись.
Я застрял с этим в течение последних 7 дней.
public function tcpdf_coo_generation($html,$filename)
{
require_once("tcpdf/tcpdf.php");
// create new PDF document
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
// set document information
$pdf->SetCreator('EEPC India');
$pdf->SetAuthor('EEPC India COO System');
$pdf->SetTitle('Certificate of Origin - Non Preferential');
$pdf->SetSubject('COO');
$pdf->SetKeywords('COO, PDF, EEPC India, Online COO, Engineering Export Promotion');
// set default header data
$pdf->SetHeaderData('', 0, '', '');
$pdf->SetPrintHeader(false);
$pdf->SetPrintFooter(false);
// set header and footer fonts
$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
// set default monospaced font
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
// set margins
$pdf->SetMargins(PDF_MARGIN_LEFT, 10, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
// set auto page breaks
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
// set image scale factor
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
// set some language-dependent strings (optional)
if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
require_once(dirname(__FILE__).'/lang/eng.php');
$pdf->setLanguageArray($l);
}
// set certificate file
//$certificate = 'file://'.$_SERVER['DOCUMENT_ROOT'].'/eepc-rcmc-portal/tcpdf/examples/data/cert/tcpdf.crt';
//$certificate = "file://".$_SERVER['DOCUMENT_ROOT']."/eepc-coo-portal/certs/eepc_cert.pem";
//$privateKey = "file://".$_SERVER['DOCUMENT_ROOT']."/eepc-coo-portal/certs/eepc_key.pem";
$certificate = "file://".$_SERVER['DOCUMENT_ROOT']."/eepc-coo-portal/certs/test-certificates/certificates/alice.crt";
$privateKey = "file://".$_SERVER['DOCUMENT_ROOT']."/eepc-coo-portal/certs/test-certificates/certificates/alice.key";
// set additional information
$info = array(
'Name' => 'EEPC India',
'Location' => 'Office',
'Reason' => 'COO',
'ContactInfo' => 'https://www.eepcindia.org',
);
// set document signature
$pdf->setSignature($certificate, $privateKey, '', '', 2, $info, 'A');
//$pdf->setSignature($certificate, $privateKey, 'tcpdfdemo', '', 2, $info, 'A');
// set font
$pdf->SetFont('helvetica', '', 12);
// add a page
$pdf->AddPage();
// print a line of text
$text = $html;
$pdf->writeHTML($text, true, 0, true, 0);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// *** set signature appearance ***
// create content for signature (image and/or text)
//$pdf->Image('images/signedby-eepcindia-logo.png', 160, 240, 30, 30, 'PNG');
// define active area for signature appearance
$pdf->setSignatureAppearance(160, 240, 30, 30);
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// *** set an empty signature appearance ***
//$pdf->addEmptySignatureAppearance(180, 250, 15, 15);
// ---------------------------------------------------------
//Close and output PDF document
$pdf->Output($_SERVER['DOCUMENT_ROOT'].'/eepc-coo-portal/uploads/coo_pdfs/'.$filename, 'F');
return true;
}