mikeday
mikeday on Hacker News
Posted by
mikeday on Wednesday February 25, 2026 @11:50PM
from the show-hn dept.
https://prince.cloud
We've been working on Prince for over twenty years and consider it the best way of getting HTML + CSS (and now Markdown!) into PDF, so it's bothered me that AI agents struggle with this, even writing Python programs to generate PDF and then getting confused when you ask for edits. So we've made an MCP server to make PDFs easier!It exposes three tools: markdown_to_pdf, html_to_pdf, and...
Ohhh Nigerian Prince, I thought it was a wrapper for our Prince HTML to PDF formatter, but there is also a JavaScript implementation of Prince of Persia lol.
yeah, we often refer to the first 90% of the work and the second 90% of the work lol.
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.
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 :)
HarfBuzz is more complete (supports more scripts) and higher performance (we assume, haven't benchmarked yet), but the large C++ codebase can be a little intimidating to dive into. We plan to extend Allsorts to reach feature parity with HarfBuzz, so it will be an interesting comparison of tackling a complex problem in Rust!
What about compiling existing OpenType fonts to state machines in combination with the shaping rules? That's something we're thinking about for our Rust implementation :)
It's a wrapper around the native process just to simplify passing command-line arguments. (There is also a persistent process mode for speeding up batch processing of many small documents).
The browsers don't specialise in PDF generation, and we do :)
We use Mercury at YesLogic to write Prince, our HTML to PDF formatter! [1]
We chose it because logic/functional languages are great for tree processing, Mercury was designed for large projects, and because in 2002 there really weren't many other options around.
Its syntax and semantics are derived from Prolog, it borrows a lot from Haskell (types, type classes), in spirit it's reminiscent of OCaml (niche, little weird) and with support for unique modes there is some interesting overlap with Rust, although this aspect of the language still needs more compiler support.
All in all, definitely worth checking out.
[1] https://www.princexml.com/
Posted by
mikeday on Saturday October 08, 2016 @07:48AM
from the paul.bone.id.au dept.