News for hackers. Stuff that matters.

mikeday

Show HN: Prince Cloud – Create PDFs with AI Agents

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...

( Read More... | no comments | 2 points | on HN )
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.
Re:The Hardest Program I've Ever Written (2015) on Sunday November 02, 2025 @03:35PM (#45793191)
yeah, we often refer to the first 90% of the work and the second 90% of the work lol.
Re:The Hardest Program I've Ever Written (2015) 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) 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:Allsorts: font parser and shaping engine implemented in Rust on Tuesday November 19, 2019 @09:36PM (#21580646)
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 :)
Re:The Mercury programming language on Thursday November 08, 2018 @02:29AM (#18404847)
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 :)

Re:The Mercury programming language on Wednesday November 07, 2018 @11:32PM (#18404337)
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/