DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Convert Markdown Files to PDF Files on Linux


Use pandoc to convert a markdown file to MS Word file on Linux system:

sudo apt-get install pandoc
pandoc input.md -o output.docx

To convert it to pdf file, you have to install texlive first:

sudo apt-get install texlive   // this is a big package, 281MB to download
sudo apt-get install texlive-xetex lmodern etoolbox
pandoc MyResume.md -o Resume.pdf --latex-engine=xelatex -V mainfont='WenQuanYi Micro Hei'

Get all installed fonts with fc-list on Linux Mint.

Note1: If there no Unicode characters (such as Chinese characters) in the markdown file, use 'DejaVu Sans Mono' instead of WenQuanYi, much better than the latter.

Note2: pandoc myresume.md -s -o test1.pdf met "Error producing PDF from TeX source. ! Package inputenc Error..." on Linux Mint 17, i3wm.

Note3: The page margin of the default pdf file is too large. Don't know how to set margin yet.

Note4: The wkhtmltopdf can't convert hyperlinks in html to pdf files properly. So this is not a valid options.

To convert a resume file (markdown) to html:

$ pandoc myresume.md -f markdown -t html -s -o resume.html

or simply "pandoc myresume.md -s -o resume.html", the "-s" option is necessary, or Chinese characters will be massed up.

The personal information section (name, address, email, mobiles, etc) is left-aligned, while they should be centered. However there isn't "centering" format in markdown, so I have to add this format manually in created html files:

$ vi resume.html
// add "<DIV ALIGN=CENTER>" before the centering section
// add "</DIV>" after the centering section


Published

Jun 30, 2014

Last Updated

Jun 30, 2014

Category

Tech

Tags

  • convert 7
  • linux 158
  • md 1
  • pdf 8

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor