Skip to main content

Ralsina.Me — Roberto Alsina's website

Having a little fun with poppler, PyQt and rst2pdf

In­spired by a post by An­dré Roberge I want­ed to see if rst2pdf was too slow to be used for re­al-­time pre­views in a re­struc­tured text ed­i­tor.

It would al­so be very use­ful, for ex­am­ple, as a way to test stylesheet changes, mak­ing rst2pdf much more use­ful in gen­er­al.

And af­ter a cou­ple of hours of gen­tle hack­ing, you know... it does­n't suck at all. I im­ple­ment­ed the (still very prim­i­tive) PDF view­er us­ing a python/pop­pler/Qt bind­ing I found via google, the UI is PyQt.

Here's the video:

A note: the video was record­ed us­ing qt-record­my­desk­top and that pro­gram is awe­some. It was triv­ial to do.

I ex­pect this will not be good enough when long doc­u­ments are pro­cessed, but the rst2pdf man­u­al (about 25 pages) ren­ders in 5 sec­ond­s.

Cory / 2009-09-20 01:52:

This is impressive! I loved how easy it was to switch to 2-column.

How well does rst2pdf handle non-ascii text?

Roberto Alsina / 2009-09-20 11:43:

It's all supposed to be unicode all the way.

There have been some unicode problems with reportlab but I think they al have been worked around.

Paul Hildebrandt / 2009-09-20 16:32:

That was a fun demo. Thanks for posting it.

jjconti / 2009-09-20 20:47:

Excelente demo! pero... que paso con el alineado a la izquierda que no anduvo?

Roberto Alsina / 2009-09-20 21:23:

@jjconti:

Como ese era el unico titulo en el documento, era un "title". El estilo title define esto:

["title" , {
"parent": "heading",
"fontName": "stdBold",
"fontSize": "200%",
"alignment": "TA_CENTER",
"keepWithNext": false,
"spaceAfter": 10
}],

Por lo que si toco "heading", estas cosas no cambian.

btami / 2009-09-21 08:48:

Is it possible to put the code somewhere public?

Roberto Alsina / 2009-09-21 11:29:

Not yet, because I am using a piece of code for which I don't know the license.

As soon as that's cleared, I'll put it somewhere.

nsisodiya / 2011-03-09 04:56:

Please tell the location of code..

Roberto Alsina / 2011-03-09 12:54:

The interesting part about PDF viewing is here: http://code.google.com/p/rs...


Contents © 2000-2024 Roberto Alsina