im using TCPDF and FPDI to import existing pdf file and write text on it.
i want to resize the pdf file to A4 properties W:595.2 H:8870.89
the reason i want to change the size, is because i want to place text with position that matches the page's pixels.
here is my code (Taken from here: TCPDF and FPDI with multiple pages)
// Original file with multiple pages
$fullPathToFile = '../documents/test5.pdf';
class PDF extends Fpdi\Tcpdf\Fpdi {
var $_tplIdx;
function Header() {
global $fullPathToFile;
if (is_null($this->_tplIdx)) {
// THIS IS WHERE YOU GET THE NUMBER OF PAGES
$this->numPages = $this->setSourceFile($fullPathToFile);
$this->_tplIdx = $this->importPage(1);
}
$this->useTemplate($this->_tplIdx);
}
function Footer() {}
}
// initiate PDF
$pdf = new PDF('P','pt');
$pdf->setFontSubsetting(true);
// set some language dependent data:
$lg = Array();
$lg['a_meta_charset'] = 'UTF-8';
$lg['a_meta_dir'] = 'rtl';
$lg['a_meta_language'] = 'he';
$lg['w_page'] = 'page';
// set some language-dependent strings (optional)
$pdf->setLanguageArray($lg);
// ---------------------------------------------------------
// set font
$pdf->SetFont('dejavusans', '', 12);
// add a page
$pdf->AddPage();
$htmlpersian = 'hello world';
$pdf->SetXY(40, 255);
$pdf->WriteHTML($htmlpersian, true, 0, true, 0);
// THIS PUTS THE REMAINDER OF THE PAGES IN
if($pdf->numPages>1) {
for($i=2;$i<=$pdf->numPages;$i++) {
$pdf->endPage();
$pdf->_tplIdx = $pdf->importPage($i);
$pdf->AddPage();
}
}
// Output the file as forced download
$pdf->Output('theNewFile.pdf', 'I');
thanks for the helpers