DEV Community

Cover image for DO Submission: PDF Server (for Figma templates)
Henry Kehlmann
Henry Kehlmann

Posted on • Updated on

DO Submission: PDF Server (for Figma templates)

What I built

PDF Server

Next.js app with a front and backend to fill Figma PDF designs with custom data. Only simple vectors + layouts and text based templates supported for now. But you could already use it for a lot of use cases.

Category Submission:

Built for business

App Link

https://pdf.blooob.co

Deploy to DO

Screenshots

Frontend with predefined templates
Frontend with and figma file url input

Description

It's easy to setup and configure, just check the docs or demos.
Integrate it into your other services/apps that need custom PDF template download/streaming functionality etc!

Built with next.js (typescript) + chakra + react-pdf + figma-js + figma-transformer.

Link to Source Code

https://github.com/madhenry/pdf-server

GitHub logo madhenry / pdf-server

Next.js app to fill figma PDF designs with custom data

PDF Server

This little next.js app lets you stream/download text and vector based Figma templates with your own content Demo

Usage

  1. Login/signup to Figma and create a developer token: https://www.figma.com/developers/api
  2. Copy a draft of the preview templates or create a new one (make sure you follow some of the guidelines)

FDS Demo Keys

  1. Deploy as a server-side app to DigitalOcean/Vercel etc

Deploy to DO

Use it through the frontend or via /api/PDF endpoint using query string variables or POST vars.

API endpoint parameters (don't use as layer names in Figma):

file - the Figma file ID

fileName - when defined the api forces a download with the specified file name

debug - when defined, react-pdf debug mode is enabled

Everything else defined is used to replace contents with matching figma layer names.

ENV

# required
FIGMA_TOKEN=
# optional
# comma separated list of figma file id-s or empty to allow all
NEXT_PUBLIC_ALLOWED_FILES=
MAX_VECTORS=100 
Enter fullscreen mode Exit fullscreen mode

Permissive License

MIT

Background

I'm building a SaaS for a client and one part of a critical functionality is the ability to export dynamic reports with all kinds of data in PDFs.
Currently the layouts and styles for PDFs are hardcoded in code and any updates need code changes. But what if a designer could just edit a template in Figma, test it out and voilà the new design is applied in production as well without any code changes.

How I built it

I learned a bit more about typescript and how to configure DigitalOcean's deploy button for easier setup. I also learned that there is a lot of work ahead to support all the features and styles from Figma.

Definately planning to support dynamic rows in templates + custom fonts and other primitives and hopefully gradient colors and images as well.

Additional Resources/Info

Documentation: https://github.com/madhenry/pdf-server

GitHub logo madhenry / pdf-server

Next.js app to fill figma PDF designs with custom data

PDF Server

This little next.js app lets you stream/download text and vector based Figma templates with your own content Demo

Usage

  1. Login/signup to Figma and create a developer token: https://www.figma.com/developers/api
  2. Copy a draft of the preview templates or create a new one (make sure you follow some of the guidelines)

FDS Demo Keys

  1. Deploy as a server-side app to DigitalOcean/Vercel etc

Deploy to DO

Use it through the frontend or via /api/PDF endpoint using query string variables or POST vars.

API endpoint parameters (don't use as layer names in Figma):

file - the Figma file ID

fileName - when defined the api forces a download with the specified file name

debug - when defined, react-pdf debug mode is enabled

Everything else defined is used to replace contents with matching figma layer names.

ENV

# required
FIGMA_TOKEN=
# optional
# comma separated list of figma file id-s or empty to allow all
NEXT_PUBLIC_ALLOWED_FILES=
MAX_VECTORS=100 
Enter fullscreen mode Exit fullscreen mode

Deploy to DO

Any feedback appreciated! Happy new year everybody :)

Top comments (0)