Private betav0.3.0
DocsSign in
Format developer documentation

Preview as PDF

Generate a PDF preview of your document at any time during development.

Studio lets you generate a real PDF preview of your document at any point during development. The PDF is generated using the Format API, so it reflects exactly what you will get in production.

Generate a PDF

Use the generate button in the Studio sidebar to trigger a PDF preview for the current document and variant.

The PDF downloads to your machine as [document-name]-[variant].pdf.

Setup

PDF generation requires a Format API key.

Create an API key

Go to the API keys section of your dashboard and create a new key.

Use a personal key for your own development. It stops working if you leave the organization. For shared projects and automation, ask an organization admin or owner to create an organization key.

Add it to your environment

Add the key to your .env file in the root of your project.

.env
FORMAT_API_KEY=your_api_key_here

No server restart is needed. Studio picks up the key immediately.

Organization usage

PDF renders count toward the API key's organization. Switching organizations in Studio does not change FORMAT_API_KEY. To render for another organization, use a key from that organization.

Usage

Careful

PDF generation in Studio uses your Format API quota. PDFs generated during development count toward the usage of the organization your key belongs to, the same as production renders.

Clicking generate again with nothing changed returns the PDF Studio already has. That costs no quota, because the Format API is never called.

Performance

The first PDF for a document is slower than a production render. Studio has to compile the document before it can send it, which production does ahead of time. Full timing and tracing metrics for any PDF generation are available in Metrics.

After that, Studio reuses what it can:

  • The compiled bundle is kept and rebuilt only when a file it was built from changes.
  • Remote assets are downloaded once, then checked with their server on each build. An unchanged file isn't downloaded again.
  • The finished PDF is cached against the exact bytes sent to the API, so an unchanged document returns instantly.

Studio also compiles the open document in the background after each preview render, so the first click after an edit has nothing left to wait for. Background builds stay quiet in your terminal, reporting only warnings and errors. Set FORMAT_DEBUG=true to see everything they do.

When a remote file changes, Studio sees it on the next Generate PDF click and rebuilds. If a server can't be reached, Studio uses the copy it already has.

Was this page helpful?