[reportlab-users] SVG and EPS
robin at reportlab.com
Tue Aug 29 11:33:17 EDT 2006
Rob Schall wrote:
> One more question for anyone who might know how svg or eps would work
> with report magic.
> My boss would like to reduce the size of the pdf. The only real area to
> do this, is to remove the jpg logo from the pdf and replace it with an
> EPS or SVG logo. By replace, I simply mean future pdfs to be created.
> I can't find much on the forums or in the documentation on how/if this
> might be possible. Right now, I have the graphic in eps format, but I
> assume with some work, I could get it into svg format.
> Can reportlab handle this?
> Thanks again!
Well if you have the curves then the logo can be drawn directly by reportlab's
canvas operations. It usually depends on whether you're brave enough to go
playing with the curves lines etc etc. We don't embed eps or svg into pdf, but
both formats are pretty readable. SVG drawings should probably be more parseable
as the operations are well known. With eps there's aleays the chance that the
postscript defines strange operators etc etc.
Typically I end up with something that looks like this
_attrMap = AttrMap(BASE=Drawing,
logoFillColor = AttrMapValue(isColorOrNone),
logoStrokeColor = AttrMapValue(isColorOrNone),
logoStrokeWidth = AttrMapValue(isNumber),
backgroundColor = AttrMapValue(isColorOrNone),
ops = AttrMapValue(isListOfNumbersOrNone),
pts = AttrMapValue(isListOfNumbersOrNone),
sizeScale = AttrMapValue(isNumber),
pts = [ 188.519,219.814,196.405,219.814,203.756,217.962,209.370,216.478,
self._w0 = width
self._h0 = height
self.backgroundColor = None
self.logoStrokeColor = None
self.sizeScale = self.logoStrokeWidth = 1
self.logoFillColor = colors.red
= self.logoStrokeColor or self.logoFillColor),'P')
The MyLogo class can be added as a flowable Drawing or used in some more comples
way to draw onto a canvas.
More information about the reportlab-users