2008-09-16 20:58

uRSSus in a magazine DVD?

Of course I could be misunderstanding this, but it seems they included uRSSus 0.2.10 in a DVD for some reason :-)

The link and I will not make a "in soviet russia" joke.

2008-09-11 18:24

Using vector images in reportlab, improved

I just committed into trunk of rst2pdf a nicely working SVGImage flowable for reportlabs.

The code is self-contained in two files:

You can use them in your app if you want (I'd like to know, though). One of them is GPL/LGPL (it's basically copied from uniconvertor) the other is MIT-Licensed.

The output is astonishing: svg.pdf is only 32KB and completely resolution-independent. Graphics in your PDF That look good printed and on screen! And are not huge! Yay!

This will be the flagship new feature in tomorrow's rst2pdf 0.8.

2008-09-10 23:32

Using vector images in reportlab

One of the big limitations of reportlab is that it has no support for vector-based images. You can't insert SVG, EPS or any other vector-based format in your documents.

Until now.

By hijacking another app called uniconvertor, I have managed to insert as vectors SVG images in a reportlab document.

Here's the hackish code:

import sys,os
from app.io import load
from app.plugins import plugins
import app
from reportlab.platypus import *
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.lib.units import inch

app.init_lib()
plugins.load_plugin_configuration()


class SVGImage(Flowable):
  def __init__(self,imgname):
    self.doc = load.load_drawing(imgname)
    for k in dir(self.doc):
      print k
    self.saver = plugins.find_export_plugin(plugins.guess_export_plugin(".pdf"))
    Flowable.__init__(self)

  def wrap(self,aW,aH):
    br=self.doc.BoundingRect()
    return br[2],br[3]

  def drawOn(self,canv,x,y,_sW=0):
    canv.translate(x,y)
    self.saver (self.doc,".ignoreme.pdf",options={'pdfgen_canvas':canv})
    os.unlink(".ignoreme.pdf")

styles = getSampleStyleSheet()
def go():
    doc = SimpleDocTemplate("phello.pdf")
    Story = [Spacer(1,2*inch)]
    style = styles["Normal"]
    p = SVGImage('warning.svg')
    Story.append(p)
    doc.build(Story)

go()

It has several problems (see where the second paragraph ended), but it does work.

To run it, you need a warning.svg file (edit as needed) and you run it this way (replacing the path as proper for your setup):

PYTHONPATH=/usr/lib/python2.5/site-packages/uniconvertor/ python use_uniconv.py

In fact, this is not limited to SVG files. You should be able to use the following formats:

  • CorelDRAW ver.7-X3,X4 (CDR/CDT/CCX/CDRX/CMX)
  • Adobe Illustrator up to 9 ver. (AI postscript based)
  • Postscript (PS)
  • Encapsulated Postscript (EPS)
  • Computer Graphics Metafile (CGM)
  • Windows Metafile (WMF)
  • XFIG
  • Scalable Vector Graphics (SVG)
  • Skencil/Sketch/sK1 (SK and SK1)
  • Acorn Draw (AFF)

2008-09-09 16:34

Old fashioned mail: Cone

I had one too many problems with kmail from KDE4 in my eee with Kubuntu, and sylpheed-claws is just unusable in a small screen (the huge widgets! the non-hidable things all over the interface!) I decided to get old fashioned and try a console mail reader.

I was a pine user for many years, and a mutt user for a while, and I was deeply disappointed that the last three years have been bad for these programs.

Just because you run in a terminal, there's no reason to be hard to configure! After spending 20 minutes trying to get a decent IMAP account setup (just two IMAP accounts) in alpine and another 10 wondering if mutt really had no place in the UI for account configuration (and whether the Debian/KUbuntu default "commented" config file is the product of hard drugs), I tried Cone.

It was bliss. It was all I remembered from pine years ago (on local accounts) only over IMAP.

Easy to configure, easy to use, quick, capable. I was in love all over again.

While I will keep using KMail on my main notebook under Arch Linux where I had no reliability problems whatsoever, I have Cone configured in my server's shell account and in the eee.

2008-09-07 21:13

This week's release plan: Uqbar

On my ongoing something-released-every-friday rampage, this friday I will release a working version of Uqbar, a Gutenberg project e-texts interface.

It may use use pandoc and rst2pdf and makeztxt and other things to make e-books that are pretty to read, and work on my Sony Clie. We'll see.

This project has been "sleeping" since 2005, I think I can now, with my new focus in limited, quick development, get a reasonable version ready in two weeks.

I may slip a little rst2pdf update, too.

After that, back to Urssus.

2008-09-04 11:08

rst2pdf: What will be new tomorrow

Keeping with my new time-based release schedule, tomorrow is again rst2pdf release day! What will be new in 0.7? Several things!

  • Fixed several serious bugs, specially with the handling of literal blocks (preformatteds and code blocks).
  • Implemented a rather neat sidebar/floating block mechanism. It only lets you go float-left or float-right but it looks better than what you get in HTML, at least:
sidebar-beige

You can even use it to float almost arbitrary objects, so you can have floating images or floating figures.

  • Fixed the look of hyperlinks. Reportlab had a bug about making some hyperlinks underlined, and those with a black thick underline. Not when you use rst2pdf! Monkey-patched the heck out of that.
  • Table styling. Let me show you:
rst2pdf-tablestyles

The first row is a header row. It automatically takes the table-heading style.

The following rows are regular, and they take the table style, which has support for zebra tables with alternating colors (white and gray here).

The lone red cell at the right is special. Its content is this:

.. class:: red

red

If you don't know ReST, that means "red" is a paragraph with class red, so it will be styled whatever way that means (here: red background).

Usually that would mean you have a white (or gray) cell with a red paragraph in it. That looks incredibly ugly.

So, rst2pdf tries to be clever: If there is a single element in a cell, it will try to guess the cell background from it.

And as you saw above, it works :-)

2008-09-02 23:49

rst2pdf: progress in smartframe branch

Yes, it is getting better. Now there are left-floating or right-floating elements, and you can float pretty much anything (except literal blocks, that's a problem) by using the class directive. Here's how it looks:

sidebar-beige

Contents © 2000-2019 Roberto Alsina