Re:The Hardest Program I've Ever Written (2015)
by PaulKeeble on Saturday November 01, 2025 @05:31PM
(#45785593)
About the worst job on any enterprise software project is the PDF output, they always end up doing it for emails or something else and its a never ending list of bugs. Text formatting is a never ending list of problems since its so got a lot of vague inputs and a relatively strict output. Far too many little details go wrong.
[ Parent
| on HN ]
Re:The Hardest Program I've Ever Written (2015)
by vbezhenar on Saturday November 01, 2025 @07:19PM
(#45786393)
With PDF, my best approach was to go very low level. I've used PDFKit and PDFBox libraries and both provide a way to output vector operations. It allows to implement extremely performant code. The resulting PDF is tiny and looks gorgeous (because it's vector). And you can implement anything. Code will be verbose, but it's worth it.
I even think that it's viable to output PDF without any libraries. I've investigated that format a bit and it doesn't seem too complicated, at least for relatively dumb output.
Re:The Hardest Program I've Ever Written (2015)
by kbbgl87 on Saturday November 01, 2025 @08:18PM
(#45786760)
Thinking about phantomjs and rasterize brings back nightmares
Re:The Hardest Program I've Ever Written (2015)
by mikeday on Saturday November 01, 2025 @09:34PM
(#45787129)
We've spent twenty years working on HTML to PDF conversion and I expect we could easily spend another twenty years, so feel free to give Prince a try if you would rather avoid the headache :)
Re:The Hardest Program I've Ever Written (2015)
by twotwotwo on Sunday November 02, 2025 @01:58AM
(#45788355)
Awesome. From curiosity: is Prince's core still written in Mercury? (Looked at old comments.)
Re:The Hardest Program I've Ever Written (2015)
by mikeday on Sunday November 02, 2025 @03:39AM
(#45788783)
Absolutely! The CSS support, layout engine, PDF output, and JavaScript interpreter are all written in Mercury, while the font support that was originally a mix of Mercury and C has now been rewritten as a standalone Rust project, Allsorts.
Re:The Hardest Program I've Ever Written (2015)
by PaulKeeble on Sunday November 02, 2025 @07:34AM
(#45789849)
Normally when we are nearly there we say its 95% done and only 95% of the work remains. If your feeling is you are half done I suspect more than 50% of the work remains!
What I know having done a lot in this space is we aren't close!