[poppler] No more poppler_page_render_to_pixbuf with Ubuntu 12.04

Craig craigbakalian at verizon.net
Fri Apr 27 17:00:07 PDT 2012


Hi,

I used the code below to render a page of a pdf to a scrolled window in
a gtk application of mine.
After downloading Ubuntu 12.04 I get that there is no more support for
poppler_page_render_to_pixbuf().
I do know that we are supposed to use cairo.  But how?  How do I replace
the code below with cairo?

these are global variables

static PopplerDocument *doc;
static PopplerPage *page;
GdkPixbuf *pixbuf;
GtkWidget *image;

void open_pdf_file_on_lily_complete()
{
  	GtkWidget *viewport, *window, *hpane, *entry;
         GtkScrolledWindow *scrolledwindow;
	GError* err = NULL;
	GString *link;
	gchar *uri;
	window = GTK_WIDGET(gtk_builder_get_object (builder, "window"));
	link = make_ly_extension_into_pdf();
	uri = g_filename_to_uri(link->str, NULL, NULL);
	g_string_free(link, TRUE);
	doc = poppler_document_new_from_file(uri, NULL, &err);
	total_pages = 0;
	width = 0.0;
	height = 0.0;
	if(doc!= NULL)
	{
  		scrolledwindow = GTK_SCROLLED_WINDOW(gtk_builder_get_object
(builder, "pdfscrollview"));	  	
  		hpane = GTK_WIDGET(gtk_builder_get_object(builder, "ly_pdf_hpane"));
		total_pages = poppler_document_get_n_pages(doc);
                 if(page_num > total_pages) page_num = 0;
                 page = poppler_document_get_page(doc, page_num);
		poppler_page_get_size(page, &width, &height);		
		pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, width, height);
		poppler_page_render_to_pixbuf(page, 0, 0, width, height, 1, 0,
pixbuf);
		image = gtk_image_new_from_pixbuf(pixbuf);
		viewport = gtk_bin_get_child(GTK_BIN(scrolledwindow));
		if(viewport ) gtk_container_remove(GTK_CONTAINER(scrolledwindow),
viewport);
		gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW
(scrolledwindow), image);
		viewport = gtk_bin_get_child(GTK_BIN(scrolledwindow));
		gtk_widget_add_events(viewport, GDK_POINTER_MOTION_MASK |
GDK_BUTTON_PRESS_MASK);
		g_signal_connect(G_OBJECT(viewport), "motion_notify_event",
G_CALLBACK(motion_notify), image);
		g_signal_connect(G_OBJECT(viewport), "button-press-event",
G_CALLBACK(mouse_down), image);
                 gtk_paned_set_position(GTK_PANED(hpane), 500);
		window = GTK_WIDGET(gtk_builder_get_object (builder, "window"));
                 entry = GTK_WIDGET(gtk_builder_get_object (builder,
"Entry"));
		gchar *my_string = g_strdup_printf("%i", page_num + 1);
		gtk_entry_set_text(GTK_ENTRY(entry), my_string);
		gtk_widget_show_all (window);
	}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/poppler/attachments/20120427/025359b2/attachment.html>


More information about the poppler mailing list