Markdown to PDF
This repository contains a simple script that converts Markdown and CSS into PDF documents. The heavy lifting is done by Python-Markdown, a tool for generating HTML from Markdown, and WeasyPrint, a tool for generating PDF documents from HTML and CSS. With this script, my CV in Markdown is converted into a PDF document.
- Install pyenv, a tool for managing Python versions.
- The file
.python-versionin the root folder specifies the Python version required by the conversion script. Navigate to the root folder and execute
pyenv installto install this Python version.
gdk-pixbuf. On macOS, these tools can be installed with
- Install pipenv by executing
pip install pipenv. There's an issue related to language and region settings that you might run into on Macs, but it's easy to resolve.
- Create a new virtual environment with all dependencies by executing
pipenv install --dev --ignore-pipfile. The flag
ignore-pipfileis used to indicate that the exact versions of the dependencies as specified in
Pipfile.lockshould be installed. The flag
devis used to also install development dependencies.
Activating the virtual environment
Before executing any of the commands below, you need to activate the virtual environment.
You can do so by executing
Your command prompt should now indicate that you've activated the virtual environment.
It can be deactivated by executing
examples folder contains a CV and a quotation.
python md2pdf.py convert examples/cv.md examples/cv.cssto generate a PDF version of the CV.
python md2pdf.py convert examples/quotation.md examples/quotation.cssto generate a PDF version of the quotation.
When writing or designing documents, you can use
python md2pdf.py watch <document_name>.md <stylesheet_name>.css.
This will watch the given files and generate new output when they change.
Both an HTML document and a PDF document are generated.
The HTML document is generated because it's convenient to be able to play around with the CSS in a browser.
CSS for print
If you want to design your own documents, take a look at designing for print with CSS by Rachel Andrew.