components_tests.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. $(document).ready(function(){
  2. var getDocument = function(){
  3. var doc = new jsPDF()
  4. doc.text(20, 20, 'Hello world!')
  5. doc.text(20, 30, 'This is client-side Javascript, pumping out a PDF.')
  6. doc.addPage()
  7. doc.text(20, 20, 'Do you like that?')
  8. doc.setFontSize(22)
  9. doc.text(20, 20, 'This is a title')
  10. doc.setFontSize(16)
  11. doc.text(20, 30, 'This is some normal sized text underneath.');
  12. doc.text(20, 20, 'This is the default font.')
  13. doc.setFont("courier")
  14. doc.setFontType("normal")
  15. doc.text(20, 30, 'This is courier normal.')
  16. doc.setFont("times")
  17. doc.setFontType("italic")
  18. doc.text(20, 40, 'This is times italic.')
  19. doc.setFont("helvetica")
  20. doc.setFontType("bold")
  21. doc.text(20, 50, 'This is helvetica bold.')
  22. doc.setFont("courier")
  23. doc.setFontType("bolditalic")
  24. doc.text(20, 60, 'This is courier bolditalic.')
  25. doc.setTextColor(100)
  26. doc.text(20, 20, 'This is gray.')
  27. doc.setTextColor(150)
  28. doc.text(20, 30, 'This is light gray.')
  29. doc.setTextColor(255,0,0)
  30. doc.text(20, 40, 'This is red.')
  31. doc.setTextColor(0,255,0)
  32. doc.text(20, 50, 'This is green.')
  33. doc.setTextColor(0,0,255)
  34. doc.text(20, 60, 'This is blue.')
  35. // Optional - set properties on the document
  36. doc.setProperties({
  37. title: 'Title',
  38. subject: 'This is the subject',
  39. author: 'James Hall',
  40. keywords: 'generated, javascript, web 2.0, ajax',
  41. creator: 'MEEE'
  42. })
  43. doc.rect(20, 20, 10, 10); // empty square
  44. doc.rect(40, 20, 10, 10, 'F') // filled square
  45. doc.setDrawColor(255,0,0)
  46. doc.rect(60, 20, 10, 10); // empty red square
  47. doc.setDrawColor(255,0,0)
  48. doc.rect(80, 20, 10, 10, 'FD') // filled square with red borders
  49. doc.setDrawColor(0)
  50. doc.setFillColor(255,0,0)
  51. doc.rect(100, 20, 10, 10, 'F') // filled red square
  52. doc.setDrawColor(0)
  53. doc.setFillColor(255,0,0)
  54. doc.rect(120, 20, 10, 10, 'FD') // filled red square with black borders
  55. doc.line(20, 20, 60, 20) // horizontal line
  56. doc.setLineWidth(0.5)
  57. doc.line(20, 25, 60, 25)
  58. doc.setLineWidth(1)
  59. doc.line(20, 30, 60, 30)
  60. doc.setLineWidth(1.5)
  61. doc.line(20, 35, 60, 35)
  62. doc.setDrawColor(255,0,0) // draw red lines
  63. doc.setLineWidth(0.1)
  64. doc.line(100, 20, 100, 60) // vertical line
  65. doc.setLineWidth(0.5)
  66. doc.line(105, 20, 105, 60)
  67. doc.setLineWidth(1)
  68. doc.line(110, 20, 110, 60)
  69. doc.setLineWidth(1.5)
  70. doc.line(115, 20, 115, 60)
  71. doc.ellipse(40, 20, 10, 5)
  72. doc.setFillColor(0,0,255)
  73. doc.ellipse(80, 20, 10, 5, 'F')
  74. doc.setLineWidth(1)
  75. doc.setDrawColor(0)
  76. doc.setFillColor(255,0,0)
  77. doc.circle(120, 20, 5, 'FD')
  78. , text = [
  79. 'This is line one'
  80. , 'This is line two'
  81. , 'This is line three'
  82. , 'This is line four'
  83. , 'This is line five'
  84. ]
  85. doc.text(20, 20, text)
  86. return doc.output()
  87. }
  88. test('compare_native_software_base64', function() {
  89. var text = getDocument()
  90. QUnit.expect(1)
  91. QUnit.equal(
  92. base64_encode_with_native_fallback(text)
  93. , base64_encode(text)
  94. )
  95. })
  96. }) // end of document.ready(