[poppler] Annot rendering improvements

Fabio D'Urso fabiodurso at hotmail.it
Mon Apr 2 16:36:38 PDT 2012

>> Yes, the raw object has a /Rect of [0 0 100 100].
>> HOWEVER, it doesn't have a prebuilt appearance. As such, Acrobat/Reader
>> (or any other viewer) has to regenerate an appearance in order to render
>> it to the page. Since your line has an L (the actual line coords) of [0 0
>> 200 200], that causes Acrobat/Reader to generate a new bounding box that
>> incorporates the entire line as that is what one would expect.
> [..]
> Sure, we'll do that, thank you very much for the clarification.

I've ran into this problem. From PDF specs:
< A matrix A shall be computed that scales and translates the transformed
appearance box to align with the edges of the annotation’s rectangle (specified
by the Rect entry). A maps the lower-left corner (the corner with the smallest
x and y coordinates) and the upper-right corner (the corner with the greatest x
and y coordinates) of the transformed appearance box to the corresponding
corners of the annotation’s rectangle.>

Suppose I've generated the appearance with the correct 200x200 bbox.
According to the previous excerpt, it should be mapped *on* the annotation
rectangle (and poppler's Gfx::drawAnnot does it right).
But that rectangle is wrong (because it doesn't fully cover the annotation).
The solution is probably to change the annotation rectangle itself, not just
the appearance's one. But I don't feel it's a good thing to change the
annotation rectangle from within the draw method, because the user can't
easily predict if/when the annotation geometry will be changed. *

A better way would be to check if the rect is correct at Annot initialization
and when setRect/setVertices/setQuadrilaterals/setWhatever are called (or
alternatively in invalidateAppearance). This second solution means moving rendering
code out of the draw methods and abstracting it from the draw operation itself.

Since we're so close to release I'd just disable clipping for generated
appearances for now. After all, we never export the generated appearance, therefore
it won't cause incompatibilities with other readers.

Of course, if you have suggestions for a better quick and effective solution,
I'll be happy to implement them.

Thank you for your help,

* = Actually, AnnotLine already changes rect from draw (as workaround for
pdf_commenting_new), but I don't feel comfortable with this approach.

More information about the poppler mailing list