test_from_html_css_page_breaks.html 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <!doctype html>
  2. <!--
  3. /**
  4. * jsPDF Test HTML PlugIn
  5. * Copyright (c) 2014 Steven Spungin (TwelveTone LLC) steven@twelvetone.tv
  6. *
  7. * Licensed under the MIT License.
  8. * http://opensource.org/licenses/mit-license
  9. */
  10. -->
  11. <html>
  12. <head>
  13. <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  14. <title>Test HTML</title>
  15. <script src='../libs/require/require.js'></script>
  16. <script>
  17. require_baseUrl_override = '../';
  18. require(['../libs/require/config'], function(){
  19. require(['test/test_harness', 'plugins/from_html'], function(){
  20. var pdf = new jsPDF('p', 'pt', 'letter');
  21. var ta = document.getElementById('textarea');
  22. pdf.fromHTML(ta.value, 0, 0);
  23. ta.onkeyup = function(){
  24. var pdf = new jsPDF('p', 'pt', 'letter');
  25. pdf.fromHTML(ta.value, 0, 0);
  26. harness.setPdf(pdf);
  27. }
  28. ta.onkeyup = function(){
  29. var pdf = new jsPDF('p', 'pt', 'letter');
  30. pdf.fromHTML(ta.value, 0, 0);
  31. harness.setPdf(pdf);
  32. }
  33. var harness = pdf_test_harness_init(pdf);
  34. harness.header.style.left='300px';
  35. harness.body.style.left='300px';
  36. }); //require
  37. }); //require
  38. </script>
  39. <script>
  40. pdf_test_harness.onload = function(harness) {
  41. }
  42. </script>
  43. </head>
  44. <body style='background-color: silver; margin: 0;'>
  45. <textarea id='textarea' style='position:fixed;left:0;width:290px;height:100%'>
  46. <html>
  47. <head>
  48. <style>
  49. .break{
  50. page-break-before:always;
  51. }
  52. body{
  53. font-size:2em;
  54. }
  55. </style>
  56. </head>
  57. <body>
  58. <div>page 1 <em>ok?</em></div>
  59. <div class='break'>page 2</div>
  60. <div class='break' style='margin-top:1in'>page 3</div>
  61. </body>
  62. </html>
  63. </textarea>
  64. </body>
  65. </html>