Wednesday, May 18, 2011

rst2pdf for presentations: installations and svg usage

Lately I tried out reST after a hint of good man Paolo Corti.

After some startup problems I am now really satified with the results. Amazing over all the possibility to embed svg files instead of images. My diagrams now really rock!

Not being a Python guy I had some problems to install rst2pdf. Well, in linux it is easy like:

sudo apt-get install python-pip python-virtualenv
sudo apt-get install python-matplotlib python-scitools
sudo easy_install rst2pdf
and the dev file if they are not installed already sudo apt-get install python2.7-dev

but in windows I had several problems with error messages. I will have to try again and update here the procedure.

When using svg images, I was getting missleading errors which then got solved by running with the -e inkscape switch.

rst2pdf -s 2011_05_19_Geoinformatics_FCE_CTU.style -e inkscape 2011_05_19_Geoinformatics_FCE_CTU.rst

Yes Martin, the first presentation done with reST is for you :)


-------------------
UPDATE 2011/10/06

The workflow to install rst2pdf on a windows machine was the following:

- install python 2.7.2 (for 32 bits for God's sake!!!)
- follow http://pypi.python.org/pypi/setuptools#windows
- (install mingw???)
- easy_install.exe PIL
- easy_install.exe rst2pdf
- install inkscape


I wasn't able to install matplotlib so that it would work in rst2pdf on windows up to this point.


-------------------
UPADTE 2012/11/12

Just installed rst2pdf again and got this error:

  File "/Library/Frameworks/Python.
framework/Versions/2.7/lib/python2.7/site-packages/rst2pdf-0.92-py2.7.egg/rst2pdf/styles.py", line 527, in __init__
    reportlab.platypus.tables.
CellStyle1.fontname=self['base'].fontName
AttributeError: 'module' object has no attribute 'CellStyle1'

And found the fix ready in the tracker:
 
And indeed it has no such attribute. Changing line 527 to refer to CellStyle.fontname (no numeral 1) fixed the problem.


UPDATE 2011/09/02

Due to a strange docutils-python mismatch, rst2pdf is no longer working for me, because one of the used functions changed signature.

The error I get is:
Traceback (most recent call last):

  File "/usr/local/bin/rst2pdf", line 9, in 

    load_entry_point('rst2pdf==0.16', 'console_scripts', 'rst2pdf')()

  File "/usr/local/lib/python2.7/dist-packages/rst2pdf-0.16-py2.7.egg/rst2pdf/createpdf.py", line 1452, in main

    numbered_links=options.numbered_links,

  File "/usr/local/lib/python2.7/dist-packages/rst2pdf-0.16-py2.7.egg/rst2pdf/createpdf.py", line 169, in __init__

    get_language (self.language)

TypeError: get_language() takes exactly 2 arguments (1 given)


The solutions was given by the author of rst2pdf and consists in opening the file createpdf.py (which in my case is in

/usr/local/lib/python2.7/dist-packages/rst2pdf-0.16-py2.7.egg/rst2pdf/createpdf.py


) and add at line 66 (right below the line

from docutils.transforms import Transform


) the following lines:

import docutils

if docutils.__version__ >= '0.8':

    orig_func = get_language

    def get_language(arg1):

        return orig_func(arg1, None)







4 comments:

aborruso said...

Dear Andrea,
great choice. The most intelligent and beautiful documentations I see online are built with rst (i.e. Sphinx powered documentations).

I must study absolutely it!

aborruso said...
This comment has been removed by a blog administrator.
moovida said...

Dearest Andrea! Try it try it, you will get addicted and the presentations get better and cleaner! :)

yoco said...

Just want to say thank you! This post is really helpful :)