acceptpagebreak.htm 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. function SetCol($col)
  24. {
  25. // Move position to a column
  26. $this-&gt;col = $col;
  27. $x = 10+$col*65;
  28. $this-&gt;SetLeftMargin($x);
  29. $this-&gt;SetX($x);
  30. }
  31. function AcceptPageBreak()
  32. {
  33. if($this-&gt;col&lt;2)
  34. {
  35. // Go to next column
  36. $this-&gt;SetCol($this-&gt;col+1);
  37. $this-&gt;SetY(10);
  38. return false;
  39. }
  40. else
  41. {
  42. // Go back to first column and issue page break
  43. $this-&gt;SetCol(0);
  44. return true;
  45. }
  46. }
  47. }
  48. $pdf = new PDF();
  49. $pdf-&gt;AddPage();
  50. $pdf-&gt;SetFont('Arial','',12);
  51. for($i=1;$i&lt;=300;$i++)
  52. $pdf-&gt;Cell(0,5,"Line $i",0,1);
  53. $pdf-&gt;Output();</code></pre>
  54. </div>
  55. <h2>See also</h2>
  56. <a href="setautopagebreak.htm">SetAutoPageBreak</a>
  57. <hr style="margin-top:1.5em">
  58. <div style="text-align:center"><a href="index.htm">Index</a></div>
  59. </body>
  60. </html>