r/rails • • 9h ago

A maintained drop-in for wkhtmltopdf: same command, so wicked_pdf apps keep their templates

I built marqius-wkhtmltopdf with my company. It is a drop-in replacement for wkhtmltopdf, built from scratch on its command line.

What it has that the Chromium routes do not: the command and the options are the same, so the templates in a wicked_pdf or PDFKit app stay as they are. There is no browser to run. It is one statically linked file.

In a Rails app it is one line in the Gemfile, in place of `gem "wkhtmltopdf-binary"`:

gem "marqius-wkhtmltopdf"

wicked_pdf and PDFKit find the program by themselves. It installs on Heroku-24, Debian 13, Alpine and macOS on Apple silicon. I ran it today on Ubuntu 22.04, Ubuntu 24.04 and macOS.

I am glad to hear where a PDF of yours prints differently. That is the feedback we work from.

Gem: https://rubygems.org/gems/marqius-wkhtmltopdf

Guide: https://marqius.com/wkhtmltopdf/rails-ruby/

Disclosure: I build Marqius. The Community licence is free for personal and open-source projects; the commercial licence is for businesses. Plans and licences: https://marqius.com/wkhtmltopdf-buy/

7 Upvotes

6 comments sorted by

6

u/IGotRangod 7h ago

1

u/ArdorWaheguru 5h ago

the commercial backing might actually be the selling point for teams that dont want to rely on an unmaintained solo repo for billing pdfs

0

u/Sea_Pianist_9694 4h ago

Exactly. An unmaintained repo is the whole risk. wkhtmltopdf was open source, and that is how it died: nobody was paid to maintain it. A paid licence is what keeps a replacement alive. That is also my answer to "why is it not open source".

The parts you need to trust it stay open: the test suites, the examples and the CI. Every release is tested in public.

1

u/Sea_Pianist_9694 6h ago

If your templates are simple and you are starting fresh, a new engine can be the better fit. If you have years of wkhtmltopdf templates, this is the one that changes nothing.

Fair question, though, and I can only speak for what I built.

Marqius keeps wkhtmltopdf's command line, with the same options. So **your templates print as they did**, and there is nothing to re-check. I tested that with wicked_pdf, PDFKit, pdfkit, imgkit, Snappy and phpwkhtmltopdf.

Beyond that:

- One statically linked file. No Qt, no X server, no browser to install.

- It installs where the old program no longer does: Ubuntu 26.04, Debian 13, Alpine, and macOS on Apple silicon.

- It makes images too. `wkhtmltoimage` is in the same file.

- The files are small. In one test this week, a picture that the old program wrote at 5.4 MB came out at 174 KB.

The trade-off is the licence. There are two licences. The Community licence is free: for personal projects, for teaching and learning, and for open-source projects, including their CI test runs and documentation builds. The commercial licence is for businesses.

If you want to see one of your own templates through it, send it over.

2

u/Easy-Comfortable-587 2h ago

The rendering of some of the fonts in wicked pdf are not upto to the standard so better if you can improve that. 

1

u/Sea_Pianist_9694 1h ago edited 1h ago

Thanks for pointing that out.

Some of that is already in place, and the rest can be. Marqius draws the page with its own engine, so its fonts can be improved. wkhtmltopdf, which wicked_pdf calls, is archived and will never change.

It already does two things better. It tells you when a font your template asks for is not on the server; wkhtmltopdf swaps in another one without a word. And when a server has no font for Thai, Japanese, Chinese or Korean, one command fetches it; there wicked_pdf prints blocks.

For fonts that are installed, it looks the same as wicked_pdf today.

Which fonts look wrong to you? A small HTML snippet is enough. I will test it.