static VALUE rg_render(VALUE self, VALUE ps_file_or_cairo) { if (RVAL2CBOOL(rb_obj_is_kind_of(ps_file_or_cairo, cPSFile))) { return page_render_to_ps(self, ps_file_or_cairo); } else { #ifdef RB_POPPLER_CAIRO_AVAILABLE return page_render(self, ps_file_or_cairo); #else rb_raise(rb_eArgError, "cairo is not available"); #endif } }
static void document_render(document_data_t *d) { GtkWidget *w = d->widget; /* render recorded data directly to widget */ cairo_t *c = gdk_cairo_create(gtk_widget_get_window(w)); cairo_set_source_rgb(c, 1.0/256*220, 1.0/256*218, 1.0/256*213); cairo_paint(c); /* render pages with scroll and zoom */ for (guint i = 0; i < d->pages->len; ++i) { page_info_t *p = g_ptr_array_index(d->pages, i); if (document_page_is_visible(d, p)) { /* render page */ cairo_scale(c, d->zoom, d->zoom); cairo_translate(c, p->rectangle->x - d->hadjust->value, p->rectangle->y - d->vadjust->value); page_render(c, p); cairo_identity_matrix(c); /* render search matches */ GList *m = p->search_matches; while (m) { PopplerRectangle *pr = (PopplerRectangle*) m->data; cairo_rectangle_t *pc = page_coordinates_from_pdf_coordinates(pr, p); cairo_rectangle_t *dc = document_coordinates_from_page_coordinates(pc, p); cairo_scale(c, d->zoom, d->zoom); cairo_translate(c, dc->x - d->hadjust->value, dc->y - d->vadjust->value); cairo_rectangle(c, 0, 0, dc->width, dc->height); if (d->current_match == m) cairo_set_source_rgba(c, 0.5, 1, 0, 0.5); else cairo_set_source_rgba(c, 1, 1, 0, 0.5); cairo_fill(c); cairo_identity_matrix(c); g_free(dc); g_free(pc); m = g_list_next(m); } } } cairo_destroy(c); }