I am generating complex user documentation using Markdown files and combining them with markedpp. I am currently using pandoc to convert to a DOCX file, but that requires some nasty hoop jumping in the Markdown to accomplish page breaks and such. I would prefer to generate a PDF, but every Latex to PDF converter barfs on the combined Markdown document saying there are too many sections. The Markdown is a combination of hand-crafted text and tool generated templates; simplifying it isn't going to be easy or cost effective.

Is there a good solution for creating print-oriented Markdown that renders to PDF that doesn't involve Latex or DOCX?

It can be either for Windows or Linux, I am running Windows 10 2004 with WSL2 enabled. Cost needs to be zero. I am doing this for a client and am trying to establish a repeatable process for all of our clients where project documentation is a mix of hand-rolled Markdown and auto-generated Markdown for database and code resources. Having the output be a generated PDF that can be digitally signed (signing will be manually done) to ensure integrity of the information within is a huge plus.

  • That's actually another question I have: Is there a set oif extensions to Markdown to add print-oriented features? – The Sharp Ninja Jul 27 '20 at 16:46
  • I've found a PowerShell module that will export PDF from DOCX using Office Interop, and it works great, but it still has the DOCX target in the middle, which I'd like to eliminate. – The Sharp Ninja Jul 27 '20 at 16:48
  • Did you ever have a look at doxygen, maybe this can be of use. – albert Jul 28 '20 at 12:54

An alternative to combining markdown pages then generating PDF is to generate the seperate PDFs, then combine the PDFs. I know and like PDFsam for this task. For a command-line interface, PDFsam proposes the open-source sejda which is used internally as the library to make PDFsam work.

  • What tool generates the PDF from Markdown in your chain? – The Sharp Ninja Jul 28 '20 at 2:46
  • @TheSharpNinja pandoc should be fine – kutschkem Jul 28 '20 at 5:36
  • pandoc uses TeX to generate a PDF and I haven't found a TeX processor yet that doesn't barf on 40 pages of markdown. – The Sharp Ninja Jul 28 '20 at 10:00

You can create excellent pdfs using Report Lab, either the Open Source or Commercial versions of Report Lab. As it is the power behind the Wikipedia "Download as PDF" functionality it can definitely handle complex content.

It is used as a back-end by the python rst2pdf libary.

The simplest process, (lifted from the book Report Lab - PDF Processing in Python by Michael Driscoll), would be:

Mark Down Content -> Pandoc -> restructuredText -> rst2pdf -> PDF File.

This is the process that Mike used for his book.

Note: While I am credited in the above book I have no financial interest in it.

  • Which Markdown dialects does it support (note OP explicitly asked for Markdown)? – Izzy Jul 27 '20 at 16:07
  • Their site is not clear on it's markdown parsing abilities in the free version. – The Sharp Ninja Jul 28 '20 at 2:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.