Created attachment 105944 [details]
We need this method to render (over a surface where the page has already being drawn) an annotation. This method is much faster than poppler_render_page, thus, it allows animation rendering. This bug depends on bug #83642
*** Bug 83644 has been marked as a duplicate of this bug. ***
I find the API a bit confusing, we should document that this expects a surface for the whole page, and only the annotation will be rendered in the coordinates where it would be rendered in the page. It's like the selections API, so it's consistent. I still don't know how this is expected to be used. I'm assuming we want to avoid having to render the whole page, right? If we are moving an annot, for example, we need to render the page at least once without the annot, and then we can paint the annot surface over the page surface during the whole motion until the drop, then we render the whole page again. Is this right? It would help if this was implemented in the demo.
to move an annotation probably we need more API in the glib part to render the page with all annotations but one. and then use this method to render the annot as you described. It is implemented like this for dragging highlight in the wip/highlight branch in git gnome evince.
The most basic usage of the API is to render over a page already rendered without the annotation, but you could render to any portion of the page by setting clip extents and proper transformation on the cairo context (of course this does not work just yet, as it does not work properly in poppler-render_page but that's a bug in the implementations that i plan to fix when i finally review and try to merge tiling support)
I agree we need to document better, and i will modify the demo of adding highlighting in order to use this func.
I was getting ready to send a patch that looked much like this one after inquiring about rendering individual annotations on the mailing list (https://lists.freedesktop.org/archives/poppler/2017-April/012165.html).
I am not sure I am a skilled enough C programmer to add highlight dragging to the glib demo, but I can share my example use case. I am writing a program to extract individual annotations from a PDF so that they can be aggregated and analyzed across documents. For stamps, lines, etc., I need to have a visual representation of the annotation to present to the user. In this code, I render a single annotation and then send along a base64 encoded PNG image representing its isolated visual representation:
The poppler_page_render_annot in that code is the one I wrote, and it differs from the one in this patch in only two trivial ways. First, the argument order is switched around, and second, cairo_clip_extents is used to get the bounding box to display (as suggested in a comment in the page code as well as in _poppler_page_render).
What can I do to help this patch along?
-- GitLab Migration Automatic Message --
This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.
You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/poppler/poppler/issues/228.