NPM library to generate PDFs on the client-side

Hi everyone,

My usecase involves generating PDFs from a user’s browser using a PDF Byte string that is returned from the server. After trying to find out how to do it, it seems like the best way is to use the NPM Plugin to load external libraries. I have tried to use a couple of libraries like jspdf and pdf-lib but it seems like they are either not supported or I don’t know what instance name to use.

Does anyone have any experience getting this usecase to work on Weweb and could please share what you did?

You don’t need a library if the server already gives you bytes, you just need to convert these bytes and download them, or what exaclty are you getting from the API?

1 Like

@Broberto Yes, you are right about this - I managed to get it to work.

However, just for reference, are there any pdf libraries known to work well with Weweb? Would like to move a chunk of pdf generation code to front-end in the future if possible (for showing realtime changes/editing in the browser)

You could just use print-css, if you want to generate stuff from HTML, otherwise I’d look into pdf-kit or something, but I haven’t tested it with WeWeb yet.