Write space with TCPDF into a PDF file

前端 未结 3 1795
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-25 02:28

I\'ve this simple script that write some text into a PDF trought the php library TCPDF. This is the script:

// create new PDF document 
$pdf = new TCPDF(PDF_PAGE         


        
相关标签:
3条回答
  • Option 1: If you want to use Cell

    The prototype is:

    //Cell($w, $h=0, $txt='', $border=0, $ln=0, $align='', $fill=0, $link='', $stretch=0, $ignore_min_height=false, $calign='T', $valign='M')
    

    To deal with spacing, use these:

    $pdf->Cell(0, 0, 'TEST CELL STRETCH: spacing', 1, 1, 'C', 0, '', 3);
    $pdf->Cell(0, 0, 'TEST CELL STRETCH: force spacing', 1, 1, 'C', 0, '', 4);
    

    You can try this:

    $label="Hello world, i'm michele";
    $pdf->Cell(0, 0 , $label, 1, 1, 'C', 0, '', 3;
    

    The border is on, so that you can see if the cell is large enough. Hope this works. (for indication, what follows : FALSE,'T','M' are already the values by default)

    Option 2: You can also use Write()

    $pdf->AddPage();
    
    // set some text to print
    $label = <<<EOD
    About Michele.
    
    Michele is awesome.
    EOD;
    
    // print a block of text using Write()
    $pdf->Write($h=0, $label, $link='', $fill=0, $align='C', $ln=true, $stretch=0, $firstline=false, $firstblock=false, $maxh=0);
    

    You can find plenty of examples there: TCPDF examples

    0 讨论(0)
  • 2021-01-25 03:12

    I believe the problem lies with the "times" font. I had the same problems with that particular font. You can try some of the other fonts in the tcpdf fonts directory.

    0 讨论(0)
  • 2021-01-25 03:20

    I've resolved, the problem is a bug with the browser's PDF plug-in visualizer!!

    0 讨论(0)
提交回复
热议问题