Join us live Sept. 27 – How Sanity and Vercel powered Morning Brew's transformation –>

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.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.