[reportlab-users] determine the color of a pixel

Tim Roberts timr at probo.com
Thu Oct 26 17:29:01 EDT 2006

pier carteri wrote:

> is it possible to know the color of a particular region of the canvas?
> somethings like
> canvas.getColorAtPosition(pos_x, pos_y)

No.  The canvas does not maintain a bitmap with all of the stuff you've
drawn.  A PDF file isn't actually turned into a bitmap until it gets
into an Acrobat Reader.

> If no, is it possible to know which object (line, text, rectangle ...)
> is present in a particular position on the canvas?
> somethings like
> canvas.getObjectsAtPosition(pos_x, pos_y)

No.  The canvas doesn't remember all of that.  It converts each call
into a Postscript command string, and adds that string to the current
Postscript program.  It's just text characters.

What are you actually trying to do?  You can certain keep a list of
objects yourself.

Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.

More information about the reportlab-users mailing list