[reportlab-users] embedding vector graphics in reportlab pdf

Jason Craig jason at iwocreative.com
Mon Dec 3 17:09:38 EST 2007


Michael Hearne wrote:

> I'm trying to recreate a PDF report currently being generated with a

> Perl postscript library. The output looks very crisp, as all of the

> components are generated either with postscript commands or with

> encapsulated postscript images.

>

> So far as I can tell, Reportlab cannot import encapsulated Postscript

> (as PIL cannot), and I'm having trouble making my PNG images in the

> PDF look as crisp as their .eps counterparts.

>

> I found some references to something called svglib, but nothing since

> 2004.

>

> What is the best strategy for importing images into ReportLab so that

> they look as crisp as possible? I have EPS versions of various logos,

> so I could presumably save these as any size PNG files.

>

> Thanks,

>

> Mike

>

As far as I could tell when I had this problem, you have three options:
1) Purchase the commercial ReportLab tools, which apparently have
methods to deal with this
2) Make some PNG/GIF/other bitmapped image realizing that it will be
resized in the final PDF. I have noted that when PDFs are rendered,
such non-vector graphics often appear strangely, but when printed those
graphics come out fine, presuming that the DPI is good. If print and
not screen is your target medium, perhaps this is the best option.
3) Use svglib. I was also put off by this notion originally, but found
that using it is quite easy. Once you have your EPS file(s) converted
to SVG (Ghostscript is one open source tool that can do this,
Illustrator can save to SVG, and Inkscape (also open source) can convert
.ai's), it's one simple function call (svg2rlg) to convert to a nice
ReportLab flowable.

--Jason


More information about the reportlab-users mailing list