<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Henry Kehlmann</title>
    <description>The latest articles on DEV Community by Henry Kehlmann (@madhenry).</description>
    <link>https://dev.to/madhenry</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F119254%2F34887e25-a201-4d69-a8de-fe22e57c8ec4.jpeg</url>
      <title>DEV Community: Henry Kehlmann</title>
      <link>https://dev.to/madhenry</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/madhenry"/>
    <language>en</language>
    <item>
      <title>DO Submission: PDF Server (for Figma templates)</title>
      <dc:creator>Henry Kehlmann</dc:creator>
      <pubDate>Thu, 31 Dec 2020 13:59:37 +0000</pubDate>
      <link>https://dev.to/madhenry/do-submission-pdf-server-for-figma-templates-37f9</link>
      <guid>https://dev.to/madhenry/do-submission-pdf-server-for-figma-templates-37f9</guid>
      <description>&lt;h2&gt;
  
  
  What I built
&lt;/h2&gt;

&lt;p&gt;PDF Server&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;h3&gt;
  
  
  Category Submission:
&lt;/h3&gt;

&lt;p&gt;Built for business&lt;/p&gt;

&lt;h3&gt;
  
  
  App Link
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://pdf.blooob.co"&gt;https://pdf.blooob.co&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://cloud.digitalocean.com/apps/new?repo=https://github.com/madhenry/pdf-server/tree/main&amp;amp;refcode=5fc6d2f5bf61"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CNMgVEM---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://mp-assets1.sfo2.digitaloceanspaces.com/deploy-to-do/do-btn-blue.svg" alt="Deploy to DO"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Screenshots
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9x6mexDU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ji0y93m8l5bm4r0rjhy3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9x6mexDU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ji0y93m8l5bm4r0rjhy3.png" alt="Frontend with predefined templates"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZQbZhR_s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/l8jhylxfo9ghpi8nw7hg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZQbZhR_s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/l8jhylxfo9ghpi8nw7hg.png" alt="Frontend with and figma file url input"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Description
&lt;/h3&gt;

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

