acceptpagebreak.htm 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. <H2>AcceptPageBreak</H2>
  10. <TT><B>boolean</B> AcceptPageBreak()</TT>
  11. <H4 CLASS='st'>Version</H4>
  12. 1.4
  13. <H4 CLASS='st'>Description</H4>
  14. Whenever a page break condition is met, the method is called, and the break is issued or not
  15. depending on the returned value. The default implementation returns a value according to the
  16. mode selected by SetAutoPageBreak().
  17. <BR>
  18. This method is called automatically and should not be called directly by the application.
  19. <H4 CLASS='st'>Example</H4>
  20. The method is overriden in an inherited class in order to obtain a 3 column layout:
  21. <BR>
  22. <BR>
  23. <TABLE WIDTH="100%" BGCOLOR="#E0E0E0"><TR><TD>
  24. <TT>
  25. class PDF extends FPDF<BR>
  26. {<BR>
  27. var $col=0;<BR>
  28. <BR>
  29. function SetCol($col)<BR>
  30. {<BR>
  31. &nbsp;&nbsp;&nbsp;&nbsp;//Move position to a column<BR>
  32. &nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;col=$col;<BR>
  33. &nbsp;&nbsp;&nbsp;&nbsp;$x=10+$col*65;<BR>
  34. &nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;SetLeftMargin($x);<BR>
  35. &nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;SetX($x);<BR>
  36. }<BR>
  37. <BR>
  38. function AcceptPageBreak()<BR>
  39. {<BR>
  40. &nbsp;&nbsp;&nbsp;&nbsp;if($this-&gt;col&lt;2)<BR>
  41. &nbsp;&nbsp;&nbsp;&nbsp;{<BR>
  42. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//Go to next column<BR>
  43. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;SetCol($this-&gt;col+1);<BR>
  44. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;SetY(10);<BR>
  45. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return false;<BR>
  46. &nbsp;&nbsp;&nbsp;&nbsp;}<BR>
  47. &nbsp;&nbsp;&nbsp;&nbsp;else<BR>
  48. &nbsp;&nbsp;&nbsp;&nbsp;{<BR>
  49. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//Go back to first column and issue page break<BR>
  50. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this-&gt;SetCol(0);<BR>
  51. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return true;<BR>
  52. &nbsp;&nbsp;&nbsp;&nbsp;}<BR>
  53. }<BR>
  54. }<BR>
  55. <BR>
  56. $pdf=new PDF();<BR>
  57. $pdf-&gt;AddPage();<BR>
  58. $pdf-&gt;SetFont('Arial','',12);<BR>
  59. for($i=1;$i&lt;=300;$i++)<BR>
  60. &nbsp;&nbsp;&nbsp;&nbsp;$pdf-&gt;Cell(0,5,&quot;Line $i&quot;,0,1);<BR>
  61. $pdf-&gt;Output();
  62. </TT>
  63. </TD></TR></TABLE><BR>
  64. <H4 CLASS='st'>See also</H4>
  65. <A HREF="setautopagebreak.htm">SetAutoPageBreak()</A>.
  66. <HR STYLE="margin-top:1.2em">
  67. <DIV ALIGN="CENTER"><A HREF="index.htm">Index</A></DIV>
  68. </BODY>
  69. </HTML>