[reportlab-users] How could I do this? inline images with relative widths

Andy Robinson andy at reportlab.com
Thu Jun 17 06:11:07 EDT 2010


On 17 June 2010 11:07, Roberto Alsina <ralsina at netmanagers.com.ar> wrote:

> In rst2pdf I have a MyImage flowable, which is just like Image, but support

> widths like "50%" by calculating the width during wrap(), when they know the

> size of their container.

>

> However, that doesn't work for images in paragraphs (using <img>) because then

> I don't have an image flowable (which I could replace with MyImage), but just

> a tag.

>

> I am thinking about how to hack around this and am drawing a blank here. Any

> ideas?


We have a number of underdocumented classes ending in 'Figure',
including ImageFigure, in reportlab.platypus.figures. These are for
things which might have subtitles like 'Figure 1'... in a book. They
go inline and can shrink or grow to fit, while keeping the right
aspect ratio. You can also set styles for the border and padding and
for a text caption to go underneath your image.

If you want to have an image taking the full width of the frame, these
are the way to go. But if they are in mid-paragraph you will need to
end the previous paragraph, output this, and start a new one.

- Andy


More information about the reportlab-users mailing list