Menu

Post image 1
Post image 2
1 / 2
0

I Spent a Week Fighting HTML-to-PDF. Here’s What Finally Worked.

DEV Community·Graham Sutton·26 days ago
#4v3i71ut
#webdev#programming#rust#pdfs#documents#pages
Reading 0:00
15s threshold

I’ve been building a property inspection platform with a friend of mine who’s an inspector. One of the requirements was deceptively simple: Generate PDF reports. That’s the deliverable inspectors send to insurance companies, banks, clients, etc. So the PDFs need to actually look good. Lots of photos, cover pages, tables of contents, structured sections, all that fun stuff. My friend uses Spectora right now and honestly their PDFs were pretty good. So I figured, alright, let me build something similar. I thought this would take maybe a day or two. I was wrong. The HTML-to-PDF rabbit hole I started where everyone starts: wkhtmltopdf headless Chrome random PDF libraries CSS print layouts "surely this StackOverflow answer will solve it" Every single path turned into pain. Stuff would randomly overflow pages. CSS that worked perfectly in the browser suddenly looked completely different in the PDF. Headers and footers were especially awful.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More