{"id":8610,"library":"rst2pdf","title":"rst2pdf","description":"rst2pdf is a Python library and command-line tool for converting reStructuredText documents to PDF format, leveraging the ReportLab library for PDF generation. It supports various reStructuredText features, including styles, images, and syntax highlighting. The current version is 0.105, and it maintains an active release cadence with frequent minor updates.","status":"active","version":"0.105","language":"en","source_language":"en","source_url":"https://github.com/rst2pdf/rst2pdf","tags":["pdf","rst","restructuredtext","reportlab","document generation","sphinx"],"install":[{"cmd":"pip install rst2pdf","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"rst2pdf","correct":"from rst2pdf.createpdf import rst2pdf"}],"quickstart":{"code":"import os\nfrom rst2pdf.createpdf import rst2pdf\n\nrst_content = '''\nMy PDF Document\n===============\n\nThis is a sample reStructuredText document converted to PDF.\n\n* Item A\n* Item B\n\n.. code-block:: python\n\n   print(\"Hello, rst2pdf!\")\n\n.. note::\n   This is a generated PDF using rst2pdf.\n'''\n\noutput_filename = \"sample_document.pdf\"\n\ntry:\n    # The rst2pdf function can take a string for 'text' and a filename for 'output'\n    rst2pdf(text=rst_content, output=output_filename)\n    print(f\"PDF successfully created: {output_filename}\")\nexcept Exception as e:\n    print(f\"Error creating PDF: {e}\")\n    print(\"Please ensure all core dependencies like docutils and reportlab are correctly installed.\")\n","lang":"python","description":"This quickstart demonstrates how to use the rst2pdf Python API to convert a reStructuredText string into a PDF file. The `rst2pdf` function from `rst2pdf.createpdf` is the primary programmatic interface."},"warnings":[{"fix":"Upgrade your Python environment to 3.10 or newer. Check `requires_python` on PyPI for the exact version range if using an older rst2pdf version.","message":"rst2pdf version 0.100 dropped support for Python versions below 3.6, and current versions (0.105) require Python >=3.10. Older Python versions will result in installation failures or runtime errors.","severity":"breaking","affected_versions":"0.100 and newer"},{"fix":"Consult `ReportLab` and `Docutils` documentation for advanced styling, font embedding, or troubleshooting parsing issues. Ensure system-level dependencies for image processing (e.g., `libjpeg` for Pillow) are met for full functionality.","message":"rst2pdf heavily relies on `ReportLab` and `Docutils` as its core rendering engines. Issues with PDF output (e.g., font rendering, complex layouts, specific styling) or reStructuredText parsing often stem from limitations or quirks within these underlying libraries, not always directly from rst2pdf itself.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Review PDF output after upgrading to ensure typographical changes are as expected. If specific `smartypants` behavior is critical, consider pinning to an older rst2pdf version or pre-processing your reStructuredText.","message":"As of version 0.104, rst2pdf removed its direct dependency on the `smartypants` library and now uses `docutils`'s built-in typography features for converting ASCII quotes to curly quotes and similar transformations. This might result in subtle rendering differences for documents that relied on specific `smartypants` behavior.","severity":"deprecated","affected_versions":"0.104 and newer"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure `reportlab` is installed: `pip install reportlab`. If installed, check your Python environment's path.","cause":"The core dependency `reportlab` is not installed or not accessible in the current Python environment.","error":"ModuleNotFoundError: No module named 'reportlab'"},{"fix":"Ensure `docutils` is installed: `pip install docutils`. This library is essential for parsing reStructuredText.","cause":"The core dependency `docutils` is not installed or not accessible in the current Python environment.","error":"ModuleNotFoundError: No module named 'docutils'"},{"fix":"Convert images to widely supported formats like PNG or JPEG. Ensure Pillow is fully installed with relevant optional backend libraries if attempting less common types. For example, on Linux, `sudo apt-get install libwebp-dev` might be needed for WebP support with Pillow.","cause":"rst2pdf (via Pillow and ReportLab) may not support certain image formats directly, or the necessary underlying image processing libraries (e.g., for WebP) are missing from your system.","error":"rst2pdf.createpdf.Rst2PdfError: Unsupported image type: .webp"},{"fix":"Ensure basic system fonts are installed (e.g., `fonts-freefont-ttf` on Debian/Ubuntu). For custom fonts, provide their paths in your stylesheet or ensure they are accessible in a standard font directory that ReportLab can scan.","cause":"ReportLab (used by rst2pdf) cannot locate system fonts, especially if you're using a minimal environment or custom styles that specify non-existent fonts.","error":"ERROR: Could not find a suitable font. Make sure some fonts are installed."}]}