i am trying to get a hang of FPDI to combine PDFs. Been trying on the example codes given by setasign.
FPDF - fpdf.php is from fpdf.org, v1.81 Fpdi - i took the src from setasign, v2beta2
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
use \setasign\Fpdi;
// require_once('fpdf/fpdf.php');
// require_once('fpdi2/src/autoload.php');
require_once('fpdf181/fpdf.php');
require_once('fpdf181/fpdi/autoload.php');
// initiate FPDI
$pdf = new Fpdi\Fpdi();
// add a page
$pdf->AddPage();
// set the source file
$pdf->setSourceFile("projects/78/78_timesheet.pdf");
// import page 1
$tplIdx = $pdf->importPage(1);
// use the imported page and place it at point 10,10 with a width of 100 mm
$pdf->useImportedPage($tplIdx, 10, 10, 100);
// now write some text above the imported page
$pdf->SetFont('Helvetica');
$pdf->SetTextColor(255, 0, 0);
$pdf->SetXY(30, 30);
$pdf->Write(0, 'This is just a simple text');
// $pdf->Output();
$dir = "reports/";
$file = 'test.pdf';
$dir_file = $dir.$file;
$pdf->Output($dir_file,'F');
?>
The code does not create any PDF. When i change $pdf = new Fpdi\Fpdi(); to $pdf = new FPDF(); it shows an error: PHP Fatal error: Call to undefined method FPDF::setSourceFile() in testpdfgen.php on line 19
what am i doing wrong here?