Open Davidzhu001 opened 7 years ago
I am having the same problem, when I try to insert an image to the PDF, the same message appears, but I have already debugged the whole code, the src is not undefined, and the path is valid.
Code:
const imgPath = 'http://behive.wpengine.com/wp-content/uploads/2017/04/LoadIcon.png'; doc.image(imgPath, 0, 15, {width: 300}).font('Helvetica', 20).text('behive', 0, 0);
It's not possible to open an image in PDFKit directly from the internet. You have to download it as an ArrayBuffer : #491 #410
Thanks, but now I'm getting this error:
Uncaught Error: Unknown image format.
On debugger, the data converted from buffer is: data: Uint8Array[14] 0: 80 1:78 2:71 3:95 4:98 5:101 6:104 7:105 8:118 9:101 10:46 11:80 12:78 13:71
Uncaught TypeError: Cannot read property 'readFileSync' of undefinedPDFImage.open @ image.js:33image @ images.js:28(anonymous function) @ pdfkit.js:50270.blob-stream @ pdfkit.js:67s @ _prelude.js:1(anonymous function) @ _prelude.js:1(anonymous function) @ fake_f103dc0.js:6268.../../semantic/dist/semantic.min.js @ fake_f103dc0.js:7s @ _prelude.js:1e @ _prelude.js:1(anonymous function) @ _prelude.js:1