user-input.js 723 B

123456789101112131415161718192021222324252627
  1. var name = prompt('What is your name?');
  2. var multiplier = parseInt(prompt('Enter a number:'));
  3. var doc = new jsPDF();
  4. doc.setFontSize(22);
  5. doc.text(20, 20, 'Questions');
  6. doc.setFontSize(16);
  7. doc.text(20, 30, 'This belongs to: ' + name);
  8. for(var i = 1; i <= 12; i ++) {
  9. doc.text(20, 30 + (i * 10), i + ' x ' + multiplier + ' = ___');
  10. }
  11. doc.addPage();
  12. doc.setFontSize(22);
  13. doc.text(20, 20, 'Answers');
  14. doc.setFontSize(16);
  15. for(var i = 1; i <= 12; i ++) {
  16. doc.text(20, 30 + (i * 10), i + ' x ' + multiplier + ' = ' + (i * multiplier));
  17. }
  18. // You wouldn't normally call this - this is just to make the
  19. // demo not look broken as we've disabled auto update.
  20. if (jsPDFEditor !== undefined) {
  21. jsPDFEditor.update(true);
  22. }