smith.james0 Posted July 19, 2006 Share Posted July 19, 2006 I use the [url=http://www.fpdf.org/]fpdf[/url] 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[code]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();[/code]This works fineI am using this code to rotate the text take from this [url=http://www.fpdf.org/en/script/script2.php]page[/url][code]<?phprequire('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();}}?><?phpdefine('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();?>[/code]This works ok by it's self. When the two are added together it stops working[code]<?phperror_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();?>[/code]This is the code i am trying to get to work, can anyone help as it's getting on my nerves!!!Many thanks James Link to comment https://forums.phpfreaks.com/topic/15068-fpdf-help/ Share on other sites More sharing options...
smith.james0 Posted July 20, 2006 Author Share Posted July 20, 2006 Can anyone help? Link to comment https://forums.phpfreaks.com/topic/15068-fpdf-help/#findComment-61058 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.