Inserting line breaks into PDF

前端 未结 13 1507
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-30 12:34

I\'m generating some PDF file on the fly using PHP. My problem is I need to insert line breaks in some part of the text that will be inserted in the PDF file. Something like

13条回答
  •  有刺的猬
    2020-11-30 12:51

    Another option is to use TCPDF::Ln(). It adds a line to the PDF with the option to set the height.

    If the newlines are within your content already then MultiCell() is probably the way to go, as others have mentioned, but I find I like using:

    $pdf->Cell(0, 0, 'Line 1', 0, 0, 'C');
    $pdf->Ln();
    $pdf->Cell(0, 0, 'Line 2', 0, 0, 'C');
    

    It confuses me that Cell() and MultiCell() take in different arguments so I tend to stick to using Cell() only. Also it reads like a newline character for the PDF the same as \n reads like a newline character in text or
    in HTML.

提交回复
热议问题