How can I set the size of a PDF page with FPDI

I'm stuck at work. I'm coding in PHP and I have to generate a PDF. My problem is that I have to create cards (same size of credit card 85.6*54mm), I'm using a template at the right size, but the page is still generated with A4 format. I can see my template on that page at the top left corner but the A4 page is filling the rest of my screen. Here is my code.

$pdf = new FPDI();
$pdf->setSourceFile('inc/om.pdf');  
$tplIdx = $pdf->importPage(2); 
$pdf->AddPage('L', array(85.6,54));   
$pdf->useTemplate($tplIdx); 

Does someone have a idea ?

Upvotes: 5

Views: 9306

Answers (1)

I slightly modified the code that miken32 sent me, now it's working pretty well ! Thank you mate, that was the right way to do it.

$pdf = new FPDI('L','mm', array(54,85.6));
$pdf->setSourceFile('inc/om.pdf');  
$tplIdx = $pdf->importPage(2); 
$pdf->AddPage();   
$pdf->useTemplate($tplIdx);  

Upvotes: 7

Related Questions