&lt;p&gt;Built with next.js (typescript) + chakra + react-pdf + figma-js + figma-transformer.&lt;/p&gt;
&lt;h3&gt;
  
  
  Link to Source Code
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/madhenry/pdf-server"&gt;https://github.com/madhenry/pdf-server&lt;/a&gt;&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/madhenry"&gt;
        madhenry
      &lt;/a&gt; / &lt;a href="https://github.com/madhenry/pdf-server"&gt;
        pdf-server
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Next.js app to fill figma PDF designs with custom data
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
PDF Server&lt;/h1&gt;
&lt;p&gt;This little next.js app lets you stream/download text and vector based Figma templates with your own content
&lt;a href="https://pdf.blooob.co" rel="nofollow"&gt;Demo&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
Usage&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Login/signup to Figma and create a developer token: &lt;a href="https://www.figma.com/developers/api" rel="nofollow"&gt;https://www.figma.com/developers/api&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Copy a draft of the preview templates or create a new one (make sure you follow some of the guidelines)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a href="https://www.figma.com/file/w4qFtzyCX2fYT3x6CQDFQF/FDS-Demo" rel="nofollow"&gt;FDS Demo&lt;/a&gt;
&lt;a href="https://www.figma.com/file/HEIPkFgqKYFeCtO7Ri9s7r/Keys" rel="nofollow"&gt;Keys&lt;/a&gt;&lt;/p&gt;
&lt;ol start="3"&gt;
&lt;li&gt;Deploy as a server-side app to DigitalOcean/Vercel etc&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a href="https://cloud.digitalocean.com/apps/new?repo=https://github.com/madhenry/pdf-server/tree/main&amp;amp;refcode=5fc6d2f5bf61" rel="nofollow"&gt;&lt;img src="https://camo.githubusercontent.com/0ccb8e8030ca77fed37048993cce0437e3dac09e603374e0b8706661caea9077/68747470733a2f2f6d702d617373657473312e73666f322e6469676974616c6f6365616e7370616365732e636f6d2f6465706c6f792d746f2d646f2f646f2d62746e2d626c75652e737667" alt="Deploy to DO"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Use it through the frontend or via /api/PDF endpoint using query string variables or POST vars.&lt;/p&gt;
&lt;h2&gt;
API endpoint parameters (don't use as layer names in Figma):&lt;/h2&gt;
&lt;p&gt;file - the Figma file ID&lt;/p&gt;
&lt;p&gt;fileName - when defined the api forces a download with the specified file name&lt;/p&gt;
&lt;p&gt;debug - when defined, react-pdf debug mode is enabled&lt;/p&gt;
&lt;p&gt;Everything else defined is used to replace contents with matching figma layer names.&lt;/p&gt;
&lt;h2&gt;
ENV&lt;/h2&gt;
&lt;div class="highlight highlight-source-shell js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; required&lt;/span&gt;
FIGMA_TOKEN=
&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; optional&lt;/span&gt;
&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; comma separated list of figma file id-s or empty to allow all&lt;/span&gt;
NEXT_PUBLIC_ALLOWED_FILES=
MAX_VECTORS=100 &lt;/pre&gt;…
&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/madhenry/pdf-server"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;h3&gt;
  
  
  Permissive License
&lt;/h3&gt;

&lt;p&gt;MIT&lt;/p&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;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.&lt;br&gt;
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.&lt;/p&gt;
&lt;h3&gt;
  
  
  How I built it
&lt;/h3&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Definately planning to support dynamic rows in templates + custom fonts and other primitives and hopefully gradient colors and images as well.&lt;/p&gt;
&lt;h3&gt;
  
  
  Additional Resources/Info
&lt;/h3&gt;

&lt;p&gt;Documentation: &lt;a href="https://github.com/madhenry/pdf-server"&gt;https://github.com/madhenry/pdf-server&lt;/a&gt;&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/madhenry"&gt;
        madhenry
      &lt;/a&gt; / &lt;a href="https://github.com/madhenry/pdf-server"&gt;
        pdf-server
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Next.js app to fill figma PDF designs with custom data
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;h1&gt;
PDF Server&lt;/h1&gt;
&lt;p&gt;This little next.js app lets you stream/download text and vector based Figma templates with your own content
&lt;a href="https://pdf.blooob.co" rel="nofollow"&gt;Demo&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
Usage&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Login/signup to Figma and create a developer token: &lt;a href="https://www.figma.com/developers/api" rel="nofollow"&gt;https://www.figma.com/developers/api&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Copy a draft of the preview templates or create a new one (make sure you follow some of the guidelines)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a href="https://www.figma.com/file/w4qFtzyCX2fYT3x6CQDFQF/FDS-Demo" rel="nofollow"&gt;FDS Demo&lt;/a&gt;
&lt;a href="https://www.figma.com/file/HEIPkFgqKYFeCtO7Ri9s7r/Keys" rel="nofollow"&gt;Keys&lt;/a&gt;&lt;/p&gt;
&lt;ol start="3"&gt;
&lt;li&gt;Deploy as a server-side app to DigitalOcean/Vercel etc&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;a href="https://cloud.digitalocean.com/apps/new?repo=https://github.com/madhenry/pdf-server/tree/main&amp;amp;refcode=5fc6d2f5bf61" rel="nofollow"&gt;&lt;img src="https://camo.githubusercontent.com/0ccb8e8030ca77fed37048993cce0437e3dac09e603374e0b8706661caea9077/68747470733a2f2f6d702d617373657473312e73666f322e6469676974616c6f6365616e7370616365732e636f6d2f6465706c6f792d746f2d646f2f646f2d62746e2d626c75652e737667" alt="Deploy to DO"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Use it through the frontend or via /api/PDF endpoint using query string variables or POST vars.&lt;/p&gt;
&lt;h2&gt;
API endpoint parameters (don't use as layer names in Figma):&lt;/h2&gt;
&lt;p&gt;file - the Figma file ID&lt;/p&gt;
&lt;p&gt;fileName - when defined the api forces a download with the specified file name&lt;/p&gt;
&lt;p&gt;debug - when defined, react-pdf debug mode is enabled&lt;/p&gt;
&lt;p&gt;Everything else defined is used to replace contents with matching figma layer names.&lt;/p&gt;
&lt;h2&gt;
ENV&lt;/h2&gt;
&lt;div class="highlight highlight-source-shell js-code-highlight"&gt;
&lt;pre&gt;&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; required&lt;/span&gt;
FIGMA_TOKEN=
&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; optional&lt;/span&gt;
&lt;span class="pl-c"&gt;&lt;span class="pl-c"&gt;#&lt;/span&gt; comma separated list of figma file id-s or empty to allow all&lt;/span&gt;
NEXT_PUBLIC_ALLOWED_FILES=
MAX_VECTORS=100 &lt;/pre&gt;…
&lt;/div&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/madhenry/pdf-server"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://cloud.digitalocean.com/apps/new?repo=https://github.com/madhenry/pdf-server/tree/main&amp;amp;refcode=5fc6d2f5bf61"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CNMgVEM---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://mp-assets1.sfo2.digitaloceanspaces.com/deploy-to-do/do-btn-blue.svg" alt="Deploy to DO"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any feedback appreciated! Happy new year everybody :)&lt;/p&gt;

</description>
      <category>dohackathon</category>
      <category>nextjs</category>
      <category>figma</category>
      <category>chakra</category>
    </item>
    <item>
      <title>PDF Server (for Figma templates) STEP 1</title>
      <dc:creator>Henry Kehlmann</dc:creator>
      <pubDate>Thu, 31 Dec 2020 13:55:06 +0000</pubDate>
      <link>https://dev.to/madhenry/pdf-server-for-figma-templates-step-1-42hi</link>
      <guid>https://dev.to/madhenry/pdf-server-for-figma-templates-step-1-42hi</guid>
      <description>&lt;h1&gt;
  
  
  Idea
&lt;/h1&gt;

&lt;p&gt;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.&lt;br&gt;
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.&lt;/p&gt;
&lt;h2&gt;
  
  
  How
&lt;/h2&gt;

&lt;p&gt;Using &lt;a href="https://nextjs.org/"&gt;Next.js&lt;/a&gt; and &lt;a href="https://react-pdf.org/"&gt;React-PDF&lt;/a&gt; to preview / stream the PDF template based on defined properties onto &lt;a href="https://www.figma.com/"&gt;Figma&lt;/a&gt; template files&lt;/p&gt;

&lt;p&gt;Probably need to implement some definitions to allow automatically repeated components, calculated/dynamic content, custom fonts etc but let's keep it simple for now.&lt;/p&gt;
&lt;h2&gt;
  
  
  Let's start up the project
&lt;/h2&gt;

&lt;p&gt;I decided to generate a new boilerplate next.js project using the typescript + chakra example. We can use &lt;a href="https://chakra-ui.com/"&gt;Chakra&lt;/a&gt; for any of the UI elements.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx create-next-app &lt;span class="nt"&gt;--example&lt;/span&gt; with-chakra-ui-typescript pdf-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XttnFs-b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ikrwyerjyv1hrh47b3zr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XttnFs-b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ikrwyerjyv1hrh47b3zr.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see we need to install figma-js and react-pdf and start integrating these 2 together to create an api endpoint.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;yarn add @react-pdf/renderer figma-js figma-transformer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;figma-transformer helps us process the response from figma api by creating .shortcuts in every layer/type.&lt;/p&gt;

&lt;h2&gt;
  
  
  utils/getFigmaFile.ts
&lt;/h2&gt;

&lt;p&gt;This allows us to query all the frames in a figma template and their children and properties. Implementing a number of env vars helps us to customize the server depending on the use case. MAX_VECTORS tries to help safeguard the server from loading way too large figma files with vectors which could lead to memory/crash issues.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;Figma&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;figma-js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;processFile&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;figma-transformer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Figma&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Client&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;personalAccessToken&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;FIGMA_TOKEN&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;DEFAULT_FILE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DEFAULT_FILE&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s2"&gt;`w4qFtzyCX2fYT3x6CQDFQF`&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;MAX_VECTORS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;MAX_VECTORS&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ALLOWED_FILES&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;NEXT_PUBLIC_ALLOWED_FILES&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;allowedFiles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ALLOWED_FILES&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;ALLOWED_FILES&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;split&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;,&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;FigmaOptions&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;geometry&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;paths&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;getFigmaFile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;FigmaOptions&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;allowedFiles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;allowedFiles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileId&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;This file id is not allowed by the server env ALLOWED_FILES&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;figmaFile&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;client&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fileId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt; &lt;span class="p"&gt;??&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;geometry&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;paths&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nx"&gt;then&lt;/span&gt;&lt;span class="p"&gt;(({&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;figma children: &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;figmaFile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;children&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;processFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;figmaFile&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;figma processed vectors length: &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;shortcuts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;vectors&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;shortcuts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;vectors&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;shortcuts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;vectors&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;MAX_VECTORS&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Too many vectors in template&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;file&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we need to start mapping the file response elements into a react-pdf document.&lt;/p&gt;

&lt;p&gt;Continue to part 2&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>figma</category>
      <category>chakra</category>
      <category>reactpdf</category>
    </item>
  </channel>
</rss>
