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

1

5

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 ?

Vharat answered 21/12, 2015 at 16:39 Comment(2)
Have you tried $pdf = new FPDI("L", "mm", array(85.6,54));? I've never used FPDI before, so not sure if that would make a difference compared to FPDF.Mcmahan
Well, haven't tried that, i'll do it at work on tomorrow, I'll let you know if it works or not. Thank's mate :)Vharat
V
7

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);  
Vharat answered 22/12, 2015 at 8:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.