Jump to content


Photo

FPDF help


  • Please log in to reply
1 reply to this topic

#1 smith.james0

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

Posted 19 July 2006 - 06:57 PM

I use the fpdf class to create  on the fly pdf's using a template. I am now trying to rotate some text on the page and have a template, but it's not working.

This this the code I use for the templates
error_reporting (E_ALL);

define('FPDF_FONTPATH','/home/*******/public_html/font/');
require('../pdf/fpdi.php');
require('../connection.php');

sql query etc....

$pdf= new fpdi();

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

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

		$pdf->Image('logo.png',90,8,33);
        $pdf->SetFont('Arial','',18);
        $pdf->SetTextColor(0);
		$pdf->SetXY(53,29);
        $pdf->write(10,"$store_name $store_num 3,2,1's Week $week");
		$pdf->SetXY(25,75);
        $pdf->write(10,"Name           Cat Number             Adjusted           Verified by");        

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

This works fine

I am using this code to rotate the text take from this page


<?php
require('fpdi.php');

class PDF_Rotate extends FPDF
{
var $angle=0;

function Rotate($angle,$x=-1,$y=-1)
{
    if($x==-1)
        $x=$this->x;
    if($y==-1)
        $y=$this->y;
    if($this->angle!=0)
        $this->_out('Q');
    $this->angle=$angle;
    if($angle!=0)
    {
        $angle*=M_PI/180;
        $c=cos($angle);
        $s=sin($angle);
        $cx=$x*$this->k;
        $cy=($this->h-$y)*$this->k;
        $this->_out(sprintf('q %.5f %.5f %.5f %.5f %.2f %.2f cm 1 0 0 1 %.2f %.2f cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy));
    }
}

function _endpage()
{
    if($this->angle!=0)
    {
        $this->angle=0;
        $this->_out('Q');
    }
    parent::_endpage();
}
}
?>







<?php
define('FPDF_FONTPATH','font/');
require('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 ok by it's self. When the two are added together it stops working

<?php
error_reporting (E_ALL);

define('FPDF_FONTPATH','/home/*******/public_html/font/');
require('../pdf/rotation.php');



class fpdi 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);
}
}

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

$pdf->addPage();
$pdf->useTemplate($tplidx,0,0);
$pdf->SetFont('Arial','',20);

$pdf->RotatedText(100,60,'Hello!',45);
$pdf->Output();
?>

This is the code i am trying to get to work, can anyone help as it's getting on my nerves!!!

Many thanks James

#2 smith.james0

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

Posted 20 July 2006 - 03:29 PM

Can anyone help?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users