AI Development
PDFCN: how to get Claude Code to create better PDFs with Haiku, at about a third of the cost of Opus
With PDFCN, an open-source library with 20 templates and 9 themes, Claude Code builds PDFs with working QR codes even on Haiku, at a third of Opus’s cost.

Luca Di Domenico
· 4 min read
In short
PDFCN is a free, open-source library with 20 document templates and 9 visual themes. In my test, with the same prompt and the same data, Claude Code with PDFCN and Haiku generated a ticket with a working QR code at about a third of the cost of Opus; without PDFCN, the QR code was an empty box. The template stays in your project and can be reused, and with a dedicated skill my costs were cut in half.
Claude Code creates better PDFs when you give it a library of ready-made templates. I used PDFCN: with the same prompt and the same data, Claude Code generated a ticket with a working QR code using Haiku, the cheapest model, and I spent about a third of what Opus cost. Without PDFCN, there was only an empty box where the QR code should have been.
What difference does PDFCN make to a PDF generated by Claude Code?
I ran a simple test. Same model, same prompt, same data: a ticket with a QR code. The only variable was the library.
- Without PDFCN: the QR code was missing entirely. In its place, an empty box.
- With PDFCN: the QR code was there, visible and working.
- Model used with PDFCN: Haiku, the cheapest model in Claude Code.
- Cost: about a third of what Opus cost, $0.17 per PDF versus $0.51.
With a good starting template, Claude Code doesn’t have to invent the layout from scratch. That is why even a small model produces a correct document.
What is PDFCN and what can you do with it?
PDFCN is a free, open-source library under the MIT license, published in the shadcn-labs/pdfcn repository. It provides ready-made components for generating PDFs, including a dedicated QR code component.
The PDFCN documentation index lists 20 ready-made templates and 9 visual themes. The templates include:
- invoices in six variants
- financial, marketing, operations and security reports
- event tickets
- meeting minutes
- shipping labels and packing slips
- work orders, gift certificates, press releases
You don’t need to know how to code to use PDFCN. Just ask Claude Code in plain language, the same way you make any other request. If this approach interests you, I also cover it in how to build software with AI without coding.
Can’t Claude Code already create PDFs on its own?
Yes, Claude Code can create PDFs on its own if you use Opus or Sonnet, the most powerful models. There are two problems.
- Every PDF costs a lot, because the most powerful models cost more on every generation.
- The result changes a little every time, because Claude Code rebuilds the layout from scratch on every request.
With PDFCN, Claude Code starts from a stable template. That is why I could drop all the way down to Haiku without losing the QR code.
Why does the document template stay yours?
The document template you choose stays in your project. You build it once and reuse it for as many documents as you want.
That way you don’t pay to design the document every time: Claude Code picks up the template you already have and regenerates only the PDF with the new data.
A concrete example: every customer who buys something from your website can automatically receive their ticket, always with the same design.
How do you use PDFCN with Claude Code?
The simplest way is to send Claude Code a request like this:
Create the PDF of my quote with pdfcn
and paste the link to the PDFCN documentation.
The best way is to use a skill, an instruction file that explains to Claude Code how to use PDFCN without mistakes. In my tests, the skill cut costs in half: the average cost per PDF dropped from $1.71 with the link alone to $0.85. I’ve already written it.
PDFCN also works outside Claude Code: you can use it with Codex, Cursor and any other AI agent.
What should you watch out for?
Always check your PDFs before sending them. If your document doesn’t resemble any of the templates in the library, Claude Code may leave some English text in it.
Invoices, reports and tickets are covered by the PDFCN templates. A very unusual document needs an extra read-through.
Where should you start?
Pick the document you produce most often, whether it’s a quote, an invoice or a ticket, and have Claude Code generate it with PDFCN. Once the template is in your project, every following PDF costs you less and comes out the same every time.
Sources
- shadcn-labs/pdfcn — GitHub — Official repository, accessed October 16, 2026: PDFCN is described as free, open-source PDF components for React, under the MIT license
- PDFCN — llms.txt (indice della documentazione) — Official documentation index, accessed October 16, 2026: lists 20 templates (including Event Ticket, Meeting Minutes, Shipping Label, six invoices and four reports), 9 themes and a QR Code component
Want to know what this means for your product?
If you're building software with AI and want a second opinion on how you're working, tell me about your project.
Tell me about your project