[poppler] problem with rectangles of links in a pdf

Vincent Torri vtorri at univ-evry.fr
Tue Oct 12 02:01:12 PDT 2010



On Tue, 12 Oct 2010, Carlos Garcia Campos wrote:

> Excerpts from Vincent Torri's message of lun oct 11 09:13:11 +0200 2010:
>>
>> Hey,
>>
>> I am trying to display the rectangles of the links of a pdf. Here is what
>> i do (basically, it's what the glib frontend does):
>>
>> /* I loop over the links */
>> link = links.getLink(i);
>> link->getRect (&x1, &y1, &x2, &y2);
>> x1 -= ebp->page.page->getCropBox()->x1;
>> x2 -= ebp->page.page->getCropBox()->x1;
>> y1 -= ebp->page.page->getCropBox()->y1;
>> y2 -= ebp->page.page->getCropBox()->y1;
>>
>> link_item->rect.x = round(x1);
>> link_item->rect.y = round(y1);
>> link_item->rect.w = round(x2 - x1);
>> link_item->rect.h = round(y2 - y1);
>>
>> I display these rectangles on the pdf. I have attached the result
>> (rectangles are blue) and the pdf.
>>
>> Does someone see if what I did is wrong ?
>
> You need to invert the y axis, in the PDF coordinate system the origin
> (0, 0) is at the lower-left corner, while in X is at the upper-left
> corner. So, you need something like:
>
> screen_rectangle.y = height - pdf_link_rectangle.y1;

It's better but no perfect yet (see attachment). The vertical alignement 
is still not good, and some rectangles are overlapping (because i'm 
rounding values ?)

Note that the glib frontend has certainly the same bug:

 	default:
 	  mapping->area.x1 = rect.x1;
 	  mapping->area.y1 = rect.y1;
 	  mapping->area.x2 = rect.x2;
 	  mapping->area.y2 = rect.y2;

in poppler-page.cc (poppler 0.15)

Vincent Torri
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pdf_links2.png
Type: image/png
Size: 75975 bytes
Desc: 
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20101012/cdc4f105/attachment-0001.png>


More information about the poppler mailing list