Generating PDFs from Pelican Articles

As of mid-2013, Pelican still advertised PDF generation of articles/pages as one of its features. However, the change log indicates that this is no longer a core feature and has since become a Pelican plugin as of version 3.3.0 (2013-09-24), see issue for further discussion. Therefore, it was rather confounding to find the setting PDF_GENERATOR to be listed in the examples settings of version 3.5.0, and of course, to no one's surprise, adding the setting PDF_GENERATOR=True isn't going to do anything.

If you have used Pelican plugins before, then the solution should be obvious. Simply install the pdf plugin from Pelican plugins. I personally prefer to keep all plugins (and themes) in the <pelican_site_root> directory, on the same level as the pelicanconf.py settings file:

$ cd <pelican_site_root>
$ mkdir plugins
$ git clone https://github.com/getpelican/pelican-plugins.git plugins

Optionally, you can also add the repository as a submodule:

$ git submodule add https://github.com/getpelican/pelican-plugins.git plugins

or clone it anywhere else you like for that matter.

Lastly, you simply need to add plugins to PLUGIN_PATHS and pdf to PLUGINS. The former will temporarily add PLUGIN_PATHS to your system path so that the latter is importable:

PLUGIN_PATHS = ['plugins']
PLUGINS = ['pdf']

When you run pelican (or make html), the generated PDFs of your articles will appear in the pdf directory of the output directory, named according to the article slug with the .pdf extension.

In my opinion, the generated PDFs aren't exactly terrific, and the plugin could do with a little bit more work.

Note

If you happen to be using the notmyidea theme, a link get the pdf will appear by simply adding PDF_PROCESSOR=True to your settings (as of commit a7ca52).

Comments

Comments powered by Disqus