Posts about rst2pdf (old posts, page 5)

2010-03-15 11:14

rst2pdf 0.13 released!

I've just uploaded the 0.13 version of rst2pdf, a tool to convert reStructured text to PDF using Reportlab to http://rst2pdf.googlecode.com

rst2pdf supports the full reSt syntax, works as a sphinx extension, and has many extras like limited support for TeX-less math, SVG images, embedding fragments from PDF documents, True Type font embedding, and much more.

This is a major version, and has lots of improvements over 0.12.3, including but not limited to:

  • New TOC code (supports dots between title and page number)
  • New extension framework
  • New preprocessor extension
  • New vectorpdf extension
  • Support for nested stylesheets
  • New headerSeparator/footerSeparator stylesheet options
  • Foreground image support (useful for watermarks)
  • Support transparency (alpha channel) when specifying colors
  • Inkscape extension for much better SVG support
  • Ability to show total page count in header/footer
  • New RSON format for stylesheets (JSON superset)
  • Fixed Issue 267: Support :align: in figures
  • Fixed Issue 174 regression (Indented lines in line blocks)
  • Fixed Issue 276: Load stylesheets from strings
  • Fixed Issue 275: Extra space before lineblocks
  • Fixed Issue 262: Full support for Reportlab 2.4
  • Fixed Issue 264: Splitting error in some documents
  • Fixed Issue 261: Assert error with wordaxe
  • Fixed Issue 251: added support for rst2pdf extensions when using sphinx
  • Fixed Issue 256: ugly crash when using SVG images without SVG support
  • Fixed Issue 257: support aafigure when using sphinx/pdfbuilder
  • Initial support for graphviz extension in pdfbuilder
  • Fixed Issue 249: Images distorted when specifiying width and height
  • Fixed Issue 252: math directive conflicted with sphinx
  • Fixed Issue 224: Tables can be left/center/right aligned in the page.
  • Fixed Issue 243: Wrong spacing for second paragraphs in bullet lists.
  • Big refactoring of the code.
  • Support for Python 2.4
  • Fully reworked test suite, continuous integration site.
  • Optionally use SWFtools for PDF images
  • Fixed Issue 231 (Smarter TTF autoembed)
  • Fixed Issue 232 (HTML tags in title metadata)
  • Fixed Issue 247 (printing stylesheet)

2009-10-19 11:30

rst2pdf 0.12.2: minor bugfix release

I just uploaded rst2pdf 0.12.2 to http://rst2pdf.googlecode.com Rst2pdf is a tool to generate PDF files directly from restructured text sources via reportlab.

This release fixes a major bug (incompatibility with reportlab 2.1) as well as several minor ones and adds a minor feature (better styling of list items).

For more details, you can see the changelog

2009-10-09 23:12

rst2pdf 0.12 released!

It's my pleasure to announce the release of rst2pdf version 0.12, available at http://code.google.com/p/rst2pdf/downloads/list

Rst2pdf is a tool to generate PDF files directly from restructured text sources via reportlab.

Rst2pdf aims to support the full restructured text feature set, and is very close to that goal, while also including some of the more experimental features, like a source code directive with syntax highlighting and math notation support with LaTeX-like syntax.

It supports embedding arbitrary fonts, both True Type and PS Type 1, both raster and vector images (including SVG and PDF), page transition effects, multiple, flexible page layouts, cascading styles, and much, much more.

This version includes many bugfixes and MANY new features compared to the previous 0.11 version, including but not limited to better styling, integration with sphinx, a very raw, preliminar graphical frontend called bookrest, kerning support (via wordaxe), and a much more powerful table implementation.

In fact, this release has so much new code it needs testers! I would consider it beta quality, and may (probably will) have some rough spots.

You can find more information about rst2pdf in its home page ( http://rst2pdf.googlecode.com), and ask anything you want in the rst2pdf-discuss mailing list (http://groups.google.com/group/rst2pdf-discuss)

A list of improvements and changes in this version is just too long, but is available at the changelog

I hope you enjoy this program!


In other news, Google just found me two nice things related to rst2pdf:

  1. A tutorial to use sphinx and rst2pdf for japanese texts: http://d.hatena.ne.jp/MiCHiLU/20091009/1255065687
  2. It looks like a rst2pdf 0.11 binary for windows is shipped by pythonxy here: http://code.google.com/p/pythonxy/downloads/detail?name=rst2pdf-0.11_py26.exe I will link to that!

I love when people do things like these :-)

2009-10-02 22:58

Bookrest: the stylesheet editor in action

As usual, a video showing it:

The current status is that the infrastructure required for the stylesheet editor is in place:

  • I figured out how to turn the StyleSheet object back into a JSON stylesheet.
  • The changes are done and merged back into the same file.
  • There is UI for 3 of the 6 required pieces. The missing ones are text styles, embedded fonts, and config options (like, break subsections to odd pages)
  • The UI for the whole app is pretty rough, I am in full make-it-functional mode right now. It will be rethought later on.

2009-09-28 11:24

