example18_headers_method_4.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. $html = '
  3. <!-- defines the headers/footers - this must occur before the headers/footers are set -->
  4. <!--mpdf
  5. <htmlpageheader name="myHTMLHeader1">
  6. <table width="100%" style="border-bottom: 1px solid #000000; vertical-align: bottom; font-family: serif; font-size: 9pt; color: #000088;"><tr>
  7. <td width="33%">Left header p <span style="font-size:14pt;">{PAGENO}</span></td>
  8. <td width="33%" align="center"><img src="sunset.jpg" width="126px" /></td>
  9. <td width="33%" style="text-align: right;"><span style="font-weight: bold;">myHTMLHeader1</span></td>
  10. </tr></table>
  11. </htmlpageheader>
  12. <htmlpageheader name="myHTMLHeader1Even">
  13. <table width="100%" style="border-bottom: 1px solid #000000; vertical-align: bottom; font-family: serif; font-size: 9pt; color: #000088;"><tr>
  14. <td width="33%"><span style="font-weight: bold;">myHTMLHeader1Even</span></td>
  15. <td width="33%" align="center"><img src="sunset.jpg" width="126px" /></td>
  16. <td width="33%" style="text-align: right;">Inner header p <span style="font-size:14pt;">{PAGENO}</span></td>
  17. </tr></table>
  18. </htmlpageheader>
  19. <htmlpageheader name="myHTMLHeader2">
  20. <table width="100%" style="border-bottom: 1px solid #880000; vertical-align: bottom; font-family: sans; font-size: 9pt; color: #880000;"><tr>
  21. <td width="33%">myHTMLHeader2 p.<span style="font-size:14pt;">{PAGENO}</span></td>
  22. <td width="33%" align="center"><img src="sunset.jpg" width="126px" /></td>
  23. <td width="33%" style="text-align: right;"><span style="font-weight: bold;">myHTMLHeader2</span></td>
  24. </tr></table>
  25. </htmlpageheader>
  26. <htmlpageheader name="myHTMLHeader2Even">
  27. <table width="100%" style="border-bottom: 1px solid #880000; vertical-align: bottom; font-family: sans; font-size: 9pt; color: #880000;"><tr>
  28. <td width="33%"><span style="font-weight: bold;">myHTMLHeader2Even</span></td>
  29. <td width="33%" align="center"><img src="sunset.jpg" width="126px" /></td>
  30. <td width="33%" style="text-align: right;">Inner header p <span style="font-size:14pt;">{PAGENO}</span></td>
  31. </tr></table>
  32. </htmlpageheader>
  33. mpdf-->
  34. <!-- set the headers/footers - they will occur from here on in the document -->
  35. <!--mpdf
  36. <sethtmlpageheader name="myHTMLHeader1" page="O" value="on" show-this-page="1" />
  37. <sethtmlpageheader name="myHTMLHeader1Even" page="E" value="on" />
  38. mpdf-->
  39. <h1>mPDF</h1>
  40. <h2>Headers & Footers Method 4</h2>
  41. <p>Nulla felis erat, imperdiet eu, ullamcorper non, nonummy quis, elit. Suspendisse potenti. Ut a eros at ligula vehicula pretium. Maecenas feugiat pede vel risus. Nulla et lectus. Fusce eleifend neque sit amet erat. Integer consectetuer nulla non orci. Morbi feugiat pulvinar dolor. Cras odio. Donec mattis, nisi id euismod auctor, neque metus pellentesque risus, at eleifend lacus sapien et risus. Phasellus metus. Phasellus feugiat, lectus ac aliquam molestie, leo lacus tincidunt turpis, vel aliquam quam odio et sapien. Mauris ante pede, auctor ac, suscipit quis, malesuada sed, nulla. Integer sit amet odio sit amet lectus luctus euismod. Donec et nulla. Sed quis orci. </p>
  42. <pagebreak />
  43. <h2>Headers & Footers Method 4</h2>
  44. <p>Nulla felis erat, imperdiet eu, ullamcorper non, nonummy quis, elit. Suspendisse potenti. Ut a eros at ligula vehicula pretium. Maecenas feugiat pede vel risus. Nulla et lectus. Fusce eleifend neque sit amet erat. Integer consectetuer nulla non orci. Morbi feugiat pulvinar dolor. Cras odio. Donec mattis, nisi id euismod auctor, neque metus pellentesque risus, at eleifend lacus sapien et risus. Phasellus metus. Phasellus feugiat, lectus ac aliquam molestie, leo lacus tincidunt turpis, vel aliquam quam odio et sapien. Mauris ante pede, auctor ac, suscipit quis, malesuada sed, nulla. Integer sit amet odio sit amet lectus luctus euismod. Donec et nulla. Sed quis orci. </p>
  45. <!-- Note the html_ prefix when referencing an HTML header using one of the pagebreaks -->
  46. <pagebreak odd-header-name="html_myHTMLHeader2" odd-header-value="1" even-header-name="html_myHTMLHeader2Even" even-header-value="1" />
  47. <h2>Headers & Footers Method 4</h2>
  48. <p>Nulla felis erat, imperdiet eu, ullamcorper non, nonummy quis, elit. Suspendisse potenti. Ut a eros at ligula vehicula pretium. Maecenas feugiat pede vel risus. Nulla et lectus. Fusce eleifend neque sit amet erat. Integer consectetuer nulla non orci. Morbi feugiat pulvinar dolor. Cras odio. Donec mattis, nisi id euismod auctor, neque metus pellentesque risus, at eleifend lacus sapien et risus. Phasellus metus. Phasellus feugiat, lectus ac aliquam molestie, leo lacus tincidunt turpis, vel aliquam quam odio et sapien. Mauris ante pede, auctor ac, suscipit quis, malesuada sed, nulla. Integer sit amet odio sit amet lectus luctus euismod. Donec et nulla. Sed quis orci. </p>
  49. ';
  50. //==============================================================
  51. //==============================================================
  52. //==============================================================
  53. include("../mpdf.php");
  54. $mpdf=new mPDF('en-x','A4','','',32,25,47,47,10,10);
  55. $mpdf->mirrorMargins = 1; // Use different Odd/Even headers and footers and mirror margins
  56. $mpdf->WriteHTML($html);
  57. $mpdf->Output();
  58. exit;
  59. //==============================================================
  60. //==============================================================
  61. //==============================================================
  62. ?>