Wednesday, January 04, 2012

How-to embed HTML in a ReStructuredText PDF document


Download: rst2pdf_html.tar.gz 

I use rst2pdf to create PDF documents from reStructuredtext and on occasion, I have needed to embed HTML in those documents. Unfortunately, this is not possible with rst2pdf as it does not support html embedding. However, with this version of rst2pdf you can embed html as I have done in the example below. The email addresses are rendered as HTML using the “raw:: html” directive. This will only work with this version of rst2pdf and you will need to have xhtml2pdf installed.


ReStructuredtext for the above example:

.. list-table::
   :widths: 50 50 
   :header-rows: 1

   * - **Name**   
     - **e-mail**   
   * - Pedro
     - .. raw:: html
       
         <p><a href="mailto:pedro@address.es">pedro@mailaddress.es</a></p>
   * - Dimitri
     - .. raw:: html
       
         <p><a href="mailto:dimitr@mail.es">dimitr@mailaddress.es</a></p>

Socializer Widget By Blogger Yard
SOCIALIZE IT →
FOLLOW US →
SHARE IT →

1 comments:

  1. Thanks for the great idea and code, I integrated this on rst2pdf 0.90!

    ReplyDelete