最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - JSPDF adding a black background to converted PDF - Stack Overflow

programmeradmin2浏览0评论

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
Add a ment  | 

1 Answer 1

Reset to default 5

I solved this by using before I drew the image to the canvas.

context.fillStyle = "#FFFFFF";
context.fillRect(0,0,width,height);
发布评论

评论列表(0)

  1. 暂无评论