Skip to content

Commit

Permalink
Update image examples
Browse files Browse the repository at this point in the history
  • Loading branch information
MrRio committed Jan 6, 2013
1 parent b29b81a commit e322d9b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions examples/css/editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,9 @@ footer {
float: left;
margin-right: 40px;
padding-top: 8px;
}

.source {
font-family: "source-code-pro", Courier;
font-size: 14px;
}
12 changes: 9 additions & 3 deletions examples/js/images.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
// This example doesn't currently work on IE
// However, you can convert your images to JSON.
// We'll post some examples and tools soon!

// Because of security restrictions, getImageFromUrl will
// not load images from other domains. Chrome has added
// security restrictions that prevent it from loading images
Expand Down Expand Up @@ -34,18 +38,20 @@ var getImageFromUrl = function(url, callback) {
return ret;
}

doc = new jsPDF();

// Since images are loaded asyncronously, we must wait to create
// the pdf until we actually have the image data.
// If we already had the jpeg image binary data loaded into
// a string, we create the pdf without delay.
var createPDF = function(imgData) {
var doc = new jsPDF();


doc.addImage(imgData, 'JPEG', 10, 10, 50, 50);
doc.addImage(imgData, 'JPEG', 70, 10, 100, 120);

doc.save('output.pdf');
// You'd usually call doc.save() here

}

getImageFromUrl('thinking-monkey.jpg', createPDF);
getImageFromUrl('./examples/thinking-monkey.jpg', createPDF);
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ <h2>Have a play.</h2>
<div class="clerfix"></div>
<div class="span12 credits">

<h2>The Basics</h2>

<p>Simply include the jsPDF library in your <span class="source">&lt;head&gt;</span>, generate your PDF using the <i>many</i> built-in functions, then hook up a button to trigger the download. All the examples here use jQuery.</p>

<h2>Credits</h2>

<p>Big thanks to Daniel Dotsenko from <a href="http://willow-systems.com">Willow Systems Corporation</a> for making huge contributions to the codebase. </p>
Expand Down

0 comments on commit e322d9b

Please sign in to comment.