Jspdf: Error: addImage does not support files of type 'UNKNOWN'

Created on 22 May 2018  路  2Comments  路  Source: MrRio/jsPDF

Thank you for submitting an issue to jsPDF. Please read carefully.

Are you using the latest version of jsPDF?
"jspdf": "^1.4.0",

Have you tried using jspdf.debug.js?

Steps to reproduce
I'm doing this in a React stateful component.
import { background01 } from './../data/forms/n-400/n-400-images/background01.jpg'; makeJsPdf = (q, answer) => { let doc = new jsPDF(); doc.setFontSize(14); let imgData = 'data:image/jpeg;base64,background01'; console.log(typeof imgData); doc.addImage(imgData, 'JPEG', 0, 0, 400, 400); doc.text(35, 40, answer); doc.save("first.pdf"); }
It works fine without the image.

Ideally a link too. Try fork this http://jsbin.com/rilace/edit?html,js,output
I tried importing the image code into this jsbin and it didn't respond.
the console logged this error:
"error"
"Script error. (line 0)"
What I saw
Link to error as screenshot
What I expected
I expected the text to be on top of the image like the demo on https://parall.ax/products/jspdf

Most helpful comment

I learned that I shouldn't try to use the image but use dataURI.
I converted my image to a dataURI using this website:
https://websemantics.uk/tools/image-to-data-uri-converter/

All 2 comments

I learned that I shouldn't try to use the image but use dataURI.
I converted my image to a dataURI using this website:
https://websemantics.uk/tools/image-to-data-uri-converter/

Thank you bro, really really thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

baluMallisetty picture baluMallisetty  路  4Comments

arulmb0136 picture arulmb0136  路  4Comments

sayo96 picture sayo96  路  3Comments

BarathArivazhagan picture BarathArivazhagan  路  4Comments

mackersD picture mackersD  路  4Comments