examples.html 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. <!DOCTYPE html>
  2. <html>
  3. <head lang="en">
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width">
  6. <!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pure/0.6.0/pure-min.css">-->
  7. <link rel="stylesheet" href="libs/pure-min.css">
  8. <!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pure/0.6.0/grids-responsive-min.css">-->
  9. <link rel="stylesheet" href="libs/grids-responsive-min.css">
  10. <title>AutoTable sample</title>
  11. <style>
  12. * {
  13. box-sizing: border-box;
  14. }
  15. html, body {
  16. height: 100%;
  17. overflow: hidden;
  18. }
  19. .navbar {
  20. position: absolute;
  21. top: 0;
  22. left: 0;
  23. right: 0;
  24. background: #e74c3c;
  25. border-bottom: 5px solid #c0392b;
  26. height: 50px;
  27. white-space: nowrap;
  28. overflow-x: auto;
  29. overflow-y: hidden;
  30. padding: 0 10px;
  31. }
  32. .navbar h1 {
  33. font-size: 20px;
  34. color: #fff;
  35. }
  36. .menu {
  37. padding: 0;
  38. list-style: none;
  39. }
  40. .menu li {
  41. vertical-align: top;
  42. }
  43. .menu li a {
  44. text-decoration: none;
  45. color: #fff;
  46. font-weight: bold;
  47. font-family: sans-serif;
  48. padding: 10px 0;
  49. line-height: 25px;
  50. }
  51. .menu li a:hover {
  52. font-style: italic;
  53. }
  54. #panel {
  55. background: #141f2b;
  56. padding: 10px;
  57. height: 100%;
  58. }
  59. #panel .editor {
  60. background: #fff;
  61. }
  62. #wrapper {
  63. overflow: hidden;
  64. height: 100%;
  65. background: rgba(193, 193, 193, 1);
  66. }
  67. #output {
  68. width: 100%;
  69. height: 100%;
  70. background: rgba(193, 193, 193, 1);
  71. }
  72. </style>
  73. </head>
  74. <body>
  75. <header class="navbar">
  76. <h1>
  77. AutoTable - Generate PDF tables and lists (jsPDF plugin)
  78. <!--<iframe style="display: inline; vertical-align: middle; margin-left: 10px;"
  79. src="https://ghbtns.com/github-btn.html?user=simonbengtsson&repo=jsPDF-AutoTable&type=star&count=true&size=medium"
  80. frameborder="0" scrolling="0" width="160px" height="20px"></iframe>-->
  81. </h1>
  82. </header>
  83. <div class="pure-g" style="padding-top: 50px; height: 100%;">
  84. <div id="panel" class="pure-u-1 pure-u-md-1-5">
  85. <ul class="menu">
  86. <li><a href="#">Default</a></li>
  87. <li><a href="#minimal">Minimal</a></li>
  88. <li><a href="#long">Long text</a></li>
  89. <li><a href="#content">With content</a></li>
  90. <li><a href="#multiple">Multiple tables</a></li>
  91. <li><a href="#html">From html</a></li>
  92. <li><a href="#header-footer">Header and footer</a></li>
  93. <li><a href="#horizontal">Horizontal headers</a></li>
  94. <li><a href="#spans">Rowspan and colspan</a></li>
  95. <li><a href="#themes">Themes</a></li>
  96. <li><a href="#custom">Custom style</a></li>
  97. </ul>
  98. <button id="download-btn" class="pure-button">Download PDF</button>
  99. <!--<div class="editor">
  100. <pre><code class="javascript">var test = "hey!";</code></pre></div>-->
  101. </div>
  102. <div id="wrapper" class="pure-u-1 pure-u-md-4-5">
  103. <iframe id="output"></iframe>
  104. </div>
  105. </div>
  106. <table id="basic-table" style="display: none;">
  107. <thead>
  108. <tr>
  109. <th>ID</th>
  110. <th>First name</th>
  111. <th>Last name</th>
  112. <th>Email</th>
  113. <th>Country</th>
  114. <th>IP-address</th>
  115. </tr>
  116. </thead>
  117. <tbody>
  118. <tr>
  119. <td>1</td>
  120. <td>Donna</td>
  121. <td>Moore</td>
  122. <td>dmoore0@furl.net</td>
  123. <td>China</td>
  124. <td>211.56.242.221</td>
  125. </tr>
  126. <tr>
  127. <td>2</td>
  128. <td>Janice</td>
  129. <td>Henry</td>
  130. <td>jhenry1@theatlantic.com</td>
  131. <td>Ukraine</td>
  132. <td>38.36.7.199</td>
  133. </tr>
  134. <tr>
  135. <td>3</td>
  136. <td>Ruth</td>
  137. <td>Wells</td>
  138. <td>rwells2@constantcontact.com</td>
  139. <td>Trinidad and Tobago</td>
  140. <td>19.162.133.184</td>
  141. </tr>
  142. <tr>
  143. <td>4</td>
  144. <td>Jason</td>
  145. <td>Ray</td>
  146. <td>jray3@psu.edu</td>
  147. <td>Brazil</td>
  148. <td>10.68.11.42</td>
  149. </tr>
  150. <tr>
  151. <td>5</td>
  152. <td>Jane</td>
  153. <td>Stephens</td>
  154. <td>jstephens4@go.com</td>
  155. <td>United States</td>
  156. <td>47.32.129.71</td>
  157. </tr>
  158. <tr>
  159. <td>6</td>
  160. <td>Adam</td>
  161. <td>Nichols</td>
  162. <td>anichols5@com.com</td>
  163. <td>Canada</td>
  164. <td>18.186.38.37</td>
  165. </tr>
  166. </tbody>
  167. </table>
  168. <!-- All major versions (0.9, 1.0 and 1.1) should work. In my experience 1.0 is the best one right now, but
  169. <!-- for extended IE support 0.9 would probably be the easiest to use. 1.1 is a bit buggy as of 26th of June 2015.
  170. <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.1.135/jspdf.min.js"></script>-->
  171. <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.0.272/jspdf.debug.js"></script>-->
  172. <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/0.9.0/jspdf.min.js"></script>-->
  173. <script src="libs/jspdf.min.js"></script>-->
  174. <script src="../dist/jspdf.plugin.autotable.js"></script>
  175. <!--<script src="https://cdn.jsdelivr.net/faker.js/2.1.5/faker.min.js"></script>-->
  176. <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.6/highlight.min.js"></script>-->
  177. <script src="libs/faker.min.js"></script>
  178. <script src="examples.js"></script>
  179. <!-- Some scripts to make the examples work nicely -->
  180. <script>
  181. //hljs.initHighlightingOnLoad();
  182. window.onhashchange = function () {
  183. update();
  184. };
  185. document.getElementById('download-btn').onclick = function () {
  186. update(true);
  187. };
  188. function update(shouldDownload) {
  189. shouldDownload = shouldDownload || false;
  190. var funcStr = window.location.hash.replace(/#/g, '');
  191. var example = examples[funcStr], doc = null;
  192. if (typeof example === 'function') {
  193. doc = example();
  194. } else {
  195. doc = examples.auto();
  196. }
  197. if (shouldDownload) {
  198. doc.save('table.pdf');
  199. } else {
  200. document.getElementById("output").src = doc.output('datauristring');
  201. }
  202. }
  203. update();
  204. </script>
  205. </body>
  206. </html>