Markdown to PDF

I can’t imagine I’m the only one who has an interest in this feature. The GitHub site does a great job of rendering my markdown documents. There’s just one little thing I’d like to see augmented.

I’d like to be able to export my README file (which is in markdown format) in PDF format. Incidentally, there is a way to do so, but the resulting document includes images of HTML elements from the page containing the document. I’d like to find a way of excluding those from the final rendering. I have embedded screenshots to illustrate what it is I’m referring to:

Is there any way I can prevent those elements from being included in the rendering, or remove them after the fact?

Thank you,



I’m not aware of a way to do this using the GitHub website, but you can use a markdown renderer to create the PDF file yourself. Pandoc is my tool of choice for that.

1 Like

You can also create a feature request to add a “export as PDF” button / text link to the file view.

Yes. There are numerous alternatives, of which I’ve tried only a few. Each has its advantages and disadvantages. The most common issue I’ve encountered is the (in)ability to maintain or modify page breaks in the PDF version. In that respect, so far the GitHub renderer has been relatively flawless. Regarding pandoc, I believe it’s a command-line tool. I must admit that, so far, I’ve been steering clear of those. Markdown Monster can export markdown as PDF, as can Visual Studio Code. There are some online converters as well. Most recently I tried an online app called md2pdf. It seems to work fairly well. Perhaps I was a bit hasty. Although it would be nice to have this function built into GitHub, with the right third-party tool it’s really no trouble.

Oops! I just noticed that md2pdf is not loading images. I’m not sure why. I will take a look and update this thread with my findings.

It is, so if you’re not familiar with the command line there may be a little learning curve. Then again, if you use Pandoc you could set up an Actions workflow to automatically build the PDF for you.

I’m not saying that I won’t ever consider the command line. I was a UNIX administrator, after all. But it’s still early. At some point I’m likely to get around to reviewing Pandoc. At first glance, I have to commend Pandoc for providing an installer, rather than relying on a zip file.

$ pandoc -f markdown -t pdf
pdflatex not found. Please select a different --pdf-engine or install pdflatex

Here’s an example of why I have been avoiding the command line. I’m not sure what would be involved in solving this, but it’s just getting more complicated. I’ll have to step back and evaluate my options. In the meantime, I do have alternatives.

I deleted the extra divs using Inspect Element, and then attempted a print using the browser. Turned out fine: youtube-cue.pdf.

The URL I used was youtube-cue/ at 8724ba85aa9cbcbd28156f56e4281d390fc943ca · captn3m0/youtube-cue · GitHub, which avoids the “Commit changes” section already.

Pandoc has convoluted dependencies and different issues across different platforms.

My solution for automatically translating .md to .pdf is:

  • use grip to translate md to html
  • use wkhtmltopdf to translate html to pdf

Here are more details, if interested: