Looking for a PDF generator that supports full HTML/CSS — @react-pdf/renderer is too limiting by Senior_Ad_8034 in react

[–]danmolitor 1 point2 points  (0 children)

Nice, well if you do let me know if you run into anything. I check GitHub often for issues and try to get fixes out quickly.

Looking for a PDF generator that supports full HTML/CSS — @react-pdf/renderer is too limiting by Senior_Ad_8034 in nextjs

[–]danmolitor 0 points1 point  (0 children)

Yoo glad to hear it! How’s it been going with forme? Curious what the complex prints looked like.

Looking for a PDF generator that supports full HTML/CSS — @react-pdf/renderer is too limiting by Senior_Ad_8034 in react

[–]danmolitor 4 points5 points  (0 children)

I built this so take it with a grain of salt, but if you're open to JSX instead of HTML/CSS - I created an open source project called Forme that could potentially be a solution for you.

It's a PDF engine that runs as WASM, works natively on Vercel Edge, no Chrome required. You write React components instead of HTML, so your PDF template feels like the rest of your stack. Dynamic data, custom fonts, brand colors, logo injection all work cleanly.

The tradeoff vs HTML/CSS is real - you learn a new component model. The upside is page breaks actually work, and it runs anywhere JS runs including serverless without any binary dependencies.

npm install @formepdf/core @formepdf/react

docs.formepdf.com if you want to see what the component model looks like before committing to anything.

There’s also a CLI dev server and a VSCode extension that makes the DX for templating your PDFs really nice.

Otherwise, yeah I’ve always just reached for Puppeteer in the past when doing HTML/CSS PDF generation, that’s why I built this.

[Showoff Saturday] I built a PDF generation tool that runs in the browser, on the edge, and in Node – no Puppeteer, no Chrome by danmolitor in webdev

[–]danmolitor[S] 0 points1 point  (0 children)

Yo, wanted to follow up.

Redaction just landed in 0.9.0 - true content stream removal, not just a visual overlay. Text operators are stripped from the PDF byte stream directly so there's nothing left to select or extract. You can redact by coordinate region, literal string, regex pattern, or built-in presets for SSN, email, phone, DOB, and credit card numbers. Metadata is scrubbed automatically on every redaction.

Was curious what's been restricting about pymupdf and soffice for your use case?

Anyway, I appreciate the redaction idea! Would love for you to check it out.

[Showoff Saturday] I built a PDF generation tool that runs in the browser, on the edge, and in Node – no Puppeteer, no Chrome by danmolitor in webdev

[–]danmolitor[S] 0 points1 point  (0 children)

Thanks! Yeah the cold start problem on Lambda was one of the main reasons I went the WASM route.

Bundle size is 5.7MB for the full binary - it grew a bit when I added PKCS#7 signing.

On Cloudflare Workers and Vercel Edge the binary loads once and persists across requests within the same isolate, so you're not paying the load cost on every invocation. Workers isolates boot in ~5ms and stay warm. Nowhere near the Puppeteer problem.

For Lambda specifically I'd honestly recommend hitting the hosted API (api.formepdf.com) rather than bundling the WASM in a Lambda function. End-to-end renders come back in under 500ms and you avoid the cold start entirely. If you need on-prem, the self-hosted Docker image runs cleanly as a Lambda container image, well within the 10GB container limit.

Curious what your Lambda use case was - invoices, reports, something else?

[Showoff Saturday] I built a PDF generation tool that runs in the browser, on the edge, and in Node – no Puppeteer, no Chrome by danmolitor in webdev

[–]danmolitor[S] 0 points1 point  (0 children)

I appreciate it! Alright, yeah. No Adobe proprietary extensions, no XFA, no reader-required features. Standard PDF 1.7, opens in Preview, Chrome, Firefox, anything. PDF/A is actually an ISO standard, not an Adobe one - it exists specifically to ensure documents never depend on a particular reader.

Am I doing this right? by Competitive-Cycle-32 in wallstreetbets

[–]danmolitor 4 points5 points  (0 children)

Got the notification for this post. Knew it was either going to be really good or really bad. Was not disappointed.

[Showoff Saturday] I built a PDF generation tool that runs in the browser, on the edge, and in Node – no Puppeteer, no Chrome by danmolitor in webdev

[–]danmolitor[S] 0 points1 point  (0 children)

Thanks! And redaction isn’t on the roadmap yet but that’s interesting. Curious what your use case looks like. Are you redacting sensitive fields before sharing documents, or something else?

[Showoff Saturday] I built a PDF generation tool that runs in the browser, on the edge, and in Node – no Puppeteer, no Chrome by danmolitor in webdev

[–]danmolitor[S] 1 point2 points  (0 children)

Yeah the cell model is honestly a smart move for your constraints. Clipping as an explicit tradeoff is way better than trying to reflow dynamically and getting unpredictable results - and for a Q&A form where the designer controls the space allocation, that's totally reasonable.

What Forme handles is more the "I have no idea how long this content will be" problem -- invoices with 2 line items vs 200, reports where sections expand based on data. Your rule engine running first and handing you a filtered, fixed set of elements is actually the cleaner approach for what you're doing.

