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 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)