4

I'm trying to make a newline inside a multicell. What I've done is:

$pdf->MultiCell(90,10,'test'.'\n'.'test',1,0,'C',1);

According to the manual the multicell should parse the '\n' character and render a newline but it does not (it prints the two byte string '\n' alongside with the actual text)

Gianluca Ghettini
  • 11,129
  • 19
  • 93
  • 159

1 Answers1

10

Try to use "\n" instead of '\n' (or even PHP_EOL predefined constant). Use double quotes.

Related:

Community
  • 1
  • 1
BlitZ
  • 12,038
  • 3
  • 49
  • 68
  • thanks, you made my day! However, I should have expected '\n' to be a single byte value and "\n" to be a two byte string, like in ANSI C style – Gianluca Ghettini May 31 '14 at 08:21
  • @G_G You are welcome. Missing your point... Did it helped? Or there any issues? – BlitZ May 31 '14 at 08:23
  • it worked. However, now multicell is trying to align text on the right even with the 'C' parameter. FPDF is a good library but string managing is soooo clumsy... – Gianluca Ghettini May 31 '14 at 08:24
  • @G_G As mentioned [here](http://www.fpdf.org/en/doc/multicell.htm), try to fix argument count `$pdf->MultiCell(90,10,'test'.'\n'.'test', 0,'C',1);` – BlitZ May 31 '14 at 08:28
  • thank you again. PHP doesn't tell you anything, it interprets the code straight away on a best effort basis – Gianluca Ghettini May 31 '14 at 08:31