<?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: tato6615</title>
    <description>The latest articles on DEV Community by tato6615 (@tato6615).</description>
    <link>https://dev.to/tato6615</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F643880%2Fe0836baf-acc1-4042-8989-1cabd67c6928.jpeg</url>
      <title>DEV Community: tato6615</title>
      <link>https://dev.to/tato6615</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tato6615"/>
    <language>en</language>
    <item>
      <title>Generate Thai-language PDF receipts from n8n, Make or Zapier with one HTTP request</title>
      <dc:creator>tato6615</dc:creator>
      <pubDate>Sun, 22 Nov 2026 07:51:49 +0000</pubDate>
      <link>https://dev.to/tato6615/generate-thai-language-pdf-receipts-from-n8n-make-or-zapier-with-one-http-request-44ck</link>
      <guid>https://dev.to/tato6615/generate-thai-language-pdf-receipts-from-n8n-make-or-zapier-with-one-http-request-44ck</guid>
      <description>&lt;p&gt;If you build automations for Thai businesses, you will eventually be asked for this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Can the system send the customer a PDF receipt, in Thai, after they pay?"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It sounds easy. In practice, Thai text is where many PDF tools fall over: missing glyphs, vowels floating in the wrong place, tone marks overlapping the letter below. The fix is not complicated, but you have to know where to look.&lt;/p&gt;

&lt;p&gt;This post shows a setup that works from any tool that can send an HTTP request (n8n, Make, Zapier, a plain script). The idea is simple:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Build the receipt as &lt;strong&gt;HTML&lt;/strong&gt; (you already know how).&lt;/li&gt;
&lt;li&gt;Include a &lt;strong&gt;Thai web font&lt;/strong&gt; in that HTML.&lt;/li&gt;
&lt;li&gt;POST the HTML to a PDF API and save the file it returns.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I'll use &lt;a href="https://leafkiln.somboon0241-c27.workers.dev/" rel="noopener noreferrer"&gt;Leafkiln&lt;/a&gt;, a small HTML-to-PDF API I built, for step 3. Disclosure: it's my project, and I'm sharing it because I'd like feedback. The technique works with any renderer that runs a real browser engine.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Thai text breaks
&lt;/h2&gt;

&lt;p&gt;Thai is written with stacked combining marks: a base consonant, a vowel above or below it, and a tone mark above that. A renderer needs two things to get this right:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A font that actually contains Thai glyphs.&lt;/strong&gt; A server with only Latin fonts will show empty boxes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Proper text shaping&lt;/strong&gt;, so the marks stack on the right letter.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A browser-based renderer handles shaping well, so the practical job is just making sure a Thai font is available. The easiest way is to load one from Google Fonts inside the HTML itself. Sarabun is a good default for documents.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: The receipt HTML
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!doctype html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"th"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"utf-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"https://fonts.googleapis.com/css2?family=Sarabun:wght@400;700&amp;amp;display=swap"&lt;/span&gt; &lt;span class="na"&gt;rel&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'Sarabun'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sans-serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;14px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mh"&gt;#222&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="mi"&gt;4px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;table&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="kt"&gt;%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;border-collapse&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;collapse&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;margin-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;16px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;th&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;td&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;border-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1px&lt;/span&gt; &lt;span class="n"&gt;solid&lt;/span&gt; &lt;span class="mh"&gt;#ddd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nt"&gt;td&lt;/span&gt;&lt;span class="nc"&gt;.num&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;th&lt;/span&gt;&lt;span class="nc"&gt;.num&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nc"&gt;.total&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;700&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;16px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;ใบเสร็จรับเงิน&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;เลขที่ INV-2026-0042 · วันที่ 22 พฤศจิกายน 2569&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;table&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;&lt;/span&gt;รายการ&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&amp;lt;th&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"num"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;จำนวน&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&amp;lt;th&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"num"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;ราคา (บาท)&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&lt;/span&gt;ชาเขียวอุจิ ถุงละ 100 กรัม&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"num"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;2&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"num"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;480.00&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;&lt;/span&gt;ค่าจัดส่ง&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"num"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;1&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"num"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;50.00&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;tr&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"total"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;td&amp;gt;&lt;/span&gt;รวมทั้งสิ้น&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"num"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;530.00&lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;

  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;ขอบคุณที่อุดหนุนครับ&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Tip: this is a normal web page, so you can open it in your browser first and fix the layout before touching any automation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Send it as a request
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -X POST https://leafkiln.somboon0241-c27.workers.dev/v1/pdf \
  -H &lt;span class="s2"&gt;"Authorization: Bearer YOUR_API_KEY"&lt;/span&gt; \
  -H &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; \
  -d &lt;span class="s1"&gt;'{"html":"&amp;lt;h1&amp;gt;ใบเสร็จรับเงิน&amp;lt;/h1&amp;gt;&amp;lt;p&amp;gt;รวมทั้งสิ้น 530.00 บาท&amp;lt;/p&amp;gt;","format":"A4"}'&lt;/span&gt; \
  --output receipt.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The response body is the PDF itself (&lt;code&gt;application/pdf&lt;/code&gt;), so &lt;code&gt;--output&lt;/code&gt; writes it straight to disk. Two parameters worth knowing for receipts:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;margin&lt;/code&gt;: an object such as &lt;code&gt;{"top":"15mm","right":"15mm","bottom":"15mm","left":"15mm"}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;printBackground&lt;/code&gt;: on by default, so table header colors and logos are kept&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The response also includes &lt;code&gt;x-leafkiln-used&lt;/code&gt; and &lt;code&gt;x-leafkiln-limit&lt;/code&gt; headers, so you can see where you are against your monthly quota. A request that fails to render returns an error and is not counted.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq9wpouqwi9mh6xwuz12f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq9wpouqwi9mh6xwuz12f.png" alt="Thai receipt PDF rendered with the Sarabun font" width="799" height="332"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example output: the receipt HTML from Step 1, rendered to PDF with Sarabun.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Wire it into n8n
