[reportlab-users] Drawing an image in the background of a frame

Lele Gaifax lele at metapensiero.it
Thu Sep 26 14:17:49 EDT 2019


Tim Roberts <timr at probo.com> writes:

> Lele Gaifax wrote:
>> I'm asked if it would be possible to obtain something like the following
>> sketch, where I have a frame with a "background" image and, in a specified
>> area (a "subframe"), a superimposed list of flowables (paragraphs of text)
>> with a "white" background:
>
> Are you trying to do an automated magazine layout of some kind? That's an
> extremely difficult thing to automate.  People, as a rule, always do a
> better job of determining the visual appeal of a layout.

Yes, sort of. But I provide just the layout machinery, then there is person
who refines the image and the description, until the result please the eye.

>> The problem is that I should omit the image *iff* the flowables do not fit in
>> the given area, possibly "trying" further combinations of image+flowables
>> until one fits, so I cannot simply draw the image and then do a
>> "subframe.add(flowable)".
>
> There are some conflicting requirements here.  Does the size of the image
> represent a bounding box for the flowables?

No, basically there will be an area that will be filled by the image, and an
overlapping "sub area" where the flowables shall fit, with a reasonable
background to make it readable (say, white). The two boxes are of fixed sizes,
independent from the image and flowables, and always in the same position.

> There are ways to determine the height of a flowable for some fixed width,
> and that may be all you need to know.

Yes, I know about that: I will try to code it so that it first does a "fit
test" on the flowable (mimicking the check done in Frame.add(), pity that it's
not a separate method, disjunct from the actual drawing), and only if that
succeeds will lay down the image, clear the "sub area" filling it with a
background color and eventually draw the flowable there, if anything cleverer
doesn't come up.

Thanks&bye, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele at metapensiero.it  |                 -- Fortunato Depero, 1929.



More information about the reportlab-users mailing list