blob: 640d1e007c81b7b014cc2bc6713a163b09df1876 [file] [log] [blame]
Copybara botbe50d492023-11-30 00:16:42 +01001<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3<head>
4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5<title>AcceptPageBreak</title>
6<link type="text/css" rel="stylesheet" href="../fpdf.css">
7</head>
8<body>
9<h1>AcceptPageBreak</h1>
10<code><b>boolean</b> AcceptPageBreak()</code>
11<h2>Description</h2>
12Whenever a page break condition is met, the method is called, and the break is issued or not
13depending on the returned value. The default implementation returns a value according to the
14mode selected by SetAutoPageBreak().
15<br>
16This method is called automatically and should not be called directly by the application.
17<h2>Example</h2>
18The method is overriden in an inherited class in order to obtain a 3 column layout:
19<div class="doc-source">
20<pre><code>class PDF extends FPDF
21{
22 protected $col = 0;
23
24 function SetCol($col)
25 {
26 // Move position to a column
27 $this-&gt;col = $col;
28 $x = 10 + $col*65;
29 $this-&gt;SetLeftMargin($x);
30 $this-&gt;SetX($x);
31 }
32
33 function AcceptPageBreak()
34 {
35 if($this-&gt;col&lt;2)
36 {
37 // Go to next column
38 $this-&gt;SetCol($this-&gt;col+1);
39 $this-&gt;SetY(10);
40 return false;
41 }
42 else
43 {
44 // Go back to first column and issue page break
45 $this-&gt;SetCol(0);
46 return true;
47 }
48 }
49}
50
51$pdf = new PDF();
52$pdf-&gt;AddPage();
53$pdf-&gt;SetFont('Arial', '', 12);
54for($i=1;$i&lt;=300;$i++)
55 $pdf-&gt;Cell(0, 5, "Line $i", 0, 1);
56$pdf-&gt;Output();</code></pre>
57</div>
58<h2>See also</h2>
59<a href="setautopagebreak.htm">SetAutoPageBreak</a>
60<hr style="margin-top:1.5em">
61<div style="text-align:center"><a href="index.htm">Index</a></div>
62</body>
63</html>