How to convert HTML to PDF using pandoc?

What libraries do I need? What command line parameters do I need to pass?

I installed wkhtml2pdf and I tried to run:

pandoc reports/7/report.html -t pdf -o reports/7/report.pdf

Which reports the error:

To create a pdf with pandoc, use the latex or beamer writer and specify
an output file with .pdf extension (pandoc -t latex -o filename.pdf).

      

+3


source to share


2 answers


pdf

is not a valid output format. latex

and beamer

(for latex slideshow).

To create a pdf file, use -t latex

and -o myoutput.pdf

. You can omit the argument -t

since a .pdf

in -o

is latex by default. So you can use either:

pandoc reports/7/report.html -t latex -o reports/7/report.pdf

      



or

pandoc reports/7/report.html -o reports/7/report.pdf

      

+3


source


From https://pandoc.org/MANUAL.html :



Alternatively, pandoc can use any of the following HTML / CSS-to-PDF engines to generate PDF:

To do this, specify the output file with the .pdf extension, as before, but add the parameter - pdf-engine or -t context, -t html or -t ms, so that on the command line ( -t html is used by default - pdf-engine = wkhtmltopdf ).

+1


source







All Articles