👀 Our most exciting product launch yet 🚀 Join us May 8th for Sanity Connect

Being able to download blocks as a PDF?

4 replies
Last updated: Sep 10, 2020
Wondering if anyone has thought of this. Being able to download blocks as a PDF? My client is asking for this feature, so it would be cool to hear insights if anyone has done something similar.
Sep 10, 2020, 1:29 PM
A couple of years ago I setup a serverless function on Amazon Lambda that would spin up Chrome headless, receive HTML/CSS and return a PDF through the “Print” functionality of the browser. I remember it was quite a lot of testing to get it working. It’s been working ever since and is stable, but I think they have deprecated node 6 (which I used at the time) so at some point I’ll have to revisit this.
Sep 10, 2020, 2:13 PM
Did the same as
user K
(hi, Audun 👋) two years ago. In the end I went with zeit/now (now known as Vercel) and it was by far the easiest setup.

https://github.com/DirektoratetForByggkvalitet/losen-pdf
…outdated now, but might serve as a starting point
Sep 10, 2020, 2:26 PM
Did almost the same as Audun and Kristoffer (when I worked at the same agency, 👋 for u4 , where we made a separate template/CSS-endpoint and sent it to DocRaptor (PrinceXML as a service ). You can also check out this serverless PDF generation on Vercel https://github.com/sanity-io/gatsby-portfolio-preview-poc/blob/master/studio/README.md#pdf-business-card
Sep 10, 2020, 2:48 PM
Why make one PDF generator when you can make three
Sep 10, 2020, 10:43 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?