[poppler] problem with rectangles of links in a pdf

Carlos Garcia Campos carlosgc at gnome.org
Tue Oct 12 01:25:10 PDT 2010


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;

> thank you
> 
> Vincent Torri

Regards, 
-- 
Carlos Garcia Campos
PGP key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x523E6462
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20101012/1f0a5af8/attachment.pgp>


More information about the poppler mailing list