1

I am new to htmlpdf2 and am curious if there is a way to rotate text. ie display the barcode top to bottom instead of left to right?

Thank you.

2

it's not possible, sorry (for barcode, but also for images and textes)
Ancien pseudo : lolo

3

hello Spidu,

First i like to thank you for creating and mantaining this nice librery. I'm one of the main developers of Fusion Ticket. This is a very easy to use webshop for selling tickets for events etc.
For the next version i desided to switch to your librery to create the PDF files inside Fusion Ticket. It is very simple to use and fast, together with Smarty you can do most likely do everyting you want.

For the tickets we want also the posiblity to have some rotated text/barcodes. After reading your replay to Lou555, i have been looking at the script at fpdf and found this script:
http://www.fpdf.org/en/script/script31.php.

This class extends the fpdf class with some extra methods that allows the user to rotate the text. Now my question is how can we implement this into htm2pdf?

thanks

Niels v/d Spek
Developer of Fusion Ticket. I ticket sale webshop using Html2pdf to generate the pdf files

4

it is not easy to add this feature... because lot of things must be modified ! the bigger pb is with div and table size...

i will maybe adding this feature, but not yet... sorry !
Ancien pseudo : lolo

5

I think it is posible to put rotate text because i used it in one site. I was trying rotate only simple text, maybe it will be work fine with barcodes.
I'm don't writing about this script:
http://www.fpdf.org/en/script/script31.php
but about this one:
http://www.fpdf.org/en/script/script32.php
If you are interested in this one I can explain how it work.
Always something new.

6

Vertical text in this solution work for CSS like (class in HTML):

.verticaltext {
writing-mode: tb-rl;
filter: flipv fliph;
}


This CSS work only in IE but for pdf it will be work.

In file: styleHTML.class.php
after:

case 'list-style-image':
if ($nom=='list-style') $nom = 'list-style-type';
$this->value[$nom] = $val;
break;

add lines:

case 'writing-mode':
if ($val=='tb-rl') $this->value['writing-mode'] = 'tb-rl' ;
else $this->value['writing-mode'] = null;
break;
case 'filter':
if ($val=='flipv fliph') $this->value['filter'] = 'flipv fliph' ;
else $this->value['filter'] = null;
break;


To file: mypdf.class.php we should add function VCell from script:
http://www.fpdf.org/en/script/script32.php

function VCell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=false)
{
//Output a cell
$k=$this->k;
if($this->y+$h>$this->PageBreakTrigger && !$this->InHeader && !$this->InFooter && $this->AcceptPageBreak())
{
//Automatic page break
$x=$this->x;
$ws=$this->ws;
if($ws>0)
{
$this->ws=0;
$this->_out('0 Tw');
}
$this->AddPage($this->CurOrientation,$this->CurPageFormat);
$this->x=$x;
if($ws>0)
{
$this->ws=$ws;
$this->_out(sprintf('%.3F Tw',$ws*$k));
}
}
if($w==0)
$w=$this->w-$this->rMargin-$this->x;
$s='';
// begin change Cell function
if($fill || $border>0)
{
if($fill)
$op=($border>0) ? 'B' : 'f';
else
$op='S';
if ($border>1) {
$s=sprintf('q %.2F w %.2F %.2F %.2F %.2F re %s Q ',$border,
$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
}
else
$s=sprintf('%.2F %.2F %.2F %.2F re %s ',$this->x*$k,($this->h-$this->y)*$k,$w*$k,-$h*$k,$op);
}
if(is_string($border))
{
$x=$this->x;
$y=$this->y;
if(is_int(strpos($border,'L')))
$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);
else if(is_int(strpos($border,'l')))
$s.=sprintf('q 2 w %.2F %.2F m %.2F %.2F l S Q ',$x*$k,($this->h-$y)*$k,$x*$k,($this->h-($y+$h))*$k);

if(is_int(strpos($border,'T')))
$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);
else if(is_int(strpos($border,'t')))
$s.=sprintf('q 2 w %.2F %.2F m %.2F %.2F l S Q ',$x*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-$y)*$k);

if(is_int(strpos($border,'R')))
$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
else if(is_int(strpos($border,'r')))
$s.=sprintf('q 2 w %.2F %.2F m %.2F %.2F l S Q ',($x+$w)*$k,($this->h-$y)*$k,($x+$w)*$k,($this->h-($y+$h))*$k);

