Downloadable page

Is there any possible way to make a page that is just a pdf file for a user to download? Was seeing if there where any examples for this use case but couldn't find any

Hi @kevin.reevers,

Of course, you can upload a PDF to the Prismic media library, or as an asset in your project. However, it sounds like maybe you want to programmatically generate a PDF with data from Prismic? If that's the case, I haven't personally seen any examples of anyone doing that. I'm sure it's possible, though I can't say exactly how. Maybe you can make it work with a package like PDFMake or PDFKit.

I hope that helps! Let me know how it goes :slight_smile:

Sam

Not quite, just seeing if there was any way to proxy via prismic a page that just directly triggers the file to be downloaded. Seems that the file is being constantly updated, and would like it to be so tied to the file itself

Hey @kevin.reevers,

That sounds interesting, but I can't quite understand your use case.

Let me see if I've got it:

  • You have a PDF hosted somewhere else, which is regularly changed
  • You have a page in Prismic that links to the PDF
  • You want to make sure that the page in Prismic is always linking to the latest version of the PDF.

Is that correct?

@samlittlefair yes, that's correct

@kevin.reevers Have you considered using Integration Fields?

You could set up a simple API to send a link to the PDF to Prismic. When the PDF changes, the API could update the link, and the link will stay in sync in your app. (If your app is statically generated, the API will also need to trigger a rebuild.)

Here's a low-code example integrating Tweets via Zapier:

For example, you could do something similar with Dropbox and Zapier. When an editor uploads a new PDF to Dropbox, Zapier sends a link to the file to Prismic's Integration Fields API. The link updates in Prismic and in your website.

Let me know if that addresses your use case. If not, I'm happy to keep tossing ideas around! I'm also happy to assist if you need help with implementation :slight_smile:

Best,
Sam

This is almost it, but was wondering if there was a way for the document to just render the pdf file? Is there a field that I could use that if the customer visits that route, it' would trigger the browser to load its pdf reader/prompt download?

Hi @kevin.reevers, Would the download HTML attribute do what you're trying to accomplish?

Not to the ideas of the marketing team. They'd like just a document be the page that would render the pdf for a consumer friendly url

Hey @kevin.reevers,

I've never dealt with a use-case like this before, so I'm just brainstorming. Are you using a framework like Next.js? Perhaps you could create a singleton type in Prismic called "pdf", with a single field for a PDF. Then create a file in your next project at ~/pages/download.jsx that queries the document from Prismic and then forwards the user to the URL of the PDF file in your media library.

(If you wanted to extend this, you could create the page at ~/pages/download/[uid].jsx and make the PDF Custom Type repeatable, with a UID field.)

Sam

Unfortunately in this case we're using ember-fastboot. Thanks for the recommendation, we'll look into it.

1 Like

@kevin.reevers Sounds good. In any case, let me know what you come up with :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.