tables.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Html2Pdf</title>
  5. <link rel="stylesheet" type="text/css" href="examples.css">
  6. <style>
  7. table {
  8. margin-bottom: 1em;
  9. }
  10. table td {
  11. padding: 3px;
  12. }
  13. .table1 {
  14. border: 1px solid red;
  15. }
  16. .table2,.table2 td {
  17. border: 1px solid silver;
  18. border-collapse: collapse;
  19. }
  20. .table2 td:first-child {
  21. background-color: lightblue;
  22. }
  23. .CSSTableGenerator {
  24. margin: 0px;
  25. padding: 0px;
  26. width: 100%;
  27. box-shadow: 10px 10px 5px #888888;
  28. border: 1px solid #000000;
  29. -moz-border-radius-bottomleft: 0px;
  30. -webkit-border-bottom-left-radius: 0px;
  31. border-bottom-left-radius: 0px;
  32. -moz-border-radius-bottomright: 0px;
  33. -webkit-border-bottom-right-radius: 0px;
  34. border-bottom-right-radius: 0px;
  35. -moz-border-radius-topright: 0px;
  36. -webkit-border-top-right-radius: 0px;
  37. border-top-right-radius: 0px;
  38. -moz-border-radius-topleft: 0px;
  39. -webkit-border-top-left-radius: 0px;
  40. border-top-left-radius: 0px;
  41. }
  42. .CSSTableGenerator table {
  43. border-collapse: collapse;
  44. border-spacing: 0;
  45. width: 100%;
  46. height: 100%;
  47. margin: 0px;
  48. padding: 0px;
  49. }
  50. .CSSTableGenerator tr:last-child td:last-child {
  51. -moz-border-radius-bottomright: 0px;
  52. -webkit-border-bottom-right-radius: 0px;
  53. border-bottom-right-radius: 0px;
  54. }
  55. .CSSTableGenerator table tr:first-child td:first-child {
  56. -moz-border-radius-topleft: 0px;
  57. -webkit-border-top-left-radius: 0px;
  58. border-top-left-radius: 0px;
  59. }
  60. .CSSTableGenerator table tr:first-child td:last-child {
  61. -moz-border-radius-topright: 0px;
  62. -webkit-border-top-right-radius: 0px;
  63. border-top-right-radius: 0px;
  64. }
  65. .CSSTableGenerator tr:last-child td:first-child {
  66. -moz-border-radius-bottomleft: 0px;
  67. -webkit-border-bottom-left-radius: 0px;
  68. border-bottom-left-radius: 0px;
  69. }
  70. .CSSTableGenerator tr:hover td {
  71. }
  72. .CSSTableGenerator tr:nth-child(odd) {
  73. background-color: #ffaa56;
  74. }
  75. .CSSTableGenerator tr:nth-child(even) {
  76. background-color: #ffffff;
  77. }
  78. .CSSTableGenerator td {
  79. vertical-align: middle;
  80. border: 1px solid #000000;
  81. border-width: 0px 1px 1px 0px;
  82. text-align: left;
  83. padding: 7px;
  84. font-size: 10px;
  85. font-family: Arial;
  86. font-weight: normal;
  87. color: #000000;
  88. }
  89. .CSSTableGenerator tr:last-child td {
  90. border-width: 0px 1px 0px 0px;
  91. }
  92. .CSSTableGenerator tr td:last-child {
  93. border-width: 0px 0px 1px 0px;
  94. }
  95. .CSSTableGenerator tr:last-child td:last-child {
  96. border-width: 0px 0px 0px 0px;
  97. }
  98. .CSSTableGenerator tr:first-child td {
  99. background: -o-linear-gradient(bottom, #ff7f00 5%, #bf5f00 100%);
  100. background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ff7f00), color-stop(1, #bf5f00));
  101. background: -moz-linear-gradient(center top, #ff7f00 5%, #bf5f00 100%);
  102. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ff7f00", endColorstr="#bf5f00");
  103. background: -o-linear-gradient(top, #ff7f00, bf5f00);
  104. background-color: #ff7f00;
  105. border: 0px solid #000000;
  106. text-align: center;
  107. border-width: 0px 0px 1px 1px;
  108. font-size: 14px;
  109. font-family: Arial;
  110. font-weight: bold;
  111. color: #ffffff;
  112. }
  113. .CSSTableGenerator tr:first-child:hover td {
  114. background: -o-linear-gradient(bottom, #ff7f00 5%, #bf5f00 100%);
  115. background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ff7f00), color-stop(1, #bf5f00));
  116. background: -moz-linear-gradient(center top, #ff7f00 5%, #bf5f00 100%);
  117. filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#ff7f00", endColorstr="#bf5f00");
  118. background: -o-linear-gradient(top, #ff7f00, bf5f00);
  119. background-color: #ff7f00;
  120. }
  121. .CSSTableGenerator tr:first-child td:first-child {
  122. border-width: 0px 0px 1px 0px;
  123. }
  124. .CSSTableGenerator tr:first-child td:last-child {
  125. border-width: 0px 0px 1px 1px;
  126. }
  127. </style>
  128. </head>
  129. <body>
  130. <div style='position: absolute'>
  131. <h1>Tables</h1>
  132. <table class='table1'>
  133. <tr>
  134. <td>Item</td>
  135. <td>Cost</td>
  136. <td>Description</td>
  137. <td>Available</td>
  138. </tr>
  139. <tr>
  140. <td>Milk</td>
  141. <td>$1.00</td>
  142. <td>Hello PDF World</td>
  143. <td>Out Of Stock</td>
  144. </tr>
  145. <tr>
  146. <td>Milk</td>
  147. <td>$1.00</td>
  148. <td>Hello PDF World</td>
  149. <td>Out Of Stock</td>
  150. </tr>
  151. </table>
  152. <table class='table2'>
  153. <tr>
  154. <td>Item</td>
  155. <td>Cost</td>
  156. <td>Description</td>
  157. <td>Available</td>
  158. </tr>
  159. <tr>
  160. <td>Milk</td>
  161. <td>$1.00</td>
  162. <td>Hello PDF World</td>
  163. <td>Out Of Stock</td>
  164. </tr>
  165. <tr>
  166. <td>Milk</td>
  167. <td>$1.00</td>
  168. <td>Hello PDF World</td>
  169. <td>Out Of Stock</td>
  170. </tr>
  171. </table>
  172. <table class='CSSTableGenerator'>
  173. <tr>
  174. <td>Item</td>
  175. <td>Cost</td>
  176. <td>Description</td>
  177. <td>Available</td>
  178. </tr>
  179. <tr>
  180. <td>Milk</td>
  181. <td>$1.00</td>
  182. <td>Hello PDF World</td>
  183. <td>Out Of Stock</td>
  184. </tr>
  185. <tr>
  186. <td>Milk</td>
  187. <td>$1.00</td>
  188. <td>Hello PDF World</td>
  189. <td>Out Of Stock</td>
  190. </tr>
  191. </table>
  192. </div>
  193. <script src='../../dist/jspdf.debug.js'></script>
  194. <script src='../../libs/html2pdf.js'></script>
  195. <script>
  196. var pdf = new jsPDF('p', 'pt', 'letter');
  197. var canvas = pdf.canvas;
  198. canvas.height = 72 * 11;
  199. canvas.width=72 * 8.5;;
  200. // var width = 400;
  201. html2pdf(document.body, pdf, function(pdf) {
  202. var iframe = document.createElement('iframe');
  203. iframe.setAttribute('style','position:absolute;right:0; top:0; bottom:0; height:100%; width:500px');
  204. document.body.appendChild(iframe);
  205. iframe.src = pdf.output('datauristring');
  206. //var div = document.createElement('pre');
  207. //div.innerText=pdf.output();
  208. //document.body.appendChild(div);
  209. }
  210. );
  211. </script>
  212. </body>
  213. </html>