Is there a way of generating views in PDF format with Redwood.JS

I need to build views in PDF format, but I still want to use Redwood.JS and TailwindCSS.

There are packages for this but I want to write pages they way I normally do it with Tailwind.CSS

Not like this

  doc.moveDown(2);
  doc.fontSize(12);
  doc.text(`Hanteras av: ${params.handledBy}`);

I know that you can change the contentType to be more like this contentType("application/pdf")

How can I accomplish this in Redwood, viewing files in pdf rather than html.

It would be nice if there a was prop in the router like this

    <Route path="/" page={MyComponent} name="index" renderFormat={"pdf"} />

Believe it or not even in 2021, making PDFs isn’t trivial.

And Ryan agrees:

https://twitter.com/ryanchenkie/status/1445392148610883586

I wouldn’t suggest generating the PDFs client side.

If anything, they should be rendered server-side (as a background task since it could take some time to assemble the data and format) and even saved to Storage and then a notification or email should be sent with a way to download the PDF file.

But, if the content is simple: Print and Save in browser as PDF works 80% of the time and requires 0 extra work.

Edit: I should add that some specialized/deidated css for print media formats help here.

See: Customizing Screens - Tailwind CSS