Pandoc
You can use Pandoc to generate PDF's directly from other document formats, like Markdown, wikitext, Libre Office or PDF.
Pandoc is an universal document converter - converts from one markup language onto another
Extensive documentation: Pandoc’s Manual or man pandoc
Pandoc common arguments
-f - option standing for “from”, is followed by the input format
-t - option standing for “to”, is followed by the output format
-s - option standing for “standalone”, produces output with an appropriate header and footer
-o - option for file output
changing the default template
$ pandoc --from markdown --to html --print-default-template=html5 > template.html $ pandoc --from markdown --to html --template template.html input.md -o output.html
A range of PDF engines are supported at the moment, including Paged.js
, weasyprint
and LaTeX
. You need to select the one of choice using the --pdf-engine
option, and have the PDF engine installed on your computer.
You can follow this page for instructions: https://pandoc.org/MANUAL.html#creating-a-pdf
Examples
Convert HTML string to markdown
echo "<h1>Hello Pandoc</h1><p>from html to markdown</p>" | pandoc -f html -t markdown
Mediawiki file to HTML
- Save the content of a wiki page on to a plain-text file, example:
page.wiki
- convert mediawiki to html:
pandoc page.wiki -f mediawiki -t html -o page.html