[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freedesktop-poppler
Subject:    [poppler] Don't know how to render a page
From:       Радомир Хаџић <radomirhadzic46 () gmail ! com>
Date:       2018-11-04 13:06:14
Message-ID: CAPV9uWv19HfM_uMm0nbYpt3bYr-SbeBC=Y2L87E+-0HWdO4nUg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


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.

[Attachment #5 (text/html)]

<div dir="ltr"><div dir="ltr"><div>Hello.</div><div><br></div><div>I&#39;ve decided \
to write a simple PDF viewer to sharpen my skills. I&#39;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&#39;s a small function that should \
render page, but it doesn&#39;t.</div><div><b>gboolean render_page()<br>{<br>       \
GError *error;<br>       double width, height;<br>       cairo_rectangle_int_t \
rectangle_dimensions;<br>       cairo_region_t *rectangle;<br>       cairo_t \
*context;<br>       GdkDrawingContext *drawing_context;<br>       GdkWindow \
*drawing_area_window;<br><br>       error = NULL;<br>       drawing_area_window = \
gtk_widget_get_window(drawing_area);<br><br>       document = \
poppler_document_new_from_file(&quot;file:///home/me/Documents/book.pdf&quot;, NULL, \
&amp;error);<br>       if (document == NULL)<br>       {<br>              \
g_print(&quot;%s\n&quot;, error-&gt;message);<br>              return FALSE;<br>      \
}<br>       page = poppler_document_get_page(document, page_current);<br>       \
poppler_page_get_size(page, &amp;width, &amp;height);<br><br>       \
rectangle_dimensions.x = 0;<br>       rectangle_dimensions.y = 0;<br>       \
rectangle_dimensions.width = (int) ceil(width);<br>       rectangle_dimensions.height \
= (int) ceil(height);<br>       rectangle = \
cairo_region_create_rectangle(&amp;rectangle_dimensions);<br><br>       \
drawing_context = gdk_window_begin_draw_frame(drawing_area_window, rectangle);<br>    \
context = gdk_drawing_context_get_cairo_context(drawing_context);<br>       \
poppler_page_render(page, context);<br>       \
gdk_window_end_draw_frame(drawing_area_window, drawing_context);<br><br>       \
cairo_region_destroy(rectangle);<br>       return TRUE;<br>}</b></div><div>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&#39;re the ones who probably know what it \
is.</div><div><br></div><div>Thank you for reading this and I hope you will be able \
to help me.</div><div>Have a nice day.<br></div></div></div>


[Attachment #6 (text/plain)]

_______________________________________________
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic