sidebase / nuxt-pdf

📄 A easy to use, pdf exporting module to convert Nuxt 3 components into downloadable PDFs.
https://sidebase.io/nuxt-pdf/getting-started
MIT License
102 stars 11 forks source link

Support server side rendering for PDFs #7

Closed zoey-kaiser closed 4 months ago

zoey-kaiser commented 1 year ago

Describe the feature

We want to offer developers to opportunity to generate their PDFs server side for more security. In order to do this we must add a new server side function to generate and export the pdf.

A good starting point is this issue: https://github.com/parallax/jsPDF/issues/2248

Additional information

No response

mklueh commented 1 year ago

Just curious, will this happen on every page hit or just once during the build? would be great to have some control over it. Maybe sometimes you want to generate something on demand, and sometimes you just want to serve a pre-generated PDF

madsh93 commented 1 year ago

Exciting. Can't wait to see where this leads.

Would be nice if you could pass it some HTML with Tailwind Style on a server route and have it generated. But it's probably to much to ask for.

It would be a tremendously needed feature for me. I've been tr Puppeteer which worked fine, but was slow and difficult to deploy in serverless environment due to the 50mb constraint.

zoey-kaiser commented 1 year ago

Just curious, will this happen on every page hit or just once during the build? would be great to have some control over it. Maybe sometimes you want to generate something on demand, and sometimes you just want to serve a pre-generated PDF

Hi @mklueh! I am currently planing to first work on a "SSG" type rendering system. So regeneration with every load, to allow for real time data on the PDF. However adding a statically generated PDF at runtime could make sense to implement as well, however it would have less priority for me for now!

zoey-kaiser commented 1 year ago

Would be nice if you could pass it some HTML with Tailwind Style on a server route and have it generated. But it's probably to much to ask for.

I am looking into a way to handle this, as it is super important for me! I am currently at a point where I know there is a way to generate pure html from a vue component using renderToString(). I am now looking into how I can generate a JS file from a vue file (which is a bit harder and I am still looking into).

One of my approches is currently looking into the server Nuxt 3 "server components", but I can keep you updated when I made some process!

It would be a tremendously needed feature for me. I've been tr Puppeteer which worked fine, but was slow and difficult to deploy in serverless environment due to the 50mb constraint.

I totally get it! I have had similar issues (not with PDF but with Social Media SEO Previews). I hope to find an elegant way to handle these use cases for Nuxt 3. It will also prove valuable as I can then move onto other advanced template use cases (such as mail, SEO Previews and more!)

fanckush commented 5 months ago

Is this still planned?

zoey-kaiser commented 4 months ago

Taken over into #25 and began working on an implementation in #26.

Lets move all discussions about this into the issue / PR! Sorry for the big delay on this, I wish I could have started this earlier, but focus sadly shifted away from this project 😓