How can TCPDF be used to manipulate existing PDF files in PHP?
To manipulate existing PDF files in PHP using TCPDF, you can use the `TCPDF` class to open an existing PDF file, modify its content, and save the changes to a new PDF file. This can be achieved by loading the existing PDF file using `TCPDF::setSourceFile()` method, selecting the page to modify with `TCPDF::ImportPage()`, and then making any necessary changes to the content. Finally, save the modified PDF file using `TCPDF::Output()` method.
// Include the TCPDF library
require_once('tcpdf/tcpdf.php');
// Create new TCPDF object
$pdf = new TCPDF();
// Load existing PDF file
$pdf->setSourceFile('existing_file.pdf');
// Select the page to modify
$page = $pdf->ImportPage(1);
// Modify the content of the page
$pdf->useImportedPage($page);
// Save the modified PDF file
$pdf->Output('modified_file.pdf', 'F');