[reportlab-users] Fwd: SVG for canvas.drawInlineImage
Robin Becker
robin at reportlab.com
Thu Jan 13 08:39:35 EST 2022
Hi Arkadi,
I think that inline image probably needs to be a real bitmap image since it requires bitmap data. In the canvas inline
means only appears once and is just an optimization since it saves a few bytes over defining an image as re-usable. The
Image flowable and similar also just handle bitmaps. We don't have a svg-->bitmap routine at present.
If are already using some flowable to render svg for stories then it eventually renders to the canvas using a drawOn
method. It should be possible to get the svg to draw directly to the canvas without using all the platypus machinery.
--
Robin Becker
On 13/01/2022 12:46, Arkadi Colson wrote:
> Hi
>
> Thanks for the answer! I'm using this already for svg images inside Flowables and that is working perfectly but inside
> the canvas method it trows an error:
>
> File "/usr/local/lib/python2.7/dist-packages/reportlab/pdfgen/canvas.py", line 852, in drawInlineImage
> img_obj = PDFImage(image, x,y, width, height)
> File "/usr/local/lib/python2.7/dist-packages/reportlab/pdfgen/pdfimages.py", line 40, in __init__
> self.getImageData()
> File "/usr/local/lib/python2.7/dist-packages/reportlab/pdfgen/pdfimages.py", line 165, in getImageData
> imagedata, imgwidth, imgheight = self.PIL_imagedata()
> File "/usr/local/lib/python2.7/dist-packages/reportlab/pdfgen/pdfimages.py", line 91, in PIL_imagedata
> if image.format=='JPEG':
> AttributeError: Drawing instance has no attribute 'format'
>
> Best regards
> Arkadi Colson
>
> On 13/01/2022 13:38, Dinu Gherman wrote:
>> WAARSCHUWING: Deze mail is afkomstig van buiten Smartbit. Klik niet op links en open geen bijlagen, tenzij je deze
>> mail verwacht en hij afkomstig is van een betrouwbare bron.
>>
>> Maybe https://github.com/deeplook/svglib is an option for you?
>>
>> Cheers,
>> Dinu
>>
>> 13.01.2022 13:16:58 Arkadi Colson <arkadi at smartbit.be>:
>>
>>> Hi
>>>
>>> Is there a way to use an svg-image for canvas.drawInlineImage?
>>>
>>> Thx
>>> Arkadi
>>>
>>> _______________________________________________
>>> reportlab-users mailing list
>>> reportlab-users at lists2.reportlab.com
>>> https://pairlist2.pair.net/mailman/listinfo/reportlab-users
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at lists2.reportlab.com
> https://pairlist2.pair.net/mailman/listinfo/reportlab-users
--
Robin Becker
More information about the reportlab-users
mailing list