You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SvgImage(Flowable) or SvgReader class that provides convenience functions to scale or wrap the image to a specified space using reportlab.platypus?
#69
Open
skidzo opened this issue
Jan 23, 2017
· 2 comments
Not sure if this is what you want, but I think that the reportlab.lib.utils.ImageReader class now accepts drawings as inputs so any svglib drawing can be used as an image. In any case drawings were already flowables so can be added to a story.
Well that's partly because I don't really know what I want, I just looked at Image Reader "Wraps up either PIL or Java to get data from bitmaps" class in my open source version=3.3.0, and there is no such fancy drawing acceptance as you described. I don't have any Problem to add a drawing to the "story", I was just thinking that it would be fancy to have a possibility to have my own SvgImage class that accepts a file or file like object as Input and where I can implement what it's drawOn method would do.
Without having to (re)write a lot of code, this seems to be impossible, using reportlab and svglib...
for now I have found that this function is needed to (re)scale a drawing returned from svg2rlg
def scaleDrawing(drawing,factor,showBoundary=False):
"""
scale a reportlab.graphics.shapes.Drawing() object,
leaving its aspect ratio unchanged
"""
sx=sy=factor
drawing.width,drawing.height = drawing.minWidth()*sx, drawing.height*sy
drawing.scale(sx,sy)
if showBoundary:
drawing._showBoundary = True
return drawing
skidzo
changed the title
SvgImage(Flowable) or SvgReader class that provides a convenience functions to scale or wrap the image to a specified space using reportlab.platypus?
SvgImage(Flowable) or SvgReader class that provides convenience functions to scale or wrap the image to a specified space using reportlab.platypus?
Feb 20, 2017
Something like this would be nice for a future release:
Maybe it is sufficient to just provide a SvgReader() class, that gives the freedom to implement this in a flexible way...
The wrap() can be overloaded, whereas the wrapOn() method should not be touched.
I found an example somewhere that explains what it could look like, only that this shows how to embed a PDF file:
The text was updated successfully, but these errors were encountered: