Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pandoc and html5 exporting pdf's with huge margins

So I'm trying Pandoc for the first time. Everything seems great but when exporting via html5 (wkhtmltopdf) my pdf output is saved with huge margins on all sides.

pandoc -t html5 -s example.md -o output.pdf

output.pdf (content output highlighted in red)

What I've tried:

  • Reinstalling pdflatex
  • Reinstalling wkhtmltopdf
  • Including CSS to remove the margins

Am I missing something?

What I want: Write a markdown document using Typora -> Use Pandoc to apply TOC and page numbering -> Use html5 to export pdf with custom styling.

like image 789
D. Ant Avatar asked Sep 04 '17 16:09

D. Ant


People also ask

Can Pandoc convert from PDF?

You can't. You can try opening the PDF in Word or Google Docs and saving in a format from which pandoc can convert directly.

Can Pandoc convert HTML to Markdown?

After downloading a website as HTML with cURL or any other workflow, you can convert the HTML code to the Markdown syntax with pandoc .

How do I convert Markdown to PDF in Pandoc?

Generating PDF from Markdown with Pandoc There are actually two steps involved in converting a Markdown file to a PDF file: The Markdown source file is converted to a LaTeX source file. Pandoc invokes the pdflatex or xelatex or other TeX command and converts the . tex source file to a PDF file.


1 Answers

These pass through vars for wkhtmltopdf worked for me (ubuntu 18.10 pandoc 2.6) : https://pandoc.org/MANUAL.html#variables-for-wkhtmltopdf

pandoc -t html5 -V margin-top=3 -V margin-left=3 -V margin-right=3 -V margin-bottom=3 -V papersize=letter -s example.md -o output.pdf

(Oddly wkhtmltopdf required all margins be the same.)

like image 133
orbvek Avatar answered Sep 25 '22 07:09

orbvek