Gangmax Blog

自由之思想,独立之精神

Pandoc: Convert HTML to PDF

| Comments

The goal is to use “pandoc” to convert a given html page to a PDF file.

From here, here, here and here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Install the required packages.
sudo apt-get install pandoc
# The following packages are also needed otherwise running "pandoc" will get errors.
sudo apt-get install texlive-fonts-recommended texlive-latex-extra  texlive-lang-chinese texlive-xetex

# Convert an HTML page in English into PDF.
pandoc ./clojure.html -o ./clojure.pdf

# Convert an HTML page in Chinese into PDF.
pandoc --latex-engine=xelatex -V CJKmainfont="WenQuanYi Micro Hei" ./clojure_cn.html -o ./clojure_cn.pdf
# To select a font, you may need to run the following command to know
# the fonts support Chinese on your OS:
fc-list :lang=zh
# In my case I chose the "WenQuanYi Micro Hei" font.

Comments