{"library":"md2pdf","title":"md2pdf: Markdown to PDF Converter","description":"md2pdf is a Python library and CLI tool for converting Markdown files to PDF, offering features like custom styling, Jinja templating, and support for various Markdown extensions. It is currently at version 3.1.1 and is actively maintained, receiving regular updates for new features, bug fixes, and security enhancements.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install md2pdf","pip install \"md2pdf[cli]\""],"cli":{"name":"md2pdf","version":""}},"imports":["from md2pdf.core import md2pdf"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"from md2pdf.core import md2pdf\nimport os\n\nmarkdown_content = \"\"\"\n# My Awesome Document\n\nHello, **md2pdf**!\n\nThis is an example of converting Markdown to PDF using the library's API.\n\n- Item 1\n- Item 2\n\n```python\nprint(\"Code blocks are also supported\")\n```\n\"\"\"\n\noutput_filename = \"my_document.pdf\"\n\ntry:\n    md2pdf(\n        md_content=markdown_content,\n        dest=output_filename,\n        css_file=None, # Path to a CSS file for custom styling, or None\n        base_url=None, # Base URL for relative paths in markdown\n        md_extensions=['extra', 'fenced_code', 'tables'] # Common Markdown extensions\n    )\n    print(f\"Successfully created PDF: {output_filename}\")\nexcept Exception as e:\n    print(f\"Error converting markdown to PDF: {e}\")\n    # For WeasyPrint related errors, check system dependencies (see 'Problems')\n","lang":"python","description":"This quickstart demonstrates how to use the `md2pdf` function from the core API to convert a Markdown string directly into a PDF file. You can specify Markdown content, output destination, optional CSS for styling, and desired Markdown extensions.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}