When I use JSPDF to convert from a PNG to PDF, wherever the PNG is transparent, JSPDF puts a black background in. Where can I find the code in the library to change this from black to white?
I am open to suggestions other than updating the library.
When I use JSPDF to convert from a PNG to PDF, wherever the PNG is transparent, JSPDF puts a black background in. Where can I find the code in the library to change this from black to white?
I am open to suggestions other than updating the library.
Share Improve this question asked Aug 15, 2016 at 20:10 Riyaz ShaikhRiyaz Shaikh 901 silver badge8 bronze badges 1-
jspdf converts transparency into black. so if you can set a background color to white you will be all set. I'm not sure how you are sending you're png to jspdf but can you wrap it in a white div. or if you use imagemagic
$im->setImageBackgroundColor('white');
I'm sure there must be an equivalent – jkuhns5 Commented Aug 16, 2016 at 14:31
1 Answer
Reset to default 5I solved this by using before I drew the image to the canvas.
context.fillStyle = "#FFFFFF";
context.fillRect(0,0,width,height);