Posts about rst2pdf (old posts, page 4)

2009-09-19 14:49

Having a little fun with poppler, PyQt and rst2pdf

Inspired by a post by André Roberge I wanted to see if rst2pdf was too slow to be used for real-time previews in a restructured text editor.

It would also be very useful, for example, as a way to test stylesheet changes, making rst2pdf much more useful in general.

And after a couple of hours of gentle hacking, you know... it doesn't suck at all. I implemented the (still very primitive) PDF viewer using a python/poppler/Qt binding I found via google, the UI is PyQt.

Here's the video:

A note: the video was recorded using qt-recordmydesktop and that program is awesome. It was trivial to do.

I expect this will not be good enough when long documents are processed, but the rst2pdf manual (about 25 pages) renders in 5 seconds.

2009-09-16 09:59

Cheatsheets: RST and Python

I never remember how to do footnotes right using ReStructured Text.

If that, or something similar, happens to you, get my rst cheatsheet and print it, it's a two-sided A4 page.

This is an early version, the left-hand columns need lots of love.

Also, you may want to take a look at this one-page python cheatsheet, too.

Both are created using restructured text and rst2pdf, and licensed under Creative Commons.

I would love to see translations to other languages. If you want to help, contact me!

2009-09-15 22:53

Preparing a rst2pdf release for next week

Since this is the first post that appears in Planet Python, a small intro is in order.

Hi, my name is Roberto Alsina, I am a former KDE developer, amateur programmer [1] , python fan.

This post (and many you will see from me) is about rst2pdf, a tool to convert restructured text to PDF. For example, it turns the python library reference into this PDF (not production quality yet).

If you are a rst2pdf 0.11 user, or a sphinx or docutils user who wants to try an alternative way to create PDFs, then I would like your help testing the SVN trunk code.

These are some of the new features since 0.11:

  • PDFBuilder, a Sphinx extension to generate PDFs.
  • Kerning (requires wordaxe from SVN)
  • AAFigure support (diagrams using ASCII Art)
  • PageBreaks can be odd/even/any
  • Support for advanced page counters (manual numbering, roman/arabic/letters)
  • Much better styling, specially for tables.
  • About two dozen bugfixes.

So, please, take a look, you may like it!

[1] That just means I love programming.

2009-09-07 15:04

PyCon Argentina 2009 Day 2

Ha, I thought I was very tired after Day 1... not even close. Not after how tired I was after day 2!

First a short recap:

  • Got there (in time!)

  • Watched Facundo Batista's Entendiendo Unicode

  • Finally presented PyQt + WxPython + PyGtk. And here are my slides.

    A huge thank you to Mariano Reingart, Mariano Guerra, Daniel Moisset and Javier Castrillo who were there in representation of WxPython and PyGtk. It was a very cordial affair and lots of fun for everyone involved, I hope. Here are the Wx and PyGtk slides.

    On the other hand, this kind of thing is dead as future talk subjects, at least to me. There isn't much sizzle in it anymore.

  • Lunch

  • A bit late for Multiprocesamiento en Python by Claudio Freire

  • Then I completely didn't follow Behind the scenes: Python bytecode by Matías Bordese because...

  • I had yet another lightning talk to give!

    It was an old trusty friend of mine, Raymond Hettinger's spreadsheet thingie and I even did slides, there was even time to get a neat xkcd reference in it... and the netbook I was using crapped out in slide #3.

    I could tell the joke (Marcos Dione had a shirt with the exact needed xkcd strip in the back), but I really had a thing going and .. well, it sucked.

    What the heck, I will try again next time.

    And yes, here are the slides I couldn't show

  • Then, last conference, Unladen Swallow by Collin Winter, which was very nice.

  • Then conference closing, gifts for the lucky, some talking, and home to rest.

In other areas:

I finally got my copy of the python tutorial printed with rst2pdf. It's the first time ever a book has been typeset using rst2pdf.

While the printing and binding are (intentionally!) cheap, the typesetting was pretty good. Here are some pictures:

libro1libro2libro3libro4

And finally, I congratulate all the organizers, it was a beautifully handled event!

2009-07-02 11:25

Yay! sphinx-rst2pdf-builder works!

Ok, it kinda works a little.

