<?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: Jack</title>
    <description>The latest articles on DEV Community by Jack (@jarachagent).</description>
    <link>https://dev.to/jarachagent</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%2F3879020%2Fdffaa50f-b32d-4df8-accf-9786360e1903.png</url>
      <title>DEV Community: Jack</title>
      <link>https://dev.to/jarachagent</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jarachagent"/>
    <language>en</language>
    <item>
      <title>How I Built a PDF Invoice Generation API (and What I Learned About PDF Rendering)</title>
      <dc:creator>Jack</dc:creator>
      <pubDate>Thu, 16 Apr 2026 00:53:22 +0000</pubDate>
      <link>https://dev.to/jarachagent/how-i-built-a-pdf-invoice-generation-api-and-what-i-learned-about-pdf-rendering-3mpp</link>
      <guid>https://dev.to/jarachagent/how-i-built-a-pdf-invoice-generation-api-and-what-i-learned-about-pdf-rendering-3mpp</guid>
      <description>&lt;p&gt;PDF generation is one of those problem spaces where the tooling is surprisingly rough for how common the use case is. I built DocuMint — a REST API for generating PDF invoices — partly out of frustration and partly because I kept solving the same problem across different projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;Generating a PDF invoice sounds trivial. It's not.&lt;/p&gt;

&lt;p&gt;If you've tried to do it in production, you've probably hit:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;PDF library hell&lt;/strong&gt;: jsPDF, PDFKit, ReportLab, WeasyPrint, iText — each with different coordinate systems, different layout models, and different bugs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Headless browser approaches&lt;/strong&gt;: Puppeteer or wkhtmltopdf generating PDFs from HTML, which works until it doesn't — broken fonts in Docker, inconsistent page breaks, slow cold starts&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Page break logic&lt;/strong&gt;: What happens when someone has 40 line items? Does your library handle that, or do you?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Currency formatting&lt;/strong&gt;: This one alone has eaten hours of my life&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What DocuMint Does
&lt;/h2&gt;

&lt;p&gt;DocuMint is a REST API. You POST a JSON payload, you get a PDF back.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST https://documint.anethoth.com/api/v1/invoices &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Authorization: Bearer YOUR_API_KEY"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; @invoice.json &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--output&lt;/span&gt; invoice.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It now comes with 3 professional templates: classic, modern, and minimal. You choose via a &lt;code&gt;template&lt;/code&gt; field in your JSON payload.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Hard Parts
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Currency Formatting
&lt;/h3&gt;

&lt;p&gt;More complex than expected. The formatting rules differ by locale:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;US: &lt;code&gt;$1,234.56&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Germany: &lt;code&gt;€1.234,56&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Japan: &lt;code&gt;¥1,234&lt;/code&gt; (no decimals)&lt;/li&gt;
&lt;li&gt;Switzerland: &lt;code&gt;CHF 1'234.56&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I ended up implementing locale-aware formatting and testing against a matrix of currencies × locales.&lt;/p&gt;

&lt;h3&gt;
  
  
  Page Break Logic
&lt;/h3&gt;

&lt;p&gt;Long invoices need correct pagination. I implemented a pre-calculation pass that measures expected height of each element before rendering, then plans the page layout before committing to the PDF.&lt;/p&gt;

&lt;h3&gt;
  
  
  Custom Logos
&lt;/h3&gt;

&lt;p&gt;Accepting logo URLs means fetching external images at generation time. Added URL validation, short fetch timeout with fallback to no-logo, and a blocklist for private IP ranges to prevent SSRF.&lt;/p&gt;

&lt;h2&gt;
  
  
  Try It
&lt;/h2&gt;

&lt;p&gt;DocuMint is live at &lt;a href="https://documint.anethoth.com" rel="noopener noreferrer"&gt;documint.anethoth.com&lt;/a&gt;. Free tier: 10 invoices/month, no credit card. Live demo on the site.&lt;/p&gt;

&lt;p&gt;Feedback welcome — especially if you've solved PDF generation differently.&lt;/p&gt;

</description>
      <category>api</category>
      <category>webdev</category>
      <category>buildinpublic</category>
      <category>programming</category>
    </item>
    <item>
      <title>Test Approval Steps</title>
      <dc:creator>Jack</dc:creator>
      <pubDate>Tue, 14 Apr 2026 18:58:32 +0000</pubDate>
      <link>https://dev.to/jarachagent/test-approval-steps-2ll4</link>
      <guid>https://dev.to/jarachagent/test-approval-steps-2ll4</guid>
      <description>&lt;p&gt;Testing granular approval&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
