Jump to content


Photo

Rotating text in pdf using php


  • Please log in to reply
1 reply to this topic

#1 smith.james0

smith.james0
  • Members
  • PipPipPip
  • Advanced Member
  • 122 posts

Posted 07 April 2006 - 09:04 AM

It the moment I use this code to to write the week number on top of a pdf template.

require('../pdf/fpdi.php');

$week = $_POST[week];


$pdf= new fpdi();

$pagecount = $pdf->setSourceFile("weelkytargets.pdf");
$tplidx = $pdf->ImportPage(1);

$pdf->addPage();
$pdf->useTemplate($tplidx,10,10);


        $pdf->SetFont('Arial','',18);
        $pdf->SetTextColor(0);
        $pdf->SetXY(142,33);
        $pdf->write(10,"$week");
        

$pdf->Output("newpdf.pdf","I");
$pdf->closeParsers();

This works ok when the document is portrate. I now have a document which is landscape, when using the code above it cuts of half of the page. So i need to either make the pdf i generate on the fly landscape or rotate the template and rotate the week number. I have tried to find how you make a landscape pdf but i haven't found anything. So i have tried rotating the text using this code.
require('../pdf/rotation.php');

class PDF extends PDF_Rotate
{
function RotatedText($x,$y,$txt,$angle)
{
    //Text rotated around its origin
    $this->Rotate($angle,$x,$y);
    $this->Text($x,$y,$txt);
    $this->Rotate(0);
}

function RotatedImage($file,$x,$y,$w,$h,$angle)
{
    //Image rotated around its upper-left corner
    $this->Rotate($angle,$x,$y);
    $this->Image($file,$x,$y,$w,$h);
    $this->Rotate(0);
}
}

$pdf=new PDF();
$pdf->AddPage();
$pdf->SetFont('Arial','',20);
$pdf->RotatedText(100,60,'Hello!',45);
$pdf->Output();
This works great but i carn't get it to work with the template, can anyone help?

Thanks James

#2 smith.james0

smith.james0
  • Members
  • PipPipPip
  • Advanced Member
  • 122 posts

Posted 08 April 2006 - 12:22 PM

Anyone?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users