yWorks / jsPDF

JavaScript PDF generation to work with SVG
MIT License
56 stars 23 forks source link

Support for webp images #36

Open Prat041192 opened 4 years ago

Prat041192 commented 4 years ago

Hi All, I have a Feature request to make and looking for the workaround at the moment too.

Issue: Adding png adds to the size of pdf as well as adds to the load time of the webpage.

I'm using jspdf for generating pdf from the visualization (d3 graph and images and text) over the web portal I'm working on. and most of my images are webp images.

Currently, addImage does not support adding Webp images to the pdf as I can see, usually, the websites or web portals use webp images to reduce the load time of the webpage.

It would be nice to have if the library can support and a big help if anyone can help me with the workaround at the moment. I'm trying this nice library webp-converter may be others have better ideas to share.

Thanks in advance,

HackbrettXXX commented 4 years ago

The upstream project (https://github.com/MrRio/jsPDF) recently got support for Webp images. We merged the features of this fork into the upstream repository some time ago and yWorks is now co-maintainer of the original project, which is why this repository will soon be archived. MrRio/jsPDF will soon get a new release that will also support Webp images.

Prat041192 commented 4 years ago

@HackbrettXXX , Thanks for getting back on this. When is the next release planned? and is there any suggestion by which I can reduce the size of the pdf. I've lot of tags and logos that combine together in the pdf that needs to export.

HackbrettXXX commented 4 years ago

There is no fixed release date, yet. Probably within the next weeks.

You can turn on by passing compress: true to the jsPDF options, but this won't help much if your PDF mainly consists of images. If your images originate from vector graphics, you can add them using svg2pdf. If not, your only option is to compress your images as much as possible. Currently, you can use JPEG images for this. In the future WebP. Note, though, that WebP is also converted to JPEG internally. AFAIK, the PDF standard does not support WebP image de-/encoding.