Bookrest: it was meant to be a stylesheet editor.

In my original post about it I was referring to Bookrest as a stylesheet editor for rst2pdf, because that's what I wanted, a way to test style changes and see what they did.

Of course, one thing lead to another and it's starting to look more like a word processor than anything else, but ... well, how about a stylesheet editor?

Sure, you can use the "Style" tab, and edit at will, but that's not exactly fun for everyone.

So, let's work on one. Here's the video of the current status:

Of course, this is about 1/20th of the stylesheet editor, but at least the dialog is there, and most of the remaining work is wiring dialogs, which is quick using designer.

2009-09-25 14:35

It shall be called Bookrest, and it has an outline view.

Yes, the program known so far as "my rst2pdf editor/previewer application" is now called Bookrest.

What's a bookrest? It's a thing you put a book on.

Why Bookrest? I hope someday people will have books open in bookrest. Plus, it ends with "rest", which is the preferred abbreviation for reStructured Text.

And what's the outline view? It's a clickable tree with the outline of the document, of course.

As usual, let's go to the video:

The background rendering was done using python's awesome multiprocessing module.

2009-09-23 18:43

rst2pdf previewer: a new feature

I am in the middle of that honeymoon you get starting a new app. Every new feature seems tobe just 50 lines of code away, there is no legacy code (in fact, you are creating that legacy code), and you learn new tricks all the time.

So, I did a new feature today.

A day or two ago, my editor started showing a yellow bar highlighting the current line.

But then I though... wouldn't it be more useful to have a similar bar following you in the PDF?

That way, when you are on a given line, you can immediately see where you are in the output. Neat, right?

Here is a video showing it:

Sadly it's not perfect, and probably never will be because of docutils limitations, but it's pretty nice!

2009-09-22 13:33

More fun with rst2pdf, poppler and PyQt

First: I really, really need a name for this thing. I am tired of saying "my rst2pdf previewer/editor app".

Now, here's a video of how it looks nowadays after all the yak shaving (sorry about my english, I write lots of it, but never speak it):

As you can see, the basic app is fairly complete, even if it lacks all the amenities that would make someone use it (like, search? save? ;-).

It has one big problem, though: I can't publish it yet.

Why? Because I need to use poppler from PyQt, and the code I found to do it has no license (see the code).

I am trying to contact the author (Rajeev J Sebastian), so there should be news soon!

As soon as that's cleared, the PDF widget is a whole post by itself, because it's pretty neat, if I may say so myself.

UPDATE: the binding is now under MIT license, thanks to Rajeev Sebastian!

2009-09-22 04:01

Yak Shavings for September 22, 2009

yak shaving
(idiomatic) Any apparently useless activity which, by allowing you to overcome intermediate difficulties, allows you to solve a larger problem.

This yak is starting to look better.

For my second pile of yak shavings: turning QPlainTextEdit into a decent editing widget for programmers.

As work advanced in my rst2pdf editor (BTW: need a name!), it became obvious that the piece of the UI the user will use most is just a couple of plain text editors.

Qt comes with a widget for that, of course, called QPlainTextEdit. However, it's a very, very bad widget for programmers.

Here's the least I wanted:

  1. Syntax highlighting for two languages: restructured text and javascript. This yak is already shaved.
  2. Line numbers
  3. Current line highlight
  4. Error highlight when it makes sense (like, in the stylesheet)

One way to achieve this would be to dump QPlainTextEdit and use QSciScintilla which is the basis for the code editor in eric and (another version) in scite.

However, I experienced a bad bug in QSciScintilla, where I can't type accented characters! Without that, (decent) spanish is impossible, and the bug seems to be at least two years old, so... no go.

So, did I get those features? I say yes!

Here is the video (yes, I am getting addicted to making these, since qt-recordmydesktop makes them so easy ;-):

The basis for this is the Code Editor example that comes with Qt itself, plus a bit of my own handywork.

First, I ported Code Editor from C++ to Python, which was very simple and took a few minutes. That takes care of points 2 and 3.

Then, the syntax highlight was plugged in, which was point 1.

Then, how about realtime javascript validation? Easy using simplejson! Just make sure to run this whenever you want validation (I do it on every keystroke).

Replace self.ui.style.toPlainText with whatever your widget is called, of course:

def validateStyle(self):
    style=unicode(self.ui.style.toPlainText())
    #no point in validating an empty string
    if not style.strip():
        return
    pos=None
    try:
        json.loads(style)
    except ValueError, e:
        s=str(e)
        print s
        if s == 'No JSON object could be decoded':
            pos=0
        elif s.startswith('Expecting '):
            pos=int(s.split(' ')[-1][:-1])
        else:
            print 'UNKNOWN ERROR'

    # This makes a red bar appear in the line
    # containing position pos
    self.ui.style.highlightError(pos)

highlightError(pos) simply stores pos in the Code Editor, which will draw a red bar in that line, the same way it highlights the current line.

And that's it. Here is the code for codeeditor.py

Contents © 2000-2019 Roberto Alsina