Katherine Eaton's Obsidian Vault

Back

wkhtmltopdf

wkhtmltopdf

  1. Configure Ubuntu ```bash sudo vi /etc/apt/sources.list

#add following line at the end of file

deb http://security.ubuntu.com/ubuntu bionic-security main

sudo apt update && apt-cache policy libssl1.0-dev sudo apt-get install libssl1.0-dev


2. Install with mamba.
```bash
mamba install -c bioconda wkhtmltopdf

pandoc

  1. Test regular pandoc PDF export.
    pandoc -s wkhtmltopdf.md -o wkhtmltopdf.pdf
    
  2. Use default CSS
    pandoc -s wkhtmltopdf.md -o wkhtmltopdf_html5.pdf -t html5
    
  3. Use killercup CSS ```bash pandoc -s wkhtmltopdf.md -o wkhtmltopdf_killercup.html -t html5 –css pandoc/templates/killercup/killercup.css

pandoc -s wkhtmltopdf.md -o wkhtmltopdf_killercup.pdf -t html5 –css pandoc/templates/killercup/killercup.css


6. Use GitHub CSS

```bash
pandoc -s wkhtmltopdf.md -o wkhtmltopdf_github.html -t html5 --css pandoc/templates/github/github.css
pandoc -s wkhtmltopdf.md -o wkhtmltopdf_github.pdf -t html5 --css pandoc/templates/github/github.css

7 Use MVP CSS

pandoc \
  -s wkhtmltopdf.md \
  -o wkhtmltopdf_mvp.pdf \
  -t html5 \
  --css pandoc/templates/pandoc-mvp-css/css/mvp.css \
  --template pandoc/templates/pandoc-mvp-css/template.html

HTML -> PDF

  1. Convert wiki links
    ./pandoc/convert_wikilinks.py --input wkhtmltopdf.md --output wkhtmltopdf_convert.md
    
  2. Convert to HTML with desired CSS.
pandoc \
  -s wkhtmltopdf.md \
  -o wkhtmltopdf_mvp.html \
  -t html5 \
  --css pandoc/templates/pandoc-mvp-css/css/mvp.css \
  --template pandoc/templates/pandoc-mvp-css/template.html
  1. Convert HTML to PDF
wkhtmltopdf wkhtmltopdf_mvp.html wkhtmltopdf_mvp.pdf

wkhtmltopdf --zoom 1 wkhtmltopdf_mvp.html wkhtmltopdf_mvp.pdf

–zoom –dpi and –disable-smart-shrinking