2012-06-06 50 views
-1

我必须写从POST方法的形式发送的动态数据和我的脚本应该写元素的列表中,由一个空行PDF文件分割。空间从PHP编写PDF文件,TCPDF

的代码是:

<?php 

require_once('libs/tcpdf/config/lang/ita.php'); 
require_once('libs/tcpdf/tcpdf.php'); 

// create new PDF document 
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 

// set document information 
$pdf->SetCreator(PDF_CREATOR); 
$pdf->SetAuthor('Label Creator'); 
$pdf->SetTitle('labels'); 
$pdf->SetSubject('Labels di prova'); 
$pdf->SetKeywords('TCPDF, PDF, example, test, guide'); 

// set default monospaced font 
$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); 
$pdf->setPrintHeader(false); 
$pdf->setPrintFooter(false); 

//set auto page breaks 
$pdf->SetAutoPageBreak(TRUE,0); 

//set image scale factor 
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 

//set some language-dependent strings 
$pdf->setLanguageArray($l); 



// set font 
$pdf->SetFont('times', '', 10); 
//imposto il margine sinistro a 30mm 
$pdf->SetMargins(18,15,18,FALSE); 
// add a page 
$pdf->AddPage(); 

//$pdf->Write(0, 'Example of HTML tables', '', 0, 'L', true, 0, false, false, 0); 

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 
for($i=0;$i<count($_POST['article']);$i++) 
{ 
    $j=0; 
    while($j<$_POST['qnt'][$i]) 
    { 
     $label= 'ART.: '.ucfirst($_POST['article'][$i]). 
       'COLORE: '.ucfirst($_POST['colore'][$i]). 
       'FONDO: '.ucfirst($_POST['fondo'][$i]). 
       'NUMERO: '.$_POST['numero'][$i]; 

     $pdf->Cell(0, 0 , $label, 0, 1, 'C', 0, '', 0,FALSE,'T','M',0, 1, 'C', 0, ''); 
     $pdf->Cell(0, 0 , $label, 0, 1, 'C', 0, '', 0,FALSE,'T','M',0, 1, 'C', 0, ''); 

    } 

} 

//Close and output PDF document 
$pdf->Output('../../labels.pdf', 'F'); 
echo 'generated'; 

?> 

然而,在PDF我有接近对方所有的话不带空格!我已经检查了很多次了库的正确语法,但看起来没问题。有什么建议么?

回答

0

我已经找到了解决办法。 这是Linux系统上Chrome的一个bug!