Skip to content

Commit

Permalink
Adds translattion of highlight annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Politz committed Nov 12, 2015
1 parent 8767514 commit 0107f80
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions server/epdfinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1227,6 +1227,25 @@ annotation_get_by_key (document_t *doc, const gchar *key)
}

#ifdef HAVE_POPPLER_ANNOT_MARKUP
void
annotation_translate_quadrilateral (PopplerPage *page, PopplerQuadrilateral *q, gboolean inverse)
{
PopplerRectangle cbox;
gdouble xs, ys;

poppler_page_get_crop_box (page, &cbox);
xs = MIN (cbox.x1, cbox.x2);
ys = MIN (cbox.y1, cbox.y2);

if (inverse)
{
xs = -xs; ys = -ys;
}

q->p1.x -= xs, q->p2.x -= xs; q->p3.x -= xs; q->p4.x -= xs;
q->p1.y -= ys, q->p2.y -= ys; q->p3.y -= ys; q->p4.y -= ys;
}

static cairo_region_t*
annotation_markup_get_text_regions (PopplerPage *page, PopplerAnnotTextMarkup *a)
{
Expand All @@ -1242,6 +1261,7 @@ annotation_markup_get_text_regions (PopplerPage *page, PopplerAnnotTextMarkup *a
PopplerQuadrilateral *q = &g_array_index (quads, PopplerQuadrilateral, i);
cairo_rectangle_int_t r;

annotation_translate_quadrilateral (page, q, FALSE);
q->p1.y = height - q->p1.y;
q->p2.y = height - q->p2.y;
q->p3.y = height - q->p3.y;
Expand Down Expand Up @@ -1296,6 +1316,7 @@ annotation_markup_append_text_region (PopplerPage *page, PopplerRectangle *regio
q.p3.x = r->x1;
q.p3.y = height - r->y2;

annotation_translate_quadrilateral (page, &q, TRUE);
g_array_append_val (garray, q);
}
g_list_free (regions);
Expand Down

0 comments on commit 0107f80

Please sign in to comment.