This article explain how to configure PDF-Tilt in a middleman project.
After hours of investigations it turned out to be easier than expected, initially I have tried to make an extension and register a custom made engine into tilt, after numerous fails google came in handy once again with pdf-tilt implementation.
Note: pdf-tilt relies on PDFKit which in its turn relies on wkhtmltopdf.
wkhtmltopdf needs an X server (screen), and in my case using Ubuntu Saucy some dependencies for the patched (full feature) version ware hard to be satisfied, I found no solution so far.
For a working solution here is what you can do:
${projectPath}/Gemfile
...
gem 'pry'
gem 'tilt-pdf'
...
shell in ${projectPath}
$ bundle install
shell
$ sudo apt-get install wkpdftohtml
For a more detailed installation instructions or other OS please refer to : http://wkhtmltopdf.org/downloads.html
${projectPath}/config.rb
...
page "*.pdf", :layout => false
...
The preparation is ready, now you can create your source file for the pdf, add in your project sources a file named test.pdf.rpdf.
This file is actually a yml format file which links together what is going to be send as parameters to wkpdftohtml, the file format is described here : https://github.com/lloeki/tilt-pdf
In my example I striped all the unsupported parameters:
${projectPath}/source/test.pdf.rpdf
page-size: A4
main: index.haml
stylesheets:
- stylesheets/pdf.css
Browser
http://localhost:4567/test.pdf
A last note : if a parameter is unrecognized wkpdftohtml will throw an error, look into server console for it.