example07_tables_borders.php 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  1. <?php
  2. $html = '
  3. <html><head>
  4. <style>
  5. table {
  6. font-family: sans-serif;
  7. border: 7mm solid aqua;
  8. border-collapse: collapse;
  9. }
  10. table.table2 {
  11. border: 2mm solid aqua;
  12. border-collapse: collapse;
  13. }
  14. table.layout {
  15. border: 0mm solid black;
  16. border-collapse: collapse;
  17. }
  18. td.layout {
  19. text-align: center;
  20. border: 0mm solid black;
  21. }
  22. td {
  23. padding: 3mm;
  24. border: 2mm solid blue;
  25. vertical-align: middle;
  26. }
  27. td.redcell {
  28. border: 3mm solid red;
  29. }
  30. td.redcell2 {
  31. border: 2mm solid red;
  32. }
  33. </style>
  34. </head>
  35. <body>
  36. <h1>mPDF</h1>
  37. <h2>Tables - Borders</h2>
  38. <h4>mPDF</h4>
  39. Border conflict resolution in tables with border-collapse set to "collapse". mPDF follows the rules set by CSS as well as possible, but as you can see, there is some difference in interpretation of the rules:
  40. <table class="layout">
  41. <tr>
  42. <td class="layout">mPDF</td>
  43. <td class="layout">Internet Explorer<br />IE 7</td>
  44. <td class="layout">Firefox<br />v 3.0.3</td>
  45. </tr>
  46. <tr>
  47. <td class="layout">
  48. <table>
  49. <tr>
  50. <td style="border:5mm solid green">1</td>
  51. <td>1</td>
  52. <td>1</td>
  53. </tr>
  54. <tr>
  55. <td rowspan="2" class="redcell" style="border:5mm solid teal">1</td>
  56. <td style="border:3mm solid pink">1</td>
  57. <td style="border:5mm solid purple">1</td>
  58. </tr>
  59. <tr>
  60. <td style="border:2mm solid gray">1</td>
  61. <td>1</td>
  62. </tr>
  63. <tr>
  64. <td class="redcell">1</td>
  65. <td>1</td>
  66. <td>1</td>
  67. </tr>
  68. </table>
  69. </td>
  70. <td class="layout" rowspan="3"><img src="bordersIE.jpg" /></td>
  71. <td class="layout" rowspan="3"><img src="bordersFF.jpg" /></td>
  72. </tr>
  73. <tr>
  74. <td class="layout" style="text-align: left">
  75. <table style="border: 2.5mm solid aqua">
  76. <tr>
  77. <td class="redcell">1</td>
  78. <td>1</td>
  79. <td>1</td>
  80. </tr>
  81. <tr>
  82. <td rowspan="2" class="redcell" style="border:5mm solid green">1</td>
  83. <td>1</td>
  84. <td>1</td>
  85. </tr>
  86. <tr>
  87. <td>1</td>
  88. <td>1</td>
  89. </tr>
  90. <tr>
  91. <td class="redcell">1</td>
  92. <td>1</td>
  93. <td>1</td>
  94. </tr>
  95. </table>
  96. </td>
  97. </tr>
  98. <tr>
  99. <td class="layout">
  100. <table>
  101. <tr>
  102. <td class="redcell">1</td>
  103. <td>1</td>
  104. <td>1</td>
  105. </tr>
  106. <tr>
  107. <td rowspan="2" >1</td>
  108. <td>1</td>
  109. <td>1</td>
  110. </tr>
  111. <tr>
  112. <td style="border:5mm solid yellow">1</td>
  113. <td>1</td>
  114. </tr>
  115. <tr>
  116. <td class="redcell">1</td>
  117. <td>1</td>
  118. <td>1</td>
  119. </tr>
  120. </table>
  121. </td>
  122. </tr>
  123. </table>
  124. <pagebreak />
  125. <table class="layout">
  126. <tr>
  127. <td class="layout">mPDF</td>
  128. <td class="layout">mPDF &lt; v3</td>
  129. <td class="layout">Internet Explorer<br />IE 7</td>
  130. <td class="layout">Firefox<br />v 3.0.3</td>
  131. </tr>
  132. <tr>
  133. <td class="layout">
  134. <table class="table2">
  135. <tr>
  136. <td style="border:2mm solid green">1</td>
  137. <td>1</td>
  138. <td>1</td>
  139. </tr>
  140. <tr>
  141. <td rowspan="2" class="redcell2" style="border:2mm solid teal">1</td>
  142. <td style="border:2mm solid pink">1</td>
  143. <td style="border:2mm solid purple">1</td>
  144. </tr>
  145. <tr>
  146. <td style="border:2mm solid gray">1</td>
  147. <td>1</td>
  148. </tr>
  149. <tr>
  150. <td class="redcell2">1</td>
  151. <td>1</td>
  152. <td>1</td>
  153. </tr>
  154. </table>
  155. </td>
  156. <td class="layout" rowspan="3"><img src="bordersMPDF2.jpg" /></td>
  157. <td class="layout" rowspan="3"><img src="borders2IE.jpg" /></td>
  158. <td class="layout" rowspan="3"><img src="borders2FF.jpg" /></td>
  159. </tr>
  160. <tr>
  161. <td class="layout" style="text-align: left">
  162. <table style="border: 2mm solid aqua" class="table2">
  163. <tr>
  164. <td class="redcell2">1</td>
  165. <td>1</td>
  166. <td>1</td>
  167. </tr>
  168. <tr>
  169. <td rowspan="2" class="redcell2" style="border:2mm solid green">1</td>
  170. <td>1</td>
  171. <td>1</td>
  172. </tr>
  173. <tr>
  174. <td>1</td>
  175. <td>1</td>
  176. </tr>
  177. <tr>
  178. <td class="redcell2">1</td>
  179. <td>1</td>
  180. <td>1</td>
  181. </tr>
  182. </table>
  183. </td>
  184. </tr>
  185. <tr>
  186. <td class="layout">
  187. <table class="table2">
  188. <tr>
  189. <td class="redcell2">1</td>
  190. <td>1</td>
  191. <td>1</td>
  192. </tr>
  193. <tr>
  194. <td rowspan="2" >1</td>
  195. <td>1</td>
  196. <td>1</td>
  197. </tr>
  198. <tr>
  199. <td style="border:2mm solid yellow">1</td>
  200. <td>1</td>
  201. </tr>
  202. <tr>
  203. <td class="redcell2">1</td>
  204. <td>1</td>
  205. <td>1</td>
  206. </tr>
  207. </table>
  208. </td>
  209. </tr>
  210. </table>
  211. <pagebreak />
  212. <h4>mPDF</h4>
  213. <table style="border: 10px solid orange">
  214. <tr>
  215. <td style="border: 10px solid orange">Data</td>
  216. <td style="border: 10px double red">double red</td>
  217. <td style="border: 10px dashed yellow">dashed yellow</td>
  218. <td style="border: 10px dotted green">dotted green</td>
  219. <td style="border: 10px solid orange">Data</td>
  220. </tr>
  221. <tr>
  222. <td style="border: 10px solid orange">Data</td>
  223. <td style="border: 10px hidden orange">hidden </td>
  224. <td style="border: 10px solid orange">Data</td>
  225. <td style="border: 10px none orange">none</td>
  226. <td style="border: 10px solid orange">Data</td>
  227. </tr>
  228. <tr>
  229. <td style="border: 10px solid orange">Data</td>
  230. <td style="border: 10px ridge blue">ridge blue</td>
  231. <td style="border: 10px none orange">none </td>
  232. <td style="border: 10px none orange">none </td>
  233. <td style="border: 10px solid orange">Data</td>
  234. </tr>
  235. <tr>
  236. <td style="border: 10px solid orange">Data</td>
  237. <td style="border: 10px none orange">none </td>
  238. <td style="border: 10px groove pink">groove pink</td>
  239. <td style="border: 10px none orange">none </td>
  240. <td style="border: 10px solid orange">Data</td>
  241. </tr>
  242. <tr>
  243. <td style="border: 10px none orange">none </td>
  244. <td style="border: 10px inset gray">inset gray</td>
  245. <td style="border: 10px none orange">none </td>
  246. <td style="border: 10px outset purple">outset purple</td>
  247. <td style="border: 10px none orange">none </td>
  248. </tr>
  249. </table>
  250. <h4>Firefox</h4>
  251. <img src="borders3FF.jpg" />
  252. <br />
  253. <h4>IE 7</h4>
  254. <img src="borders3IE.jpg" />
  255. <pagebreak />
  256. <div>mPDF</div>
  257. <table style="border: 10px solid orange; border-collapse: separate;">
  258. <tr>
  259. <td style="border: 10px solid orange">Data</td>
  260. <td style="border: 10px double red">double red</td>
  261. <td style="border: 10px dashed yellow">dashed yellow</td>
  262. <td style="border: 10px dotted green">dotted green</td>
  263. <td style="border: 10px solid orange">Data</td>
  264. </tr>
  265. <tr>
  266. <td style="border: 10px solid orange">Data</td>
  267. <td style="border: 10px hidden orange">hidden </td>
  268. <td style="border: 10px solid orange">Data</td>
  269. <td style="border: 10px none orange">none</td>
  270. <td style="border: 10px solid orange">Data</td>
  271. </tr>
  272. <tr>
  273. <td style="border: 10px solid orange">Data</td>
  274. <td style="border: 10px ridge blue">ridge blue</td>
  275. <td style="border: 10px none orange">none </td>
  276. <td style="border: 10px none orange">none </td>
  277. <td style="border: 10px solid orange">Data</td>
  278. </tr>
  279. <tr>
  280. <td style="border: 10px solid orange">Data</td>
  281. <td style="border: 10px none orange">none </td>
  282. <td style="border: 10px groove pink">groove pink</td>
  283. <td style="border: 10px none orange">none </td>
  284. <td style="border: 10px solid orange">Data</td>
  285. </tr>
  286. <tr>
  287. <td style="border: 10px none orange">none </td>
  288. <td style="border: 10px inset gray">inset gray</td>
  289. <td style="border: 10px none orange">none </td>
  290. <td style="border: 10px outset purple">outset purple</td>
  291. <td style="border: 10px none orange">none </td>
  292. </tr>
  293. </table>
  294. <div>Firefox</div>
  295. <img style="margin:0;" src="borders4FF.jpg" />
  296. <div>IE 7</div>
  297. <img style="margin:0;" src="borders4IE.jpg" />
  298. <pagebreak />
  299. <table style="border: 5px inset teal">
  300. <tr>
  301. <td style="border: 5px solid orange">solid orange</td>
  302. <td style="border: 0px none black">none</td>
  303. <td style="border: 5px double red">double red</td>
  304. <td style="border: 0px none black">none</td>
  305. <td style="border: 5px inset gray">inset gray</td>
  306. <td style="border: 0px none black">none</td>
  307. <td style="border: 5px outset purple">outset purple</td>
  308. <td style="border: 0px none black">none</td>
  309. <td style="border: 5px groove pink">groove pink</td>
  310. <td style="border: 0px none black">none</td>
  311. <td style="border: 5px ridge blue">ridge blue</td>
  312. </tr>
  313. </table>
  314. <table style="border: 5px inset gray; border-collapse: separate;">
  315. <tr>
  316. <td style="border: 5px solid orange">solid orange</td>
  317. <td style="border: 0px none black">none</td>
  318. <td style="border: 5px double red">double red</td>
  319. <td style="border: 0px none black">none</td>
  320. <td style="border: 5px inset gray">inset gray</td>
  321. <td style="border: 0px none black">none</td>
  322. <td style="border: 5px outset purple">outset purple</td>
  323. <td style="border: 0px none black">none</td>
  324. <td style="border: 5px groove pink">groove pink</td>
  325. <td style="border: 0px none black">none</td>
  326. <td style="border: 5px ridge blue">ridge blue</td>
  327. </tr>
  328. </table>
  329. <table style="border: 5px outset purple; border-collapse: separate;">
  330. <tr>
  331. <td style="border: 5px solid orange">solid orange</td>
  332. <td style="border: 0px none black">none</td>
  333. <td style="border: 5px double red">double red</td>
  334. <td style="border: 0px none black">none</td>
  335. <td style="border: 5px inset gray">inset gray</td>
  336. <td style="border: 0px none black">none</td>
  337. <td style="border: 5px outset purple">outset purple</td>
  338. <td style="border: 0px none black">none</td>
  339. <td style="border: 5px groove pink">groove pink</td>
  340. <td style="border: 0px none black">none</td>
  341. <td style="border: 5px ridge blue">ridge blue</td>
  342. </tr>
  343. </table>
  344. <table style="border: 5px groove pink; border-collapse: separate;">
  345. <tr>
  346. <td style="border: 5px solid orange">solid orange</td>
  347. <td style="border: 0px none black">none</td>
  348. <td style="border: 5px double red">double red</td>
  349. <td style="border: 0px none black">none</td>
  350. <td style="border: 5px inset gray">inset gray</td>
  351. <td style="border: 0px none black">none</td>
  352. <td style="border: 5px outset purple">outset purple</td>
  353. <td style="border: 0px none black">none</td>
  354. <td style="border: 5px groove pink">groove pink</td>
  355. <td style="border: 0px none black">none</td>
  356. <td style="border: 5px ridge blue">ridge blue</td>
  357. </tr>
  358. </table>
  359. <table style="border: 5px ridge blue; border-collapse: separate;">
  360. <tr>
  361. <td style="border: 5px solid orange">solid orange</td>
  362. <td style="border: 0px none black">none</td>
  363. <td style="border: 5px double red">double red</td>
  364. <td style="border: 0px none black">none</td>
  365. <td style="border: 5px inset gray">inset gray</td>
  366. <td style="border: 0px none black">none</td>
  367. <td style="border: 5px outset purple">outset purple</td>
  368. <td style="border: 0px none black">none</td>
  369. <td style="border: 5px groove pink">groove pink</td>
  370. <td style="border: 0px none black">none</td>
  371. <td style="border: 5px ridge blue">ridge blue</td>
  372. </tr>
  373. </table>
  374. <table style="border: 5px double red; border-collapse: separate;">
  375. <tr>
  376. <td style="border: 5px solid orange">solid orange</td>
  377. <td style="border: 0px none black">none</td>
  378. <td style="border: 5px double red">double red</td>
  379. <td style="border: 0px none black">none</td>
  380. <td style="border: 5px inset gray">inset gray</td>
  381. <td style="border: 0px none black">none</td>
  382. <td style="border: 5px outset purple">outset purple</td>
  383. <td style="border: 0px none black">none</td>
  384. <td style="border: 5px groove pink">groove pink</td>
  385. <td style="border: 0px none black">none</td>
  386. <td style="border: 5px ridge blue">ridge blue</td>
  387. </tr>
  388. </table>
  389. </body>
  390. </html>
  391. ';
  392. //==============================================================
  393. //==============================================================
  394. //==============================================================
  395. include("../mpdf.php");
  396. $mpdf=new mPDF('en-GB-x','A4','','',10,10,10,10,6,3);
  397. $mpdf->SetDisplayMode('fullpage');
  398. $mpdf->list_indent_first_level = 0; // 1 or 0 - whether to indent the first level of a list
  399. // LOAD a stylesheet
  400. $stylesheet = file_get_contents('mpdfstyletables.css');
  401. $mpdf->WriteHTML($stylesheet,1); // The parameter 1 tells that this is css/style only and no body/html/text
  402. $mpdf->WriteHTML($html);
  403. $mpdf->Output();
  404. exit;
  405. //==============================================================
  406. //==============================================================
  407. //==============================================================
  408. ?>