HTML image to pdf convertor in javascript


<img class="imagepdf "src="www.images.com/someimage" alt="Smiley face" height="42" width="42">

I want to convert this image to pdf format. I am using <strong>jspdf()</strong> for this but i am not getting my output ?Can someone give me live example on fiddle for pdf conversion for chrome.


Here is code from it's github site

var getImageFromUrl = function(url, callback) { var img = new Image(); img.onError = function() { alert('Cannot load image: "'+url+'"'); }; img.onload = function() { callback(img); }; img.src = url; } var createPDF = function(imgData) { var doc = new jsPDF(); doc.addImage(imgData, 'JPEG', 10, 10, 50, 50, 'monkey'); doc.addImage('monkey', 70, 10, 100, 120); // use the cached 'monkey' image, JPEG is optional regardless doc.output('datauri'); } getImageFromUrl('thinking-monkey.jpg', createPDF);

If you are working in chrome security restrictions that prevent it from loading images from a url so just add this line and it will be working fine<strong>img.crossOrigin = " ";</strong> It will be fine for chrome alse


  • JSPDF - How to export multiple images with various page size (height & width) to a single pdf fi
  • Twitter Request Token Wahts Wrong with this HTTP?
  • Export HTML + CSS to PDF using Javascript
  • Error - ( Uncaught TypeError: Object(…) is not a function) while converting HTML to PDF in React
  • C# COM Component Fails To Read Config When Loaded Into An Unmanaged C++ App
  • Bootstrap Popover showing at wrong place upon zoom in/out or resizing Browser window
  • How can I add div content to a new page in jspdf?
  • How to display the images in listview
  • how to get data attributes of dynamically generated element
  • C# List of Panels
  • Get the number 18437736874454810627
  • Is there a way to dynamically embed PDF Files in a JSP pulled from the file system?
  • Creating PDF from TIFF image using iText
  • How to get links to open in the native browser in iOS Meteor apps?
  • Application level floating views with navigation in Android
  • Convert SQLite database to XML
  • How to generate and display a QR Code in ionic 2
  • WPF Visiblity Binding to Boolean Expression with multiple Variables
  • Position: fixed nav does not stay fixed
  • Conversion from string “a” to type 'Boolean' is not valid
  • Using a canvas object in a thread to do simple animations - Java
  • How can I enlarge video fullscreen without the affected interface project in as3?
  • Python urlparse: small issue
  • FileReader+canvas image loading problem
  • Linq Objects Group By & Sum
  • Optimizing database types to compact database (SQLite)
  • Shallow update not allowed (git > 1.9)
  • Deserializing XML into class C#
  • Font Awesome Showing Box instead of Icons
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • Properly structure and highlight a GtkPopoverMenu using PyGObject
  • How do I rollback to a specific git commit
  • Arrays break string types in Julia
  • Revoking OAuth Access Token Results in 404 Not Found
  • Buffer size for converting unsigned long to string
  • python draw pie shapes with colour filled
  • Is it possible to post an object from jquery to bottle.py?
  • reshape alternating columns in less time and using less memory
  • How to Embed XSL into XML
  • Python/Django TangoWithDjango Models and Databases