Can FPDF/FPDI use a PDF in landscape format as a template?
Asked Answered
K

2

15

I am trying to import an existing PDF as a template with FPDI. The template is in landscape format. If I import the template into a new document the template page is inserted in portrait form with the content rotated 90 degrees. If my new document is in portrait the full content appears, but if the new document is also landscape, the content is cropped.

Is it possible to use a landscape template with FPDI?

Kuntz answered 18/11, 2008 at 5:9 Comment(0)
A
30

sure, it is no problem. Just add "L" as parameter when calling "addPage()". Here is a sample which works fine for me (the template is in landscape)

<?php
require_once('fpdf.php');
require_once('fpdi.php');

$pdf =& new FPDI();
$pdf->addPage('L');
$pagecount = $pdf->setSourceFile('template.pdf');
$tplIdx = $pdf->importPage(1); 
$pdf->useTemplate($tplIdx); 
$pdf->SetFont('Arial'); 
$pdf->SetTextColor(255,0,0); 
$pdf->SetXY(25, 25); 
$pdf->Write(0, "This is just a test"); 
$pdf->Output('newpdf.pdf', 'F');

?>
Ataman answered 18/11, 2008 at 23:39 Comment(1)
how to print layout of pdf file in output. now it is printing like this: "0 0 0 rg BT /F1 15 Tf 1 0 0 1 231.49 739.13 (Yesterday Task Report)Tj ET 0 0 1 rg BT /F2 12 Tf 1 0 0 1 37.13 707.29 ". but this is the form of table.Hygienics
K
0

Finally got to look at this problem again... Although crono's answer is perfectly valid. It seems this only works with more recent versions of the FPDI tools. Upgrading from v1.1 to v1.3 solves the problem.

Kuntz answered 30/7, 2009 at 2:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.