I got commit rights in the mercurial repo, so now you can get the very very alpha version here.

This triggered several bugs in rst2pdf, so you need SVN rst2pdf for it to work.

What works:

  • Glossary
  • Plain restructured text ... with some caveats (example: footnotes are semi-broken)
  • Index generation (not 100%, but maybe 75%)

I don't know what other pieces of sphinx require specific rst2pdf support, but I will be hitting them as they come.

2009-07-01 17:58

rst2pdf: almost sphinx-ready

Some guys at PyAr are translating the python tutorial to spanish.

That tutorial, like all the new python docs, uses sphinx.

Since sphinx is very popular, I want rst2pdf to work as well as possible as Sphinx's PDF producer. So, two different things itching, I started scratching.

Well, progress has been made. While the sphinx changes currently reside only on my computer, I will publish them soon, and the rst2pdf changes are already committed.

Here's a sample to whet your appetite.

2009-06-22 09:35

AAFigure in rst2pdf

As of today, rst2pdf supports Chris Liechti's awesome aafigure.

What does it mean? It means you can put this in your document:

+-------+       +-------+
|   A   |------>|   B   |
+-------+       +-------+

And get this (and as a PDF drawing, not as an image, so you can copy the text from it):

/static/aafigure.png

So it's an awesome way to add simple diagrams to your restructured text documents that look good in plain text, on the web, and on PDF.

Aafigure can create lots of interesting drawings, check their docs for examples here

It currently requires aafigure from bzr (0.3 won't work).

2009-06-19 19:13

Rst2pdf 0.11 released!

It's my pleasure to announce the release of rst2pdf version 0.11, 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.

This version includes many bugfixes and some new features compared to the previous 0.10.1 version, including but not limited to embedding PDF images, much improved image sizing, nicer list layouts, better styling, page backgrounds, and more than 15 bugs fixed. A full changelog is included at the bottom of this message.

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), page transition effects, multiple, flexible page layouts, cascading styles, and much, much more.

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)

Here are the changes in this version compared to 0.10.1:

  • Degrade more gracefully when one or more wordaxe hyphenators are broken (currently DWC is the broken one)
  • Fixed issue 132: in some cases, with user-defined fontAlias, bold and italic would get confused (getting italic instead of bold in inline markup, for instance).
  • New stylesheet no-compact-lists to make lists... less compact
  • SVG images now handle % as a width unit correctly.
  • Implemented issue 127: support images in PDF format. Right now they are rasterized, so it's not ideal. Perhaps something better will come up later.
  • Fixed issue 129: make it work around a prblem with KeepTogether in RL 2.1 it probably makes the output look worse in some cases when using that. RL 2.1 is not really supported, so added a warning.
  • Fixed issue 130: use os.pathsep instead of ":" since ":" in windows is used in disk names (and we still pay for DOS idiocy, in 2009)
  • Fixed issue 128: headings level 3+ all looked the same
  • Ugly bugfix for Issue 126: crashes when using images in header + TOC
  • New tstyles section in the stylesheet provides more configurable list layouts and more powerful table styling.
  • Better syntax highlighting (supports bold/italic)
  • Workaround for issue 103 so you can use borderPadding as a list (but it will look wrong if you are using wordaxe <= 0.3.2)
  • Added fieldvalue style for field lists
  • Added optionlist tstyle, for option lists
  • Added collection of utility stylesheets and documented it
  • Improved command line parsing and stylesheet loading (guess extension like latest rst2latex does)
  • Fixed Issue 67: completely new list layouting code
  • Fixed Issue 116: crashes caused by huge images
  • Better support for %width in images, n2ow it's % of the container frame's width, not of the text area.
  • Fixed bug in SVG scaling
  • Better handling of missing images
  • Added missing styles abstract, contents, dedication to the default stylesheet
  • Tables style support spaceBefore and spaceAfter
  • New topic-title style for topic titles (obvious ;-)
  • Vertical alignment for inline images (:align: parameter)
  • Issue 118: Support for :scale: in images and handle resizing of inline images
  • Issue 119: Fix placement of headers and footers
  • New background property for page templates (nice for presentations, for example)
  • Default to px for image width specifications instead of pt
  • Support all required measurement units ("em" "ex" "px" "in" "cm" "mm" "pt" "pc" "%" "")
  • New automated scripts to check test cases for "visual differences"
  • Respect images DPI property a bit like rst2latex does.
  • Issue 110: New --inline-footnotes option
  • Tested with reportlab from SVN trunk
  • Support for Dinu Gherman's svglib. If both svglib and uniconvertor are available, svglib is preferred (for SVG, of course). Patch originally by rute.
  • Issue 109: Separate styles for each kind of admonition
  • For Issue 109: missing styles are not a fatal error
  • Issue 117: TOCs with more than 6 levels now supported (raised limit to 9, which is silly deep)

