Hail Hydra

pdf mangling in a web service

Chromium seems to have a pretty good cross-platform pdf renderer. It's based on the proprietary Foxit PDF library, which is well regarded. Google opensourced their fork of it eventually. It's called pdfium. This code embeds pdfium in a webserver and uses it to transform and rasterise pdfs

Requirements and dependencies

  • pdfium , get it from here. It's quite a pain to build, and a massive pain to link.
  • Poco C++ framework. I used the version in the Ubuntu 16.04 repos
  • libjpeg-turbo8
  • gcc/g++
  • GNU make

build it

There's a Makefile. You need to point PDFIUM_ROOT at wherever you've built pdfium. The makefile expects you to build products into a directory called 'out' in the pdfium root. If you used something else as a build directory, you'll need to edit that

run it

The binary is called hydra. It listens on http://localhost:2225 forever. It serves a quarter sized version of a file called test.pdf in the directory it is running in as a jpeg.