Nov 15, 2023
0
Level 1
Digitally Sign a PDF Document using TCPDF/FPDI with explicit Date of Signing
Hello, I have an API controller that accepts a pdf document and sign it using TCPDF/FPDI and the send back the digitally signed PDF.
Here is my code: use setasign\Fpdi\Tcpdf\Fpdi;
$uploadedPdf = $request->file('pdfDoc');
$pdf = new Fpdi();
$pdfFilePath = $uploadedPdf->getPathname();
$pageCount = $pdf->setSourceFile($pdfFilePath);
for ($pageNo = 1; $pageNo <= $pageCount; $pageNo++) {
$templateId = $pdf->importPage($pageNo);
$pdf->AddPage();
$pdf->useTemplate($templateId);
}
$info = array(
'Name' => '',
'Location' => 'Office',
'Reason' => 'Aproval',
'ContactInfo' => ''
);
$certificate = 'file://' . str_replace('\', '/', storage_path('app/tempsig/77834.crt'));
$key='file://' . str_replace('\', '/', storage_path('app/tempsig/77834.key'));
$pdf->setSignature($certificate, $key, 'Pass1257141563', '', 2, $info);
$pdfContent = $pdf->Output('', 'S');
return response($pdfContent)
->header('Content-Type', 'application/pdf')
->header('Content-Disposition', 'attachment; filename="new_pdf.pdf"');
This code is working fine. However, when the file is returned, the Date of Signing that shows in the PDF is the current date. Is there anyway to change the Date of Signing instead of the current date? I'm using Adobe Reader to verify the Signature and the Date of Signing. Is it even Possible?
Thank you and Godbless
Please or to participate in this conversation.