dtxs9017 2012-06-06 15:07
浏览 38
已采纳

使用TCPDF从PHP编写PDF文件的空间[重复]

This question is an exact duplicate of:

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>
  • 写回答

1条回答 默认 最新

  • doudouba4520 2012-06-08 08:12
    关注

    I've found the solution. It is a bug of Chrome on Linux systems!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路
  • ¥15 公交车和无人机协同运输
  • ¥15 stm32代码移植没反应
  • ¥15 matlab基于pde算法图像修复,为什么只能对示例图像有效
  • ¥100 连续两帧图像高速减法
  • ¥15 如何绘制动力学系统的相图