[reportlab-users] From intra-paragraph images to drawings?

Robin Becker robin at reportlab.com
Wed May 8 12:46:34 EDT 2013


On 08/05/2013 17:05, Andy Robinson wrote:

> I am going a bit off topic, but in the (infinitely regressing)

> ReportLab 3.0, we probably want two ways to produce a paragraph: (1)

> a string with markup, and (2) a list of Fragment objects, which is

> pretty much what we parse (1) into anyway. In the latter

> representation you could have inline graphical elements initialised

> how you want in your python code. They need to be able to report

> their size.

>

> Robin, maybe you could see if it's possible for a user to construct a

> paragraph from fragments, and post an example if it is?

>

.........
all of my recent experiments have been about getting rid of fragments :( they
were introduced when I/we first started using markup because I/we didn't know
any better and they were fairly fast. In practice it would be better to just
mark the transitions from one style to another with action objects. That way we
could eliminate all the fragment style comparisons and a lot of code where we
check to see if the incoming frag changes font, font size, or some other attribute.

In the box glue model we would then have boxes with text or other content, glue
and actions. There are various well known schemes for joining these all together.

You are supposed to be able to make a paragraph out of frags and the parser is
not called when they are given. Currently there are only text fragments and
cbDefns (callbacks originally). The cbDefns have a kind which can be img to get
image handling or anchor for an anchor (as in the original a tag). All other
cbDefns are assumed to be proper callbacks with a function name etc etc. Only
the 'img' kind has a size and gets special treatment. Presumably we could add
another kind which has size that could as Andy suggests be created directly with
special behaviours. Personally I don't find the idea of generating paragraphs
directly from fragments all that attractive. Having just slogged through the
code to split fragment words that are over long I'm not sure fragments are an
easy way to do things.
--
Robin Becker


More information about the reportlab-users mailing list