How to set PDF page size using FPDI

I'm stuck at work. I am coding in PHP and I need to create a PDF file. My problem is that I have to create cards (credit card size 85.6 * 54 mm), I use the template in the right size, but the page is still created using A4 format. I see my template on this page in the upper left corner, but page A4 fills 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 anyone have any ideas?

+4
source share
1 answer

I slightly modified the code that miken32 sent me, now it works very well! Thanks, mate, that was the right way to do this.

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

Source: https://habr.com/ru/post/1621141/


All Articles