This question is an exact duplicate of:
- Write space with TCPDF into a PDF file 3 answers
I must write dynamic data sent from a form with POST method and my script should write a list of element, divided by a blank line in a PDF file.
The code is:
<?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';
?>
However, in the PDF I have all the words near each other without spaces! I've check a lot of times for the correct syntax of the library but looks okay. Any suggestions?
</div>