Write space with TCPDF into a PDF file

前端 未结 3 1830
爱一瞬间的悲伤
爱一瞬间的悲伤 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条回答
  •  不要未来只要你来
    2021-01-25 03:10

    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 = <<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

提交回复
热议问题