[poppler] Don't know how to render a page

Радомир Хаџић radomirhadzic46 at gmail.com
Sun Nov 4 13:06:14 UTC 2018


Hello.

I've decided to write a simple PDF viewer to sharpen my skills. I've
decided to use poppler-glib, along with GTK+. As you probably already know,
GTK+ uses Cairo as its 2D library so I use it as well. Anyway, here's a
small function that should render page, but it doesn't.



































*gboolean render_page(){    GError *error;    double width, height;
cairo_rectangle_int_t rectangle_dimensions;    cairo_region_t
*rectangle;    cairo_t *context;    GdkDrawingContext *drawing_context;
GdkWindow *drawing_area_window;    error = NULL;    drawing_area_window =
gtk_widget_get_window(drawing_area);    document =
poppler_document_new_from_file("file:///home/me/Documents/book.pdf", NULL,
&error);    if (document == NULL)    {        g_print("%s\n",
error->message);        return FALSE;    }    page =
poppler_document_get_page(document, page_current);
poppler_page_get_size(page, &width, &height);    rectangle_dimensions.x =
0;    rectangle_dimensions.y = 0;    rectangle_dimensions.width = (int)
ceil(width);    rectangle_dimensions.height = (int) ceil(height);
rectangle = cairo_region_create_rectangle(&rectangle_dimensions);
drawing_context = gdk_window_begin_draw_frame(drawing_area_window,
rectangle);    context =
gdk_drawing_context_get_cairo_context(drawing_context);
poppler_page_render(page, context);
gdk_window_end_draw_frame(drawing_area_window, drawing_context);
cairo_region_destroy(rectangle);    return TRUE;}*
Assume that all variables used but not declared inside of this function are
global. Also assume that all necessary headers are included. There are no
warnings during compilation nor execution. Everything runs as it should
except that the page is not rendered on the drawing area. Of course, I do
realize that this is not Poppler-exclusive issue but if there is something
wrong with the rendering, then I guess you're the ones who probably know
what it is.

Thank you for reading this and I hope you will be able to help me.
Have a nice day.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/poppler/attachments/20181104/4123ff63/attachment.html>


More information about the poppler mailing list