Member-only story
How I use markdown-pdf to create PDF documents with Python
The markdown-pdf
module allows us to create PDF documents, via Python code. It takes a markdown formal file as its source, which is a simple text file that an be easily generated by hand, or created using Python code.
What is PDF
PDF is a standard file format for storing documents containing formatted text, images, and other elements. Unlike many other popular formats, the content of a PDF file will have an identical appearance wherever it is viewed. You can use any PDF reader software on any operating system, and the content will look exactly the same. You can view it on the web, using any browser, or print it on any office printer, or sell it on Amazon as either an ebook or a physical book, the content will always look exactly the same.
This level of versatility and predictability makes PDF a very useful format whenever you want to guarantee the appearance of the document. For example:
- A report, where you might want to avoid data tables potentially getting mangled when someone views it.
- An invoice, where you need to be sure the company branding and billing information are preserved.
- A brochure, where you want the customer to see it exactly as the marketing department intended.
- A book, where it might be very important that certain text and images appear together on the same page.