diff --git a/include/class/pdf.class.php b/include/class/pdf.class.php index 3cc88e39a..1af5bba6e 100644 --- a/include/class/pdf.class.php +++ b/include/class/pdf.class.php @@ -155,4 +155,36 @@ class PDF extends PDF_Core throw new Exception(_("Filter invalide ".$filter_operation), 5); } + /** + * @brief test the class + * @return void + */ + static function test_me() + { + $cn=Dossier::connect(); + $pdf=new PDF($cn); + $pdf->AddPage(); + $pdf->SetFont('DejaVu', '', 8); + for ($i=0;$i <10;$i++){ + $ln = $i*2+8; + $pdf->write_cell("50",$ln," heigh $ln ln $i",'1',$i); + $pdf->line_new(); + + } + + $pdf->AddPage(); + for ($i=0;$i <10;$i++){ + $ln = $i*2+8; + $pdf->LongLine("100",3," + Contrairement à une opinion répandue le Lorem Ipsum n'est pas simplement du texte aléatoire. Il trouve ses racines dans une oeuvre de la littérature latine classique datant de 45 av. J.-C., le rendant vieux de 2000 ans. Un professeur du Hampden-Sydney College, en Virginie, s'est intéressé à un des mots latins les plus obscurs, consectetur, extrait d'un passage du Lorem Ipsum, et en étudiant tous les usages de ce mot dans la littérature classique, découvrit la source incontestable du Lorem Ipsum. Il provient en fait des sections 1.10.32 et 1.10.33 du De Finibus Bonorum et Malorum (Des Suprêmes Biens et des Suprêmes Maux) de Cicéron. Cet ouvrage, très populaire pendant la Renaissance, est un traité sur la théorie de l'éthique. Les premières lignes du Lorem Ipsum, Lorem ipsum dolor sit amet.., proviennent de la section 1.10.32 heigh $ln ln $i",'1',$i); + + $pdf->write_cell("50",$ln," heigh $ln ln $i",'1',$i,align:'C'); + $pdf->line_new(); + + } + + + $pdf->Output('F','/tmp/a.pdf'); + } + } \ No newline at end of file diff --git a/include/lib/pdf_core.class.php b/include/lib/pdf_core.class.php index 97e6188d2..21a597bfa 100644 --- a/include/lib/pdf_core.class.php +++ b/include/lib/pdf_core.class.php @@ -40,10 +40,10 @@ class Cellule { var $fill; var $link; var $type; - function __construct($w,$h,$txt,$border,$ln,$align,$fill,$link,$type) + function __construct($width,$height,$txt,$border,$ln,$align,$fill,$link,$type) { - $this->width=$w ; - $this->height=$h ; + $this->width=$width ; + $this->height=$height ; $this->text=$txt; $this->border=$border; $this->new_line=$ln; @@ -227,25 +227,25 @@ class PDF_Core extends TFPDF { case "M": $x_m=$this->GetX(); - $y_m=$this->GetY(); - parent::MultiCell( + $y_m=$this->GetY(); + parent::MultiCell( $a->width, $a->height, $a->text, $a->border, $a->align, $a->fill - ); - $x_m=$x_m+$a->width; - $tmp=$this->GetY()-$y_m; - if ( $tmp > $this->bigger) $this->bigger=$tmp; - $this->SetXY($x_m,$y_m); + ); + $x_m=$x_m+$a->width; + $tmp=$this->GetY()-$y_m; + if ( $tmp > $this->bigger) $this->bigger=$tmp; + $this->SetXY($x_m,$y_m); break; case "C": - + $height=($this->bigger==0)?$a->height:$this->bigger; parent::Cell( $a->width, - $a->height, + $height, $a->text, $a->border, $a->new_line, @@ -266,14 +266,14 @@ class PDF_Core extends TFPDF $this->cells[$size]=$Ce; } - function write_cell ($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') + function write_cell ($width, $heigh=0, $txt='', $border=0, $ln=0, $align='', $fill=false, $link='') { - $this->add_cell(new Cellule($w,$h,$txt,$border,$ln,$align,$fill,$link,'C')); + $this->add_cell(new Cellule($width,$heigh,$txt,$border,$ln,$align,$fill,$link,'C')); } - function LongLine($w,$h,$txt,$border=0,$align='',$fill=false) + function LongLine($width,$heigh,$txt,$border=0,$align='',$fill=false) { - $this->add_cell(new Cellule($w,$h,$txt,$border,0,$align,$fill,'','M')); + $this->add_cell(new Cellule($width,$heigh,$txt,$border,0,$align,$fill,'','M')); } /** diff --git a/scenario/pdf.test.php b/scenario/pdf.test.php new file mode 100644 index 000000000..42683d0bc --- /dev/null +++ b/scenario/pdf.test.php @@ -0,0 +1,3 @@ +