2

How do you use SetAutoPageBreak in fpdf if you want it to be enabled? On the net I've found all sorts of variants:

$p->SetAutoPageBreak(1,20);
$p->SetAutoPageBreak(true,20);
$p->SetAutoPageBreak('true',20);
$p->SetAutoPageBreak(on,20);
$p->SetAutoPageBreak('on',20);
$p->SetAutoPageBreak('on','20');

Thanks!

Claudiu Creanga
  • 8,031
  • 10
  • 71
  • 110
  • FWIW, the second margin parameter seems slightly dodgy here, with a table. If the value is wrong, the table ignores the page break, goes straight through the footer text, and no new page is created for the rest of the rows. For my current code: 40 works, 41-44 doesn't, 45-49 does. 49.4 and 50 don't. 52 works fine. I've given up. – MSpreij Mar 28 '19 at 14:32

1 Answers1

3

SetAutoPageBreak accepts a boolean value for it's first parameter so all the examples you have shown are valid.

See the PHP manual for details on what values are evaluated to true/false. Personally, I would use true or maybe 1. It's clear and easy to understand when you review your code in the future.

Are you having trouble with the output or was it just a curiosity question?

EDIT:

MultiCell is just that, it has multiple cells, to allow for line breaks etc. The page break will only occur if one of the cells breaches the limit and even then it will just break for that cell. So, in effect a paragraph of text over multiple lines may be split across two pages, but the last line on the page won't breach the margin limit.

You might want to consider using cell or, forcing a page break using AddPage.

Mark
  • 3,005
  • 1
  • 21
  • 30
  • it was not working before, but now with 'on' it is working. yes, I have a loop of multicell that sometimes is splited between pages. But I see that setting page break is not helping me at all: http://stackoverflow.com/questions/12349827/fpdf-page-break-issue – Claudiu Creanga Sep 10 '12 at 11:49
  • OK, I think this question is answered - I've posted a response on your other question with that post. – Mark Sep 10 '12 at 12:21