Python 3 rst2pdf Library Example For PDF Generation From Raw Text or Files Full Tutorial For Beginners

 

 

Welcome folks today in this blog post we will be generating pdf files from raw text or files in python using rst2pdf library.

 

 

 

pip install rst2pdf

 

 

 

The usual way of creating PDF from reStructuredText is by going through LaTeX. This tool provides an alternative by producing PDF directly using the ReportLab library.

More information is available at the main website.

Features

  • User-defined page layout. Multiple frames per page, multiple layouts per document.
  • Page transitions
  • Cascading stylesheet mechanism, define only what you want changed.
  • Supports TTF and Type1 font embedding.
  • Any number of paragraph styles using the class directive.
  • Any number of character styles using text roles.
  • Custom page sizes and margins.
  • Syntax highlighter for many languages, using Pygments.
  • Supports embedding almost any kind of raster or vector images.
  • Supports hyphenation.
  • Sphinx integration
  • Full user’s manual

 

Usage

To convert a reStructuredText document to a PDF, simply run:

For information on available options, use -h:

To enable basic integration with Sphinx, modify your conf.py file to enable the rst2pdf.pdfbuilder extension and configure the pdf_documents option. For example:

 

Leave a Reply