example59_new_mPDF_v5-6_features.php 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <?php
  2. require_once __DIR__ . '/../vendor/autoload.php';
  3. $mpdf = new mPDF('');
  4. //==============================================================
  5. $html = '
  6. <style>
  7. .gradient {
  8. border:0.1mm solid #220044;
  9. background-color: #f0f2ff;
  10. background-gradient: linear #c7cdde #f0f2ff 0 1 0 0.5;
  11. box-shadow: 0.3em 0.3em #888888;
  12. }
  13. .rounded {
  14. border:0.1mm solid #220044;
  15. background-color: #f0f2ff;
  16. background-gradient: linear #c7cdde #f0f2ff 0 1 0 0.5;
  17. border-radius: 2mm;
  18. background-clip: border-box;
  19. }
  20. h4 {
  21. font-weight: bold;
  22. margin-top: 1em;
  23. margin-bottom: 0.3em;
  24. margin-top: 0;
  25. }
  26. div.text {
  27. padding:0.8em;
  28. margin-bottom: 0.7em;
  29. }
  30. p { margin: 0.25em 0; }
  31. .code {
  32. font-family: monospace;
  33. font-size: 9pt;
  34. background-color: #d5d5d5;
  35. margin: 1em 1cm;
  36. padding: 0 0.3cm;
  37. border:0.2mm solid #000088;
  38. box-shadow: 0.3em 0.3em #888888;
  39. }
  40. table {
  41. border:1px solid #000000;
  42. font-family: sans-serif;
  43. font-size: 10pt;
  44. background-gradient: linear #c7cdde #f0f2ff 0 1 0 0.5;
  45. }
  46. td, th {
  47. border:1px solid #000000;
  48. text-align: left;
  49. font-weight: normal;
  50. }
  51. .shadowtitle {
  52. height: 8mm;
  53. background-color: #EEDDFF;
  54. background-gradient: linear #c7cdde #f0f2ff 0 1 0 0.5;
  55. padding: 0.8em;
  56. padding-left: 3em;
  57. font-family:sans;
  58. font-size: 26pt;
  59. font-weight: bold;
  60. border: 0.2mm solid white;
  61. border-radius: 0.2em;
  62. box-shadow: 0 0 2em 0.5em rgba(0,0,255,0.9);
  63. color: #AAAACC;
  64. text-shadow: 0.03em 0.03em #666, 0.05em 0.05em rgba(127,127,127,0.5), -0.015em -0.015em white;
  65. }
  66. h3 {
  67. margin: 3em 0 2em -15mm;
  68. background-color: #EEDDFF;
  69. background-gradient: linear #c7cdde #f0f2ff 0 1 0 0.5;
  70. padding: 0.5em;
  71. padding-left: 3em;
  72. width: 50%;
  73. font-family:sans;
  74. font-size: 16pt;
  75. font-weight: bold;
  76. border-left: none;
  77. border-radius: 0 2em 2em 0;
  78. box-shadow: 0 0 2em 0.5em rgba(255,0,0,1);
  79. text-shadow: 0.05em 0.04em rgba(127,127,127,0.5);
  80. }
  81. .css {
  82. font-family: arial;
  83. font-style: italic;
  84. color: #000088;
  85. }
  86. table.pop {
  87. border-collapse: collapse;
  88. }
  89. table.pop td {
  90. font-family: arial;
  91. font-size: 10px;
  92. border: 1px solid #888888;
  93. }
  94. meter.pop {
  95. margin: 3px;
  96. }
  97. fieldset { border: 1px solid #000000; border-radius: 5px; padding: 10px; }
  98. div.folder {
  99. background: url(data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/f3//Ub//ge8WSLf/rhf/3kdbW1mxsbP//mf///yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExKcppV0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPj/gAwXEQA7) no-repeat 4px center;
  100. padding: 5px 0 5px 25px;
  101. border: 1px solid #000000;
  102. }
  103. </style>
  104. <body>
  105. <div class="shadowtitle">New Features in mPDF v5.6</div>
  106. <h3>HTML5 tags</h3>
  107. <div class="gradient text">
  108. <p>New tags introduced in HTML5 now have basic support in mPDF, and will thus support CSS style references.</p>
  109. <p>The following are treated as block elements similar to &lt;div&gt;:</p>
  110. <p class="code">&lt;article&gt; &lt;aside&gt; &lt;details&gt; &lt;figure&gt; &lt;figcaption&gt; &lt;footer&gt; &lt;header&gt; &lt;hgroup&gt; &lt;nav&gt; &lt;section&gt; &lt;summary&gt; </p>
  111. <p>The following are treated as in-line elements:</p>
  112. <p class="code">&lt;time&gt; &lt;mark&gt;</p>
  113. <p>Mark is set by default to highlight in yellow in config.php using $defaultCSS e.g. <mark>mark</mark></p>
  114. <p>Progress and meter are discussed below:</p>
  115. </div>
  116. <h3>&lt;progress&gt;</h3>
  117. <div class="gradient text">
  118. <p>Progress: accepts the attributes value and max. A progress element without a value is called an indeterminate progress bar.
  119. Text between the opening and closing tags is not displayed.</p>
  120. <p>CSS styles properties can be applied: display, visibility, margin, padding, border, vertical-align, width, height and opacity.
  121. HTML attributes width and height are supported, although not officially part of the spec.</p>
  122. <p>Example:</p>
  123. <p class="code">&lt;progress value="5" max="10"&gt;50%&lt;/progress&gt;</p>
  124. <ul class="compact">
  125. <li>
  126. <label>Indeterminate</label>
  127. <progress max="100"></progress>
  128. </li>
  129. <li>
  130. <label>Progress: 0%</label>
  131. <progress max="10" value="0"></progress>
  132. </li>
  133. <li>
  134. <label>Progress: 100%</label>
  135. <progress max="3254" value="3254"></progress>
  136. </li>
  137. <li>
  138. <label>Progress: 57%</label>
  139. <progress max="0.7" value="0.4"></progress>
  140. </li>
  141. </ul>
  142. </div>
  143. <h3>&lt;meter&gt;</h3>
  144. <div class="gradient text">
  145. <p>Meter: accepts the attributes min, max, value, optimum, low, and high.
  146. Text between the opening and closing tags is not displayed.</p>
  147. <p>CSS styles properties can be applied: display, visibility, margin, padding, border, vertical-align, width, height and opacity.
  148. HTML attributes width and height are supported, although not officially part of the spec.</p>
  149. <p>Example:</p>
  150. <p class="code">&lt;meter value="5" max="10" min="1" low="2" high="8" optimum="5.6"&gt;5&lt;/meter&gt;</p>
  151. <ul class="compact">
  152. <li>
  153. <label>Meter: full</label>
  154. <meter value="1"></meter>
  155. </li>
  156. <li>
  157. <label>Preferred usage</label>
  158. <meter min="1024" max="10240" low="2048" high="8192" value="1824" optimum="1024"></meter>
  159. </li>
  160. <li>
  161. <label>Too much traffic</label>
  162. <meter min="1024" max="10240" low="2048" high="8192" value="6216" optimum="1024"></meter>
  163. </li>
  164. <li>
  165. <label>Much too much traffic</label>
  166. <meter min="1024" max="10240" low="2048" high="8192" value="9216" optimum="1024"></meter>
  167. </li>
  168. </ul>
  169. </div>
  170. <div class="gradient text">
  171. <h4>Custom appearances for &lt;meter&gt; and &lt;progress&gt;</h4>
  172. <p>Meter (and to a lesser extent progress) can be used with custom appearances e.g. by using optimum to display the average, and low/high to indicate 90th centiles</p>
  173. <p>Custom appearances can be written by editing the script in classes/meter.php - Use a custom attribute of type="anyname" which is passed to the class as a variable e.g.</p>
  174. <p class="code">&lt;meter type="2" value="612.7" optimum="580.4" min="517.0 " max="642.7" low="542" high="600"&gt;612.7&lt;/meter&gt;</p>
  175. </div>
  176. <table class="pop">
  177. <tbody>
  178. <tr>
  179. <td><p><b>Domain</b></p></td>
  180. <td><p><b>Indicator</b></p></td>
  181. <td><p><b>LHB</b></p><p><b>number</b></p></td>
  182. <td><p><b>LHB</b></p><p><b>Indicator</b></p>
  183. <p><b>value</b></p>
  184. </td>
  185. <td><p><b>Wales</b></p><p><b>average</b></p>
  186. </td>
  187. <td><p><b>Wales range</b></p></td>
  188. <td><p><b>Comparison</b></p></td>
  189. </tr>
  190. <tr>
  191. <td rowspan="4"><p><b>Deaths</b></p></td>
  192. <td><p>Death Rates per 100,000 population</p></td>
  193. <td><p>3046</p></td>
  194. <td><p><b>612.7</b><b></b></p></td>
  195. <td><p>580.4</p></td>
  196. <td><p>517.0 - 642.7</p></td>
  197. <td><meter class="pop" type="2" value="612.7" optimum="580.4" min="517.0 " max="642.7" low="542" high="600">612.7</meter></td>
  198. </tr>
  199. <tr>
  200. <td><p>Death Rates per 100,000 from cancer</p></td>
  201. <td><p>789</p></td>
  202. <td><p><b>178.2</b><b></b></p></td>
  203. <td><p>172.7</p></td>
  204. <td><p>159.5 - 182.2</p></td>
  205. <td><meter class="pop" type="2" value="178.2" optimum="172.7" min="159.5 " max="182.2" low="162" high="180">178.2</meter></td>
  206. </tr>
  207. <tr>
  208. <td><p>Death Rates per 100,000 from respiratory disease</p></td>
  209. <td><p>505</p></td>
  210. <td><p><b>60.5</b><b></b></p></td>
  211. <td><p>72.11</p></td>
  212. <td><p>54.41 - 95.5</p></td>
  213. <td><meter class="pop" type="2" value="60.5" optimum="72.11" min="54.41 " max="95.5" low="68" high="80">60.5</meter></td>
  214. </tr>
  215. <tr>
  216. <td><p>Death Rates per 100,000 from cardiovascular disease</p></td>
  217. <td><p>913</p></td>
  218. <td><p><b>178.2</b><b></b></p></td>
  219. <td><p>165.0</p></td>
  220. <td><p>151.8 - 179.9</p></td>
  221. <td><meter class="pop" type="2" value="160.2" optimum="165" min="151.8 " max="179.9" low="158" high="170">160.2</meter></td>
  222. </tr>
  223. </tbody>
  224. </table>
  225. <h3>Fieldset and Legend</h3>
  226. <form>
  227. <fieldset>
  228. <legend>Fieldset and legend</legend>
  229. <p>Support for fieldset and legend was introduced in mPDF v5.5. Consider it experimental!</p>
  230. <label for="name">Username:</label>
  231. <input type="text" name="name" id="name" />
  232. <br />
  233. <label for="mail">E-mail:</label>
  234. <input type="text" name="mail" id="mail" />
  235. </fieldset>
  236. </form>
  237. <h3>CSS styles</h3>
  238. <div class="gradient text">
  239. <h4></h4>
  240. <p><span class="css">min-height</span>, <span class="css">min-width</span>, <span class="css">max-height</span> and <span class="css">max-width</span> are now supported in CSS style sheets for &lt;img&gt; (only).</p>
  241. <p><span class="css">background: url(data:image/gif;base64,...)</span> is now supported in CSS style sheets (gif, png and jpeg).</p>
  242. </div>
  243. <div class="folder">This &lt;div&gt; has the folder icon set as an embedded image in the CSS</div>
  244. <p class="code">div.folder {
  245. background: url(data:image/gif;base64,R0lGODlhEAAOALMAAOazToeHh0tLS/7LZv/0jvb29t/f3//Ub//ge8WSLf/rhf/3kdbW1mxsbP//mf///yH5BAAAAAAALAAAAAAQAA4AAARe8L1Ekyky67QZ1hLnjM5UUde0ECwLJoExKcppV0aCcGCmTIHEIUEqjgaORCMxIC6e0CcguWw6aFjsVMkkIr7g77ZKPJjPZqIyd7sJAgVGoEGv2xsBxqNgYPj/gAwXEQA7) no-repeat 4px center;
  246. padding: 5px 0 5px 25px;
  247. border: 1px solid #000000;
  248. }
  249. </p>
  250. ';
  251. //==============================================================
  252. $mpdf->WriteHTML($html);
  253. $mpdf->Output(); exit;
  254. //==============================================================
  255. //==============================================================
  256. //==============================================================
  257. //==============================================================