Better HN
topnewbestaskshowjobs
Log inSign up

mikeday

52 karma · joined Dec 26, 2012 (13y ago) · 10 submissions

Working on Prince to get HTML + CSS into PDF
Submissions

1.

Show HN: Prince Cloud – Create PDFs with AI Agents(prince.cloud ↗)

2 points · by mikeday · 9mo ago · discuss

comment 1y ago · link · parent

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.

comment 1y ago · link · parent

yeah, we often refer to the first 90% of the work and the second 90% of the work lol.

comment 1y ago · link · parent

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.

comment 1y ago · link · parent

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 :)

comment 7y ago · link · parent

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!

comment 7y ago · link · parent

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 :)

comment 8y ago · link · parent

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 :)

comment 8y ago · link · parent

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/

10.

Memory Fragmentation in the Boehm-Demers-Weiser Garbage Collector(paul.bone.id.au ↗)

1 points · by mikeday · 10y ago · discuss