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

Roberto Alsina ralsina at netmanagers.com.ar
Thu Jun 17 06:39:34 EDT 2010


On Thursday 17 June 2010 07:11:07 Andy Robinson wrote:

> 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.


Maybe I am not clear. What I want is something like this:

Bla Bla <img src=whatever.jpg width=50%/> bla bla.

being the same as

Bla Bla <img src=whatever.jpg width=100/> bla bla.

in a frame that's 200pt wide.

As I said, I have it working for images as a separate flowable, it's just with
images inline on paragraph xml markup that I can't figure it out.


More information about the reportlab-users mailing list