Inserting line breaks into PDF

前端 未结 13 1672
佛祖请我去吃肉
佛祖请我去吃肉 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:45

    If you are using fpdf, in order to be able to use line breaks you will need to use a multi-line text cell as described here.

    If you use this, then line breaks in your text should be interpreted and converted correctly.

    Just a quick example:

    $pdf->Multicell(0,2,"This is a multi-line text string\nNew line\nNew line"); 
    

    Here, 2 is the height of the multi-line text box. I don't know what units that's measured in or if you can just set it to 0 and ignore it. Perhaps try it with a large number if at first it doesn't work.

提交回复
热议问题