To add a timestamp to a PDF signature using PHP, you can use the TCPDF library, a popular PHP library for creating and modifying PDF documents. Below are the steps to add a timestamp to an existing PDF signature:

  1. Install TCPDF: First, you need to install the TCPDF library. You can download it from the official website ( or install it using Composer:

    composer require tecnickcom/tcpdf
  2. Load and Modify the PDF: Assuming you have an existing PDF with a signature field, you can use the TCPDF library to add a timestamp to the signature field. The following PHP code demonstrates how to achieve this:

    require_once('vendor/autoload.php'); // If using Composer to load TCPDF // Path to the existing PDF file with the signature field $inputPdf = 'path/to/existing_pdf_with_signature.pdf'; // Path to the output PDF file with the timestamp added to the signature $outputPdf = 'path/to/output_pdf_with_timestamp.pdf'; // Load the PDF using TCPDF $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); // Set the creator and title of the PDF $pdf->SetCreator(PDF_CREATOR); $pdf->SetTitle('PDF with Timestamp'); // Add a new page to the PDF $pdf->AddPage(); // Set the font and font size for the timestamp $pdf->SetFont('times', 'I', 10); // Set the position to add the timestamp $x = 100; $y = 100; // Get the current date and time in your desired format $timestamp = date('Y-m-d H:i:s'); // Add the timestamp to the PDF $pdf->Text($x, $y, $timestamp); // Output the modified PDF to the specified file $pdf->Output($outputPdf, 'F');
  3. Run the PHP Script: Save the above PHP code in a PHP file (e.g., add_timestamp.php) and run it from the command line or through a web server.

This code will load the existing PDF, add a timestamp using TCPDF's Text() method, and then save the modified PDF to a new file with the timestamp added. The timestamp will be placed at the specified X and Y coordinates ($x and $y).

Make sure you have appropriate permissions to read the existing PDF and write the new PDF with the timestamp. Additionally, customize the font, font size, and position according to your requirements.

Note that TCPDF offers various other methods for adding text, images, and other elements to the PDF, so you can further customize the appearance of the timestamp based on your needs.

Have questions or queries?
Get in Touch