PDF: add tests
This commit is contained in:
parent
1b71b30b30
commit
53f708b46f
3 changed files with 51 additions and 16 deletions
|
|
@ -155,4 +155,36 @@ class PDF extends PDF_Core
|
||||||
throw new Exception(_("Filter invalide ".$filter_operation), 5);
|
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');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -40,10 +40,10 @@ class Cellule {
|
||||||
var $fill;
|
var $fill;
|
||||||
var $link;
|
var $link;
|
||||||
var $type;
|
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->width=$width ;
|
||||||
$this->height=$h ;
|
$this->height=$height ;
|
||||||
$this->text=$txt;
|
$this->text=$txt;
|
||||||
$this->border=$border;
|
$this->border=$border;
|
||||||
$this->new_line=$ln;
|
$this->new_line=$ln;
|
||||||
|
|
@ -243,9 +243,9 @@ class PDF_Core extends TFPDF
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "C":
|
case "C":
|
||||||
|
$height=($this->bigger==0)?$a->height:$this->bigger;
|
||||||
parent::Cell( $a->width,
|
parent::Cell( $a->width,
|
||||||
$a->height,
|
$height,
|
||||||
$a->text,
|
$a->text,
|
||||||
$a->border,
|
$a->border,
|
||||||
$a->new_line,
|
$a->new_line,
|
||||||
|
|
@ -266,14 +266,14 @@ class PDF_Core extends TFPDF
|
||||||
$this->cells[$size]=$Ce;
|
$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'));
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
3
scenario/pdf.test.php
Normal file
3
scenario/pdf.test.php
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
//@description: test PDF interline
|
||||||
|
PDF::test_me();
|
||||||
Loading…
Add table
Add a link
Reference in a new issue