Tuesday, October 11, 2016

How to - Convert MkDocs to PDF

I has been requested to create website that will use as Term of Services and Privacy Policy on our services, I am dealing with future changes and I want people get alert and know what has been modified soon. I found out creating simple static page are more convinince. I'am using MkDocs - Project documentation with Markdown as the platform which is quite simple. This documentation site are using markdown and python. I recorded any changes using our private git as tracker. Simply just install Python and PIP then pull mkdocs via pip command. The problem is, MkDocs does't have any built in PDF converter so we need to install pandoc, mkdocs-pandoc and few Tex library to compile the documentation into PDF.

$ sudo pip install pandoc
$ sudo pip install mkdocs-pandoc
$ sudo apt-get install texlive-full

To convert written MkDocs into PDF just type this command :
$ mkdocs2pandoc > myFile.pd
$ pandoc --toc -f markdown+grid_tables+table_captions -o myFile.pdf myFile.pd

That all, Adios!


  1. This did not work for me... I wonder if "pip install pandoc" should be "pip install pypandoc"

    When I tried it run pandoc, it had problems with the relative links, and failed.

    For example (one of many such message):

    pandoc: Could not find image `/home/mike/docs-3/site/integration/../img/integration/oauth_info_confirm.jpg', skipping...

    1. You path to relative file is wrong (possibly)