test_annotation.html 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <!doctype html>
  2. <!--
  3. /**
  4. * jsPDF Annotations 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>Annotation Test</title>
  15. <script src='../../libs/require/require.js'></script>
  16. <script>
  17. require_baseUrl_override = '../../';
  18. require(['../../libs/require/config'], function(){
  19. require(['plugins/annotations', 'examples/js/test_harness'], function(){
  20. var pdf = new jsPDF('p', 'pt', 'letter');
  21. // Create pages with a table of contents.
  22. // TOC links to each page
  23. // Each page links back to TOC and to an external URL
  24. // Supported magnification Options are included.
  25. var y = 20;
  26. var text = 'Table of Contents';
  27. pdf.text(text, 20, y);
  28. y += pdf.getLineHeight() * 2;
  29. for (var i=2; i<10; i++){
  30. text = "Page " + i;
  31. pdf.textWithLink(text, 20, y, {pageNumber:i});
  32. y += pdf.getLineHeight();
  33. var x = 20;
  34. var width = pdf.textWithLink(" [100%]", x, y, {pageNumber:i, magFactor:'XYZ', zoom:1});
  35. x += width;
  36. var width = pdf.textWithLink(" [200%]", x, y, {pageNumber:i, magFactor:'XYZ', zoom:2});
  37. x += width;
  38. var width = pdf.textWithLink(" [50%]", x, y, {pageNumber:i, magFactor:'XYZ', zoom:.5});
  39. x += width;
  40. var width = pdf.textWithLink(" [Fit]", x, y, {pageNumber:i, magFactor:'Fit'});
  41. x += width;
  42. var width = pdf.textWithLink(" [FitH]", x, y, {pageNumber:i, magFactor:'FitH'});
  43. x += width;
  44. var width = pdf.textWithLink(" [FitV]", x, y, {pageNumber:i, magFactor:'FitV'});
  45. y += pdf.getLineHeight();
  46. }
  47. // Create Test Pages
  48. for (var i=2; i<10; i++){
  49. pdf.addPage();
  50. y = 20;
  51. var text = 'Page ' + i;
  52. pdf.text(text, 20, y);
  53. y += pdf.getLineHeight() * 2;
  54. text = "Goto First Page";
  55. pdf.textWithLink(text, 20, y, {pageNumber:1});
  56. y += pdf.getLineHeight();
  57. text = "Goto External URL";
  58. pdf.textWithLink(text, 20, y, {url:'http://www.twelvetone.tv'});
  59. y += pdf.getLineHeight();
  60. }
  61. var message = 'Chrome default PDF reader currently does not support magFactor links, \
  62. although links still work after manualy changing magFactor. <br /> \
  63. Firefox has a bug displaying annotations after the magFactor changes, but links do work. <br /> \
  64. To test magFactor links [...] without bugs, use Adobe Reader or compatible application.';
  65. pdf_test_harness_init(pdf, message);
  66. }); // require
  67. }); // require
  68. </script>
  69. </head>
  70. <body style='background-color: silver; margin: 0;'>
  71. </body>
  72. </html>