Skip to content
Browse files

Update docs, change all examples to use new .save() API

  • Loading branch information...
1 parent d9adb08 commit b8b88a7fc4ab4ffe15b86fa75d9db68b6ed875b4 @MrRio committed Dec 29, 2012
Showing with 34 additions and 46 deletions.
  1. +16 −22 examples/basic.html
  2. +18 −24 examples/js/basic.js
View
38 examples/basic.html
@@ -8,6 +8,9 @@
<script type="text/javascript" src="js/jquery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js/jquery/jquery-ui-1.8.17.custom.min.js"></script>
<script type="text/javascript" src="../jspdf.js"></script>
+ <script type="text/javascript" src="../libs/FileSaver.js/FileSaver.js"></script>
+ <script type="text/javascript" src="../libs/BlobBuilder.js/BlobBuilder.js"></script>
+
<script type="text/javascript" src="../jspdf.plugin.standard_fonts_metrics.js"></script>
<script type="text/javascript" src="../jspdf.plugin.split_text_to_size.js"></script>
<script type="text/javascript" src="../jspdf.plugin.from_html.js"></script>
@@ -51,16 +54,14 @@
doc.addPage();
doc.text(20, 20, 'Do you like that?');
-// Output as Data URI
-doc.output('datauri');</pre>
+doc.save('Test.pdf');</pre>
<a href="javascript:demoTwoPageDocument()" class="button">Run Code</a></p></div>
<h2><a href="#">Landscape document</a></h2>
<div><p><pre>var doc = new jsPDF('landscape');
doc.text(20, 20, 'Hello landscape world!');
-// Output as Data URI
-doc.output('datauri');</pre>
+doc.save('Test.pdf');</pre>
<a href="javascript:demoLandscape()" class="button">Run Code</a></p></div>
<h2><a href="#">Adding metadata</a></h2>
@@ -77,7 +78,7 @@
});
// Output as Data URI
-doc.output('datauri');</pre>
+doc.save('Test.pdf');</pre>
<a href="javascript:demoMetadata()" class="button">Run Code</a></p></div>
<h2><a href="#">Example of user input</a></h2>
@@ -103,7 +104,7 @@
for(var i = 1; i <= 12; i ++) {
doc.text(20, 30 + (i * 10), i + ' x ' + multiplier + ' = ' + (i * multiplier));
}
-doc.output('datauri');</pre>
+doc.save('Test.pdf');</pre>
<a href="javascript:demoUserInput()" class="button">Run Code</a></p></div>
</div>
</div>
@@ -119,8 +120,7 @@
doc.setFontSize(16);
doc.text(20, 30, 'This is some normal sized text underneath.');
-// Output as Data URI
-doc.output('datauri');</pre>
+doc.save('Test.pdf');</pre>
<a href="javascript:demoFontSizes()" class="button">Run Code</a>
</p></div>
@@ -144,8 +144,7 @@
doc.setFontType("bolditalic");
doc.text(20, 60, 'This is courier bolditalic.');
-// Output as Data URI
-doc.output('datauri');</pre>
+doc.save('Test.pdf');</pre>
<a href="javascript:demoFontTypes()" class="button">Run Code</a></p></div>
<h2><a href="#">Different text colors</a></h2>
@@ -166,8 +165,7 @@
doc.setTextColor(0,0,255);
doc.text(20, 60, 'This is blue.');
-// Output as Data URI
-doc.output('datauri');</pre>
+doc.save('Test.pdf');</pre>
<a href="javascript:demoTextColors()" class="button">Run Code</a></p></div>
<h2><a href="#">Font-metrics-based line sizing and split</a></h2>
@@ -203,7 +201,7 @@
}
}
-pdf.output('dataurl')</pre>
+pdf.save('Test.pdf');</pre>
<a href="javascript:demoStringSplitting()" class="button">Run Code</a></p></div>
<h2><a href="#">fromHTML plugin</a></h2>
@@ -252,7 +250,7 @@ <h2 style="font-size:120%">Header Two</h2>
}
)
-pdf.output()</pre>
+pdf.save('Test.pdf');</pre>
<a href="javascript:demoFromHTML()" class="button">Run Code</a></p></div></div>
</div>
@@ -282,8 +280,7 @@ <h2 style="font-size:120%">Header Two</h2>
doc.setFillColor(255,0,0);
doc.rect(120, 20, 10, 10, 'FD'); // filled red square with black borders
-// Output as Data URI
-doc.output('datauri');</pre>
+doc.save('Test.pdf');</pre>
<a href="javascript:demoRectangles()" class="button">Run Code</a></p></div>
<h2><a href="#">Draw example: lines</a></h2>
@@ -314,8 +311,7 @@ <h2 style="font-size:120%">Header Two</h2>
doc.setLineWidth(1.5);
doc.line(115, 20, 115, 60);
-// Output as Data URI
-doc.output('datauri');</pre>
+doc.save('Test.pdf');</pre>
<a href="javascript:demoLines()" class="button">Run Code</a></p></div>
<h2><a href="#">Draw example: circles and ellipses</a></h2>
@@ -331,8 +327,7 @@ <h2 style="font-size:120%">Header Two</h2>
doc.setFillColor(255,0,0);
doc.circle(120, 20, 5, 'FD');
-// Output as Data URI
-doc.output('datauri');</pre>
+doc.save('Test.pdf');</pre>
<a href="javascript:demoCircles()" class="button">Run Code</a></p></div>
<h2><a href="#">Draw example: triangles</a></h2>
@@ -345,8 +340,7 @@ <h2 style="font-size:120%">Header Two</h2>
doc.setFillColor(0,0,255);
doc.triangle(100, 100, 110, 100, 120, 130, 'FD');
-// Output as Data URI
-doc.output('datauri');</pre>
+doc.save('My file.pdf');</pre>
<a href="javascript:demoTriangles()" class="button">Run Code</a></p></div>
<h2><a href="#">Draw example: Images</a></h2>
View
42 examples/js/basic.js
@@ -5,16 +5,16 @@ function demoTwoPageDocument() {
doc.addPage();
doc.text(20, 20, 'Do you like that?');
- // Output as Data URI
- doc.output('datauri');
+ // Save the PDF
+ doc.save('Test.pdf');
}
function demoLandscape() {
var doc = new jsPDF('landscape');
doc.text(20, 20, 'Hello landscape world!');
- // Output as Data URI
- doc.output('datauri');
+ // Save the PDF
+ doc.save('Test.pdf');
}
function demoFontSizes() {
@@ -23,10 +23,9 @@ function demoFontSizes() {
doc.text(20, 20, 'This is a title');
doc.setFontSize(16);
- doc.text(20, 30, 'This is some normal sized text underneath.');
+ doc.text(20, 30, 'This is some normal sized text underneath.');
- // Output as Data URI
- doc.output('datauri');
+ doc.save('Test.pdf');
}
function demoFontTypes() {
@@ -50,8 +49,7 @@ function demoFontTypes() {
doc.setFontType("bolditalic");
doc.text(20, 60, 'This is courier bolditalic.');
- // Output as Data URI
- doc.output('datauri');
+ doc.save('Test.pdf');
}
function demoTextColors() {
@@ -61,7 +59,7 @@ function demoTextColors() {
doc.text(20, 20, 'This is gray.');
doc.setTextColor(150);
- doc.text(20, 30, 'This is light gray.');
+ doc.text(20, 30, 'This is light gray.');
doc.setTextColor(255,0,0);
doc.text(20, 40, 'This is red.');
@@ -83,14 +81,13 @@ function demoMetadata() {
// Optional - set properties on the document
doc.setProperties({
title: 'Title',
- subject: 'This is the subject',
+ subject: 'This is the subject',
author: 'James Hall',
keywords: 'generated, javascript, web 2.0, ajax',
creator: 'MEEE'
});
- // Output as Data URI
- doc.output('datauri');
+ doc.save('Test.pdf');
}
function demoUserInput() {
@@ -116,7 +113,7 @@ function demoUserInput() {
for(var i = 1; i <= 12; i ++) {
doc.text(20, 30 + (i * 10), i + ' x ' + multiplier + ' = ' + (i * multiplier));
}
- doc.output('datauri');
+ doc.save('Test.pdf');
}
@@ -141,8 +138,7 @@ function demoRectangles() {
doc.setFillColor(255,0,0);
doc.rect(120, 20, 10, 10, 'FD'); // filled red square with black borders
- // Output as Data URI
- doc.output('datauri');
+ doc.save('Test.pdf');
}
function demoLines() {
@@ -190,8 +186,7 @@ function demoCircles() {
doc.setFillColor(255,0,0);
doc.circle(120, 20, 5, 'FD');
- // Output as Data URI
- doc.output('datauri');
+ doc.save('Test.pdf');
}
function demoTriangles() {
@@ -204,8 +199,7 @@ function demoTriangles() {
doc.setFillColor(0,0,255);
doc.triangle(100, 100, 110, 100, 120, 130, 'FD');
- // Output as Data URI
- doc.output('datauri');
+ doc.save('Test.pdf');
}
function demoImages() {
@@ -255,8 +249,8 @@ function demoImages() {
doc.addImage(imgData, 'JPEG', 10, 10, 50, 50);
doc.addImage(imgData, 'JPEG', 70, 10, 100, 120);
- // Output as Data URI
- doc.output('datauri');
+ doc.save('Test.pdf');
+
}
getImageFromUrl('thinking-monkey.jpg', createPDF);
@@ -304,7 +298,7 @@ function demoStringSplitting() {
}
}
- pdf.output('dataurl')
+ pdf.save('Test.pdf');
}
function demoFromHTML() {
@@ -338,5 +332,5 @@ function demoFromHTML() {
}
)
- pdf.output('dataurl')
+ pdf.save('Test.pdf');
}

0 comments on commit b8b88a7

Please sign in to comment.
Something went wrong with that request. Please try again.