if(is_int(strpos($border,'B')))
$s.=sprintf('%.2F %.2F m %.2F %.2F l S ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
else if(is_int(strpos($border,'b')))
$s.=sprintf('q 2 w %.2F %.2F m %.2F %.2F l S Q ',$x*$k,($this->h-($y+$h))*$k,($x+$w)*$k,($this->h-($y+$h))*$k);
}
if(trim($txt)!='')
{
$cr=substr_count($txt,"\n");
if ($cr>0) { // Multi line
$txts = explode("\n", $txt);
$lines = count($txts);
for($l=0;$l<$lines;$l++) {
$txt=$txts[$l];
$w_txt=$this->GetStringWidth($txt);
if ($align=='U')
$dy=$this->cMargin+$w_txt;
elseif($align=='D')
$dy=$h-$this->cMargin;
else
$dy=($h+$w_txt)/2;
$txt=str_replace(')','\)',str_replace('(','\(',str_replace('\','\\',$txt)));
if($this->ColorFlag)
$s.='q '.$this->TextColor.' ';
$s.=sprintf('BT 0 1 -1 0 %.2F %.2F Tm (%s) Tj ET ',
($this->x+.5*$w+(.7+$l-$lines/2)*$this->FontSize)*$k,
($this->h-($this->y+$dy))*$k,$txt);
if($this->ColorFlag)
$s.=' Q ';
}
}
else { // Single line
$w_txt=$this->GetStringWidth($txt);
$Tz=100;
if ($w_txt>$h-2*$this->cMargin) {
$Tz=($h-2*$this->cMargin)/$w_txt*100;
$w_txt=$h-2*$this->cMargin;
}
if ($align=='U')
$dy=$this->cMargin+$w_txt;
elseif($align=='D')
$dy=$h-$this->cMargin;
else
$dy=($h+$w_txt)/2;
$txt=str_replace(')','\)',str_replace('(','\(',str_replace('\','\\',$txt)));
if($this->ColorFlag)
$s.='q '.$this->TextColor.' ';
$s.=sprintf('q BT 0 1 -1 0 %.2F %.2F Tm %.2F Tz (%s) Tj ET Q ',
($this->x+.5*$w+.3*$this->FontSize)*$k,
($this->h-($this->y+$dy))*$k,$Tz,$txt);
if($this->ColorFlag)
$s.=' Q ';
}
}
// end change Cell function
if($s)
$this->_out($s);
$this->lasth=$h;
if($ln>0)
{
//Go to next line
$this->y+=$h;
if($ln==1)
$this->x=$this->lMargin;
}
else
$this->x+=$w;
}


Change the lines in file: html2pdf.class.php
Line:

if (strlen($str)) $this->pdf->Cell($wc, $h+$dh, $str, 0, 0, $align, $fill, $this->inLink);

Change with:

if (strlen($str)){
if($this->style->value['writing-mode']!=null){
$this->pdf->VCell($wc, $h+$dh, $str, 0, 0, $align, $fill);
}else{
$this->pdf->Cell($wc, $h+$dh, $str, 0, 0, $align, $fill, $this->inLink);
}
}


and line:

$this->pdf->Cell(($align=='L' ? $w : $this->style->value['width']), $h+$dh, $txt, 0, 0, $align, $fill, $this->inLink);


with lines:

if($this->style->value['writing-mode']!=null){
$this->pdf->VCell(($align=='L' ? $w : $this->style->value['width']), $h+$dh, $txt, 0, 0, $align, $fill);
}else{
$this->pdf->Cell(($align=='L' ? $w : $this->style->value['width']), $h+$dh, $txt, 0, 0, $align, $fill, $this->inLink);
}


I hope it help for someone.
I add "filter" attribute but it is not impement in this solution.
Always something new.

7

it will not works with tables, div, and others blocks tags... it will only works with text alone in a page
Ancien pseudo : lolo

8

Yes I wrote that work with simple text. But whit barcode should work I think.
If someone have to rotate simple text it is solution.
Always something new.

9

Dans la prochaine version 3.25, la propriété css rotate sera présente.
Elle permettra de tourner une DIV entièrement, avec tout son contenu.
Elle sera à utiliser comme suit :
<div style="rotate: 90"> ... </div>

Voici un exemple : http://html2pdf.fr/_html2pdf/exemples/pdf/exemple08.pdf

pour plus d'informations sur la prochaine version : http://html2pdf.fr/exemple_fr



On the next release 3.25, the CSS property rotate will be there.
It will rotate a DIV fully, with all its contents.
It will be used as follows:
<div style="rotate: 90"> ... </div>

Here is a example : http://html2pdf.fr/_html2pdf/exemples/pdf/exemple08.pdf

For more informations on the next release : http://html2pdf.fr/exemple_en
Ancien pseudo : lolo

10

11


Advertising is not allowed in this forum

la publicité n'est pas autorisé dans ce forum
Ancien pseudo : lolo