test_from_html.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. var harness = pdf_test_harness_init(pdf);
  29. harness.header.style.left='50%';
  30. harness.body.style.left='50%';
  31. }); //require
  32. }); //require
  33. </script>
  34. </head>
  35. <body style='background-color: silver; margin: 0;'>
  36. <textarea id='textarea' style='position: fixed; width: 50%; height: 100%'>
  37. <html>
  38. <head>
  39. <style>
  40. .important {
  41. color: darkred;
  42. font-size: 10em;
  43. }
  44. </style>
  45. </head>
  46. <body>
  47. <div>black</div>
  48. <div>black (should not have color parameter in PDF source)</div>
  49. <div style='color: red; font-size: 30px'>hello</div>
  50. <div style='color: rgb(0, 255, 0); font-size: 30px'>hello</div>
  51. <div style='color: #0000FF; font-size: 30px'>hello</div>
  52. <div class='important'>hello</div>
  53. <div>black</div>
  54. <div>black (should not have color parameter in PDF source)</div>
  55. </body>
  56. </html>
  57. </textarea>
  58. </body>
  59. </html>