calvinfroedge / node-jspdf

jsPDF on the server.
14 stars 19 forks source link

Trouble adding image to node-jspdf #5

Open trevordowdle opened 8 years ago

trevordowdle commented 8 years ago

Hey Calvin,

Just wanted to first say thank you for the nice package you have created and shared.

It's working great, however I am having some trouble adding an image and getting it to save properly in node.

Do you have an example or know of an example out there that I could see for reference?

I have a string of Base64 encoded jpeg data I am working with and when the pdf generates I am getting an out of memory error. I don't have to do it with the base64 encoded data.. I could grab the image from the server somewhere..

Any help/feedback is appreciated. ( In order to get it to run I had to import an atob function from node )

doc.addImage('data:image/jpeg;base64,/9j/4AAQS...etc..', 'JPEG', 35, 25, 141.9, 35.75); doc.save('Test.pdf', function(err){console.log('saved!');});

calvinfroedge commented 8 years ago

Hi Trevor,

I actually ran into this issue as well, but did not need to support images so I punted on it. It's not in the issues, but it's a known issue to me. You're welcome to take a stab at fixing it.

trevordowdle commented 8 years ago

Okay thank you for the feedback.. I'll see what I can do.

dbauszus-glx commented 8 years ago

Were you able to sort this problem? Not being able to add images to PDF. But I don't get any error message neither.

trevordowdle commented 8 years ago

No, I looked at it for a little while, but I ended up using Electron to spin up an instance of chrome and generate the PDF in the browser, with Electron I was was able to watch for and intercept downloads in the browser and handle the file accordingly.

dbauszus-glx commented 8 years ago

Just finished my own workaround. I am now using a phantom bridge for phantomjs to get pixel perfect pdf output.

https://www.npmjs.com/package/phantom