From 21298359e6fe6eec9a4083f8ed8c23e88338b5ff Mon Sep 17 00:00:00 2001 From: Thomas Felber Date: Fri, 10 Apr 2015 05:23:28 -0700 Subject: added html, css, js --- .../main/webapp/assets/js/jspdf/examples/basic.htm | 201 +++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 pdf-as-web/src/main/webapp/assets/js/jspdf/examples/basic.htm (limited to 'pdf-as-web/src/main/webapp/assets/js/jspdf/examples/basic.htm') diff --git a/pdf-as-web/src/main/webapp/assets/js/jspdf/examples/basic.htm b/pdf-as-web/src/main/webapp/assets/js/jspdf/examples/basic.htm new file mode 100644 index 00000000..dea59adf --- /dev/null +++ b/pdf-as-web/src/main/webapp/assets/js/jspdf/examples/basic.htm @@ -0,0 +1,201 @@ + + + + jsPDF + + + + + + + + +

jsPDF Demos

+ +

Examples for using jsPDF with Data URIs below. Go back to project homepage.

+ +

Simple Two-page Text Document

+
var doc = new jsPDF();
+doc.text(20, 20, 'Hello world!');
+doc.text(20, 30, 'This is client-side Javascript, pumping out a PDF.');
+doc.addPage();
+doc.text(20, 20, 'Do you like that?');
+
+// Output as Data URI
+doc.output('datauri');
+Run Code + +

Different font sizes

+
var doc = new jsPDF();
+doc.setFontSize(22);
+doc.text(20, 20, 'This is a title');
+
+doc.setFontSize(16);
+doc.text(20, 30, 'This is some normal sized text underneath.');	
+
+// Output as Data URI
+doc.output('datauri');
+Run Code + + +

Adding metadata

+
var doc = new jsPDF();
+doc.text(20, 20, 'This PDF has a title, subject, author, keywords and a creator.');
+
+// Optional - set properties on the document
+doc.setProperties({
+	title: 'Title',
+	subject: 'This is the subject',		
+	author: 'James Hall',
+	keywords: 'generated, javascript, web 2.0, ajax',
+	creator: 'MEEE'
+});
+
+// Output as Data URI
+doc.output('datauri');
+Run Code + + +

Example of user input

+
var name = prompt('What is your name?');
+var multiplier = prompt('Enter a number:');
+multiplier = parseInt(multiplier);
+
+var doc = new jsPDF();
+doc.setFontSize(22);	
+doc.text(20, 20, 'Questions');
+doc.setFontSize(16);
+doc.text(20, 30, 'This belongs to: ' + name);
+
+for(var i = 1; i <= 12; i ++) {
+	doc.text(20, 30 + (i * 10), i + ' x ' + multiplier + ' = ___');
+}
+
+doc.addPage();
+doc.setFontSize(22);
+doc.text(20, 20, 'Answers');
+doc.setFontSize(16);
+
+for(var i = 1; i <= 12; i ++) {
+	doc.text(20, 30 + (i * 10), i + ' x ' + multiplier + ' = ' + (i * multiplier));
+}	
+doc.output('datauri');
+Run Code + + + + + + + + + + \ No newline at end of file -- cgit v1.2.3