Pypandoc is a Python wrapper for Pandoc, a powerful universal document converter. It simplifies the process of converting files between various formats such as Markdown, HTML, DOCX, PDF, LaTeX, ODT, and EPUB. The library is actively maintained, with the current version being 1.17, and it follows a regular release cadence to incorporate updates and improvements.
pip install pypandocVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to convert a Markdown file to PDF and a Markdown string to HTML using `pypandoc`. For PDF conversion, installing `pypandoc[tinytex]` simplifies LaTeX setup. If `pypandoc_binary` is not used, ensure Pandoc is installed on your system or use `pypandoc.download_pandoc()`.
Upgrade to Python 3 or pin pypandoc version to <1.8.
Replace `pypandoc.convert(source, to, format, ...)` with `pypandoc.convert_file(source_path, to_format, outputfile, ...)` for files or `pypandoc.convert_text(source_string, to_format, format, ...)` for strings.
Install `pandoc` on your system, use `pip install pypandoc_binary`, or utilize `pypandoc.download_pandoc()` to install it through the library. Ensure Pandoc's executable is in your system's PATH.
Review Pandoc's documentation on sandbox mode. If necessary, you can typically disable it via `extra_args` or library configuration, though it's recommended to understand the security implications.
Instead of `extra_args='-V key=value'`, use `extra_args=['-V', 'key=value']`.
Install `pypandoc[tinytex]` for automatic setup, or install a full LaTeX distribution manually and ensure it's in your system's PATH.