2009-05-29 14:40

rst2pdf progress report

Since the last release, there have been many changes, improvements and fixes in rst2pdf.

At the bottom of this post you will find (maybe incomplete) list, but I wanted to share a couple of relatively large advances.


Presentations

I have wanted to make rst2pdf useful for presentations for quite a while. And now it's getting close.

I am writing a small tutorial about it, but you can see a demo already.

The changes that make this possible are:

  • Fixed bugs regarding page layout
  • Added support for page backgrounds (including SVG!)

This was in large part because of César Rodas, who wanted something simple and text-based to do his ZendCon presentation, so he asked me about it, and I was ashamed to give him a broken tool.

See how that works? I am driven by embarrassment. That's embarrasing.


Major stylesheet improvements

The related changes are way too many (see below), but it also happened for a reason: I wanted to make prettier documents.

So, since most people seems to like Sphinx's style, I wanted to look similar.

Did I achieve it? Yes and no, take a look:

web-sphinx rst2pdf-sphinx

But it's just a draft, I didn't look at fonts, or weight of the headings, or even at what pygments color scheme sphinx is using.

But anyway, even this rough stylesheet made me find a dozen bugs or problems in rst2pdf.

So, the main lesson here is, please tell me what you can and can't do with rst2pdf, because there are whole areas I am not even looking at, day-to-day.


The final thing is... the next release is going to be awesome. But then again, I always say that, don't I?


Changes as of today:

  • Workaround for issue 103 so you can use borderPadding as a list (but it will look wrong if you are using wordaxe <= 0.3.2)
  • Added fieldvalue style for field lists
  • Added optionlist tstyle, for option lists
  • Added collection of utility stylesheets and documented it
  • Improved command line parsing and stylesheet loading (guess extension like latest rst2latex does)
  • Fixed Issue 67: completely new list layouting code
  • Fixed Issue 116: crashes caused by huge images
  • Better support for %width in images, n2ow it's % of the container frame's width, not of the text area.
  • Fixed bug in SVG scaling
  • Better handling of missing images
  • Added missing styles abstract, contents, dedication to the default stylesheet
  • Tables style support spaceBefore and spaceAfter
  • New topic-title style for topic titles (obvious ;-)
  • Vertical alignment for inline images (:align: parameter)
  • Issue 118: Support for :scale: in images and handle resizing of inline images
  • Issue 119: Fix placement of headers and footers
  • New background property for page templates (nice for presentations, for example)
  • Default to px for image width specifications instead of pt
  • Support all required measurement units ("em" "ex" "px" "in" "cm" "mm" "pt" "pc" "%" "")
  • New automated scripts to check test cases for "visual differences"
  • Respect images DPI property a bit like rst2latex does.
  • Issue 110: New --inline-footnotes option
  • Tested with reportlab from SVN trunk
  • Support for Dinu Gherman's svglib. If both svglib and uniconvertor are available, svglib is preferred (for SVG, of course). Patch originally by rute.
  • Issue 109: Separate styles for each kind of admonition
  • For Issue 109: missing styles are not a fatal error
  • Issue 117: TOCs with more than 6 levels now supported (raised limit to 9, which is silly deep)

2009-05-17 13:51

Sorry about rst2pdf 0.10, have some 0.10.1 instead.

So, rst2pdf 0.10 was not ok. The setup.py that worked on 0.9 simply didn't work for the new version.

Good thing is, Christoph actually undestands setuptools, so he could fix it and deliver a neat 0.10.1 for your PDF-generating pleasure.

Post 0.10.1, I have already fixed one bug, Issue 117.

Contents © 2000-2018 Roberto Alsina