[reportlab-users] Vector Graphics

Andy Robinson reportlab-users@reportlab.com
Mon, 30 Aug 2004 20:50:34 +0100


> To demonstrate how
> far I go, for one project., I actually took the .EPS output from
> Designer, and wrote a Python script to translate the PostScript commands
> to ReportLab calls, all so I could do the fine-grained tweaking
> that I want.
>
> My question is this: what do the rest of you do when you need vector
> graphics in your ReportLab documents?  My luck with EPS import has been
> dreadful.  Does that work for others?  Converting to JPG is almost
> always unsatisfactory.  SVG looks like a good option, but I don't think
> the tools are there yet.  I have half-considered writing a little Python
> tool to create lines and Beziers, which would generate Python/Reportlab
> code on the other end.  Anybody have any tools like that?

When we need to import static graphics in our commercial projects,
we simply distill the EPS file (or whatever they gave us) to a single page
PDF and slurp it in with PageCatcher.  So we get away without doing any
work. I've emailed you directly about this.  (We can't open-source or give
away PageCatcher since it's one of our key edges over competing
technologies, but any experienced ReportLab developers who think it sounds
useful should just mail me and we can discuss terms...)

Apart from that there are several starting points that spring to mind...I'd
welcome any contributions in this area.

1. Dinu Gherman wrote an SVG import library, which works well as far as I
know.  Most vector graphics packages can export SVH these days.  It depends
on the additional Python XML package which was too big a footprint for us to
bundle in.

2. Sketch, the Python vector graphics package, already uses bits of our
framework, but regrettably there is no downloadable Windows version.  It
should be easy to extend with something which outputs code, and it can
inport

3. Adobe Illustrator files used to have a very simple regular subset of
PostScript, but I suspect things have been complicated long ago.

4. OpenOffice.org has a good drawing program and saves things in zipped XML
which may be a good candidate and easy to parse.

Writing a GUI from scratch sounds appealing but if one needs paths,
transforms and bezier curves may not be a small task.

I would also suggest to directly generate PDF operators (which are a lot
like Postscript) instead of canvas operations, and to include the whole
thing with addLiteral.

Best Regards,

Andy Robinson