How to convert Markdown + CSS -> PDF?

后端 未结 4 1430
南笙
南笙 2020-12-14 18:05

I\'m trying to convert a Markdown file into a PDF. I\'m looking for only two things:

  • A way to easily change the style of the pdf (for example with a CSS file)<
4条回答
  •  情歌与酒
    2020-12-14 18:45

    Pandoc can convert your Markdown to HTML, but the styling/layout is a different topic. If you want to produce a PDF but use CSS for styling, you need something that can interpret CSS. That is either use a browser and print to PDF, pay for Prince or try wkhtmltopdf (see also print-css.rocks). Btw, pandoc can also use wkhtmltopdf now:

    pandoc -t html --css mystyles.css input.md -o output.pdf
    

    But I suspect if you want a beautifully-typeset PDF for free you'll have to learn LaTeX or ConTeXt which is a modern and more self-contained replacement for LaTeX, both can be used with pandoc. See creating a PDF with pandoc.

    You can also give PanWriter a try: a markdown editor I built, where you can inject CSS and export the PDF from the paginated preview.

提交回复
热议问题