Create Landscape PDF with Pandoc using wkhtmltopdf

Viewed 264

I am trying to create PDF with landscape orientation in Pandoc.

I am using WkHtmlToPdf as a PDF Engine. I chose not to use LaTeX. Here is the command I am using:

pandoc test.md -t html -o test.pdf

But it creates a portrait orientation. How can I create PDF in landscape mode?

Things I have tried without success

pandoc -V geometry:landscape test.md -t html -o test.pdf

pandoc -O landscape test.md -t html -o test.pdf

Please help.

Note: I do not want to use LaTeX as my PDF engine.

1 Answers

Please try this:

pandoc test.md -t html \
       --pdf-engine-opt="-O" --pdf-engine-opt="Landscape" \
       -o test.pdf

Pandoc doesn't know the -O option, it must be given to wkhtmltopdf. Use --pdf-engine-opts, once for each option or argument that you want pandoc to pass to the pdf engine.

The above was tested and succeeds on:

Ubuntu 20.04
pandoc 2.5
wkhtmltopdf 0.12.5
Related