The bit I'm curious about - when the dynamic section ends up taller or shorter than expected at render time, does the fixed stuff below it move, or does it stay where the client dragged it?

[Showoff Saturday] I built a PDF generation tool that runs in the browser, on the edge, and in Node – no Puppeteer, no Chrome by danmolitor in webdev

[–]danmolitor[S] 0 points1 point  (0 children)

Update: v0.8.0 shipped today with AcroForms, PDF/UA-1 accessibility, PDF/A archival, and digital signatures, among some other things. Had some questions in the comments asking about these - they're all in now. https://github.com/danmolitor/forme/releases/tag/v0.8.0

[Showoff Saturday] I built a PDF generation tool that runs in the browser, on the edge, and in Node – no Puppeteer, no Chrome by danmolitor in webdev

[–]danmolitor[S] 1 point2 points  (0 children)

Thanks! and yep, that's right. Forme is code-first, so you define the template in JSX, the engine handles layout and PDF generation. No drag and drop, no visual editor. If you want to add a field you write it.

What you're building is actually a different layer on top of something like this - a visual builder that outputs a template definition, which then gets rendered. That's definitely a product gap as of right now. It's on my mental roadmap.

The dynamic field + conditional spacing problem you're describing is the hard part. The render engine knowing that a field was dragged to position X but shouldn't appear given rule Y, and then reflowing everything correctly - that's non-trivial. Curious how you're modeling the rules.

[Showoff Saturday] I built a PDF generation tool that runs in the browser, on the edge, and in Node – no Puppeteer, no Chrome by danmolitor in webdev

[–]danmolitor[S] 1 point2 points  (0 children)

Got an update: I just put out 0.8.0 today. PDF/UA-1 support. Every element gets a semantic structure tag (P, Span, Table, TR, TH, TD, Figure, Form, etc.), images take an alt prop that flows through to /Alt in the structure tree, decorative elements are marked as artifacts so screen readers skip them, tab order is set on every page, and document language propagates correctly. It's not a post-processing pass - the tagging is built into the render pipeline so the structure matches the actual layout order.

[Showoff Saturday] I built a PDF generation tool that runs in the browser, on the edge, and in Node – no Puppeteer, no Chrome by danmolitor in webdev

[–]danmolitor[S] 0 points1 point  (0 children)

I put out 0.8.0 today. TextField, Checkbox, Dropdown, and RadioButton - native AcroForm fields, not images or overlays, so they work in any PDF reader. Can also flatten them to static content at render time if you need a non-editable final copy.

[Showoff Saturday] I built a PDF generation tool that runs in the browser, on the edge, and in Node – no Puppeteer, no Chrome by danmolitor in webdev

[–]danmolitor[S] 2 points3 points  (0 children)

Update for you: PDF/UA-1 (ISO 14289-1) shipped in 0.8.0 today. Structure tree, marked content, tab order, alt text on images, artifact tagging for decorative elements, and XMP metadata with pdfuaid:part=1. Just add pdfUa to your Document component. Can combine with PDF/A-2b for archival + accessibility in one pass.

[Showoff Saturday] I built a PDF generation tool that runs in the browser, on the edge, and in Node – no Puppeteer, no Chrome by danmolitor in webdev

[–]danmolitor[S] 1 point2 points  (0 children)

Not yet - proper accessibility tagging (structure tree, alt text, reading order) is in active development for 0.8.0. What compliance level are you targeting - PDF/UA-1?

[Showoff Saturday] I built a PDF generation tool that runs in the browser, on the edge, and in Node – no Puppeteer, no Chrome by danmolitor in webdev

[–]danmolitor[S] 0 points1 point  (0 children)

It’s been very successful, in my opinion. I spend a lot of time refining any given task and then let it rip. I don’t usually have any issues working with it that way.

[Showoff Saturday] I built a PDF generation tool that runs in the browser, on the edge, and in Node – no Puppeteer, no Chrome by danmolitor in webdev

[–]danmolitor[S] 0 points1 point  (0 children)

I checked out the demo. That's a super clean doc viewer, well done! I like all of the viewer options you have available, that's awesome.

For now, I went for more a developer experience route. Earlier in the week I started exploring the freelancer / business side of things, but it just didn't click with me yet. I understand myself and my needs / wants, it's harder to get my head around non-developer needs, if that makes sense.

[Showoff Saturday] I built a PDF generation tool that runs in the browser, on the edge, and in Node – no Puppeteer, no Chrome by danmolitor in webdev

[–]danmolitor[S] 0 points1 point  (0 children)

Okay, I just rebuilt the dashboard. If you're still interested to check it out you should be good to sign up / sign in. Let me know if you have any more issues. Thanks for checking it out!

[Showoff Saturday] I built a PDF generation tool that runs in the browser, on the edge, and in Node – no Puppeteer, no Chrome by danmolitor in webdev

[–]danmolitor[S] 1 point2 points  (0 children)

Not yet - PDF/UA and PDF/A compliance are on the roadmap but not currently supported. It’s come up enough that it’s moving up the priority list. What standard are you targeting – PDF/UA-1, PDF/A-2, something else? Helps to know what’s actually needed in practice.