John Davidson

php - TCPDF 1st page Missing on Import Page

0 comments
Message:


When I try to import a pdf from an existing pdf it removes the first page and starts from the second. where am I going wrong


 $pdf = new TcpdfFpdi('P', 'mm', 'A4', true, 'UTF-8', false, true);

$pdf->SetCreator('TCPDF Name');
$pdf->SetAuthor('TCPDF Author');
$pdf->SetTitle('TCPDF title');
$pdf->SetSubject('TCPDF Tutorial');
$pdf->SetKeywords('KEYWORDS');


$pagecount = $pdf->setSourceFile('/** file path**/');

for ($i=1; $i<=$pagecount; $i++) {

$tplId = $pdf->importPage($i);
$pdf->useTemplate($tplId,0,0,'210','297');

if ($i < $pagecount)
$pdf->AddPage('P','A4');
}

$pdf->Output(public_path('filename'.pdf'), 'F');


My Answer:
>setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->AddPage();
$pdf->setSourceFile('existing.pdf');
$tplIdx = $pdf->importPage(1);
$pdf->useTemplate($tplIdx, 0, 0, 210);
$pdf->Output('new.pdf', 'I');

Rate this post

5 of 5 based on 6047 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us