1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
---|
2 | <html>
|
---|
3 | <head>
|
---|
4 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
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>
|
---|
12 | Whenever a page break condition is met, the method is called, and the break is issued or not
|
---|
13 | depending on the returned value. The default implementation returns a value according to the
|
---|
14 | mode selected by SetAutoPageBreak().
|
---|
15 | <br>
|
---|
16 | This method is called automatically and should not be called directly by the application.
|
---|
17 | <h2>Example</h2>
|
---|
18 | The 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 | var $col=0;
|
---|
23 |
|
---|
24 | function SetCol($col)
|
---|
25 | {
|
---|
26 | //Move position to a column
|
---|
27 | $this->col=$col;
|
---|
28 | $x=10+$col*65;
|
---|
29 | $this->SetLeftMargin($x);
|
---|
30 | $this->SetX($x);
|
---|
31 | }
|
---|
32 |
|
---|
33 | function AcceptPageBreak()
|
---|
34 | {
|
---|
35 | if($this->col<2)
|
---|
36 | {
|
---|
37 | //Go to next column
|
---|
38 | $this->SetCol($this->col+1);
|
---|
39 | $this->SetY(10);
|
---|
40 | return false;
|
---|
41 | }
|
---|
42 | else
|
---|
43 | {
|
---|
44 | //Go back to first column and issue page break
|
---|
45 | $this->SetCol(0);
|
---|
46 | return true;
|
---|
47 | }
|
---|
48 | }
|
---|
49 | }
|
---|
50 |
|
---|
51 | $pdf=new PDF();
|
---|
52 | $pdf->AddPage();
|
---|
53 | $pdf->SetFont('Arial','',12);
|
---|
54 | for($i=1;$i<=300;$i++)
|
---|
55 | $pdf->Cell(0,5,"Line $i",0,1);
|
---|
56 | $pdf->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>
|
---|