&lt;/h2&gt;

&lt;p&gt;In n8n, the pattern is two nodes after your "payment received" trigger:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Code (or Set) node&lt;/strong&gt; that builds the HTML string, inserting the order number, items and total from the incoming data. Have it return two fields: &lt;code&gt;html&lt;/code&gt; (the receipt HTML) and &lt;code&gt;format&lt;/code&gt; (set to &lt;code&gt;A4&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;HTTP Request node&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;Method: &lt;code&gt;POST&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;URL: &lt;code&gt;https://leafkiln.somboon0241-c27.workers.dev/v1/pdf&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Authentication: add a header named &lt;code&gt;Authorization&lt;/code&gt; with the value &lt;code&gt;Bearer YOUR_API_KEY&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Send Body: on, Body Content Type: &lt;code&gt;JSON&lt;/code&gt;, Specify Body: &lt;code&gt;Using Fields Below&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Add two body fields, &lt;code&gt;html&lt;/code&gt; and &lt;code&gt;format&lt;/code&gt;, and drag the matching fields from the Code node's output into the value boxes&lt;/li&gt;
&lt;li&gt;Options &amp;gt; Response &amp;gt; Response Format: &lt;strong&gt;File&lt;/strong&gt;, so the PDF flows into the next node as an attachment&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;From there, attach the binary file in a Gmail, LINE or S3 node. Make and Zapier work the same way: an HTTP module that POSTs JSON and returns a file.&lt;/p&gt;

&lt;p&gt;Using "Fields Below" has a bonus: n8n serializes the body for you, so quotes and newlines in the HTML are escaped correctly. If you hand-write a JSON string from an HTML string, those characters will break the request.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common gotchas
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Fonts load from the network.&lt;/strong&gt; If the Google Fonts request is slow, the first render can fall back to a default font. Setting &lt;code&gt;waitUntil&lt;/code&gt; to &lt;code&gt;networkidle&lt;/code&gt; makes the renderer wait for those requests to finish.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Page breaks.&lt;/strong&gt; For long item lists, add &lt;code&gt;tr { page-break-inside: avoid; }&lt;/code&gt; so rows don't split across pages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rendering a URL instead.&lt;/strong&gt; If your receipt already exists as a web page, send &lt;code&gt;url&lt;/code&gt; instead of &lt;code&gt;html&lt;/code&gt;. You send exactly one of the two.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Request size.&lt;/strong&gt; Request bodies are limited to 6 MB, so avoid embedding large base64 images. Link to hosted images instead.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What I'd like feedback on
&lt;/h2&gt;

&lt;p&gt;I built this because I kept hitting the Thai-PDF problem in client automations. It runs on Cloudflare Workers with Browser Rendering, doesn't store your HTML or PDFs, and there's a free tier of 100 files per month with every parameter available.&lt;/p&gt;

&lt;p&gt;If you try it, I'd really like to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Did the Thai text render correctly in your layout?&lt;/li&gt;
&lt;li&gt;Where did you get stuck in the n8n / Make / Zapier setup?&lt;/li&gt;
&lt;li&gt;Which option is missing that would stop you from using it?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Free key and live demo: &lt;a href="https://leafkiln.somboon0241-c27.workers.dev/" rel="noopener noreferrer"&gt;https://leafkiln.somboon0241-c27.workers.dev/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Comments here are the fastest way to reach me.&lt;/p&gt;

</description>
      <category>automation</category>
      <category>n8n</category>
      <category>api</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
