bem consegui achar uma função aqi pra poder colocar o texto
justificado
mas ocorreu um outro problema
quando justifico um texto e no meio deste texto tem negrito
o texto em negrito acaba saindo com quebra de linha
ex.:<P ALIGN=justify>Pelo presente instrumento particular de prestação
de serviços e honorários advocatícios, de um lado como<B>CONTRATADA
MINGARDI E MINGARDI ADVOGADOS ASSOCIADOS</B>, sociedade de advogados
devidamente registrada na OAB, ............</P>
acaba saindo assim:
Pelo presente instrumento particular de prestação de serviços e
honorários advocatícios, de um lado como
CONTRATADA MINGARDI E MINGARDI ADVOGADOS ASSOCIADOS
, sociedade de advogados devidamente registrada na OAB, ............
eu qeria deixar junto (concatenado)
se alguem puder me ajudar
segue o codigo
<?php
require('fpdf.php');
//function hex2dec
//returns an associative array (keys: R,G,B) from
//a hex html code (e.g. #3FE5AA)
function hex2dec($couleur = "#000000"){
$R = substr($couleur, 1, 2);
$rouge = hexdec($R);
$V = substr($couleur, 3, 2);
$vert = hexdec($V);
$B = substr($couleur, 5, 2);
$bleu = hexdec($B);
$tbl_couleur = array();
$tbl_couleur['R']=$rouge;
$tbl_couleur['G']=$vert;
$tbl_couleur['B']=$bleu;
return $tbl_couleur;
}
//conversion pixel -> millimeter in 72 dpi
function px2mm($px){
return $px*25.4/72;
}
function txtentities($html){
$trans = get_html_translation_table(HTML_ENTITIES);
$trans = array_flip($trans);
return strtr($html, $trans);
}
////////////////////////////////////
class PDF_HTML extends FPDF
{
var $B=0;
var $I=0;
var $U=0;
var $HREF='';
var $ALIGN='';
function WriteHTML($html)
{
//HTML parser
$html=str_replace("\n",' ',$html);
$a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
foreach($a as $i=>$e)
{
if($i%2==0)
{
//Text
if($this->HREF)
$this->PutLink($this->HREF,$e);
elseif($this->ALIGN == 'center'){
$this->MultiCell(145,5,$e,0,'C');
}
elseif($this->ALIGN == 'justify'){
$this->MultiCell(145,5,$e,0,"J");
}
elseif($this->ALIGN == 'right'){
$this->MultiCell(145,5,$e,0,"R");
}
else
$this->Write(5,$e);
}
else
{
//Tag
if($e{0}=='/')
$this->CloseTag(strtoupper(substr($e,1)));
else
{
//Extract properties
$a2=split(' ',$e);
$tag=strtoupper(array_shift($a2));
$prop=array();
foreach($a2 as $v)
if(ereg('^([^=]*)=["\']?([^"\']*)["\']?$',$v,
$a3))
$prop[strtoupper($a3[1])]=$a3[2];
$this->OpenTag($tag,$prop);
}
}
}
}
function OpenTag($tag,$prop)
{
//Opening tag
if($tag=='B' or $tag=='I' or $tag=='U')
$this->SetStyle($tag,true);
if($tag=='A')
$this->HREF=$prop['HREF'];
if($tag=='BR')
$this->Ln(5);
if($tag=='P')
$this->ALIGN=$prop['ALIGN'];
if($tag=='HR')
{
if( $prop['WIDTH'] != '' )
$Width = $prop['WIDTH'];
else
$Width = $this->w - $this->lMargin-$this->rMargin;
$this->Ln(2);
$x = $this->GetX();
$y = $this->GetY();
$this->SetLineWidth(0.4);
$this->Line($x,$y,$x+$Width,$y);
$this->SetLineWidth(0.2);
$this->Ln(2);
}
}
function CloseTag($tag)
{
//Closing tag
if($tag=='B' or $tag=='I' or $tag=='U')
$this->SetStyle($tag,false);
if($tag=='A')
$this->HREF='';
if($tag=='P')
$this->ALIGN='';
}
function SetStyle($tag,$enable)
{
//Modify style and select corresponding font
$this->$tag+=($enable ? 1 : -1);
$style='';
foreach(array('B','I','U') as $s)
if($this->$s>0)
$style.=$s;
$this->SetFont('',$style);
}
function PutLink($URL,$txt)
{
//Put a hyperlink
$this->SetTextColor(0,0,255);
$this->SetStyle('U',true);
$this->Write(5,$txt,$URL);
$this->SetStyle('U',false);
$this->SetTextColor(0);
}
//Cabecalho
function Header(){
$this->Image('imagem.jpg',45,10,65);
$this->SetFont('Arial','i',8);
$this->Cell(95); //Mover para direita
$this->Cell(50,10,'Endereço: Av. Paulo Afonso, n.º460, 2º andar,
conjs.07, 08 e 09,',0,0,'R'); //Titulo
$this->Ln(3);
$this->Cell(95);
$this->Cell(50,10,'centro, São Bernardo do Campo – SP, CEP
09770-350.',0,0,'R'); //Titulo
$this->Ln(3);
$this->Cell(95); //Mover para direita
$this->Cell(50,10,'Fone/fax: (11) 4121-5777 ',0,0,'R'); //Titulo
$this->Ln(6);
$this->Cell(95); //Mover para direita
$this->Cell(50,10,'Correio eletrônico:
ming...@mingardi.com.br ',
0,0,'R'); //Titulo
$this->Ln(6);
$this->Cell(95); //Mover para direita
$this->Cell(50,10,'Site:
www.mingardi.com.br ',0,0,'R'); //Titulo
$this->Ln(10);
$this->Cell(1); //Mover para direita
$this->Cell(143,0,'',1,1,'L');
$this->Ln(10); //Quebra de linha
}
//Rodape
function Footer(){
$this->SetY(-15); //Posicao a 15mm da margem inferior
$this->SetFont('Arial','I',8);
$this->Cell(1);
$this->Cell(143,0,'',1,1,'L');
$this->Cell(143,5,'Pagina '.$this->PageNo(),0,0,'R'); //Numero da
Pagina
}
}
//Instanciacao da classe filha
$pdf=new PDF_HTML();
$pdf->SetLeftMargin(45);
$pdf->SetRightMargin(20);
$pdf->AliasNbPages('{numeroDePaginas}');//alias para chamar total de
paginas
$pdf->AddPage();
$pdf->SetFont('Times','',12);
$texto="";
$pdf->WriteHTML($texto);
$pdf->Output();
?>