test_annotation.html 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. </head>
  16. <body style='background-color: silver; margin: 0;'>
  17. <script src="../../dist/jspdf.debug.js"></script>
  18. <script src="../js/test_harness.js"></script>
  19. <script>
  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, {
  59. url: 'https://parall.ax/'
  60. });
  61. y += pdf.getLineHeight();
  62. }
  63. var message = 'Chrome default PDF reader currently does not support magFactor links, \
  64. although links still work after manualy changing magFactor. <br /> \
  65. Firefox has a bug displaying annotations after the magFactor changes, but links do work. <br /> \
  66. To test magFactor links [...] without bugs, use Adobe Reader or compatible application.';
  67. pdf_test_harness_init(pdf, message);
  68. </script>
  69. </body>
  70. </html>