+ proposed_width = dvi_document->context->dvi_page_w * dvi_document->context->params.conv;
+ proposed_height = dvi_document->context->dvi_page_h * dvi_document->context->params.vconv;
+
+ if (border) {
+ mdvi_pixbuf_device_set_margins (&dvi_document->context->device,
+ MAX (thumb_width - proposed_width, 0) / 2,
+ MAX (thumb_height - proposed_height, 0) / 2);
+ } else {
+ mdvi_pixbuf_device_set_margins (&dvi_document->context->device,
+ MAX (thumb_width - proposed_width - 2, 0) / 2,
+ MAX (thumb_height - proposed_height - 2, 0) / 2);
+ }
+
+
+ mdvi_pixbuf_device_render (dvi_document->context);
+ pixbuf = mdvi_pixbuf_device_get_pixbuf (&dvi_document->context->device);
+
+ g_mutex_unlock (dvi_context_mutex);
+
+ if (border) {
+ border_pixbuf = ev_document_misc_get_thumbnail_frame (thumb_width, thumb_height, NULL);
+ gdk_pixbuf_copy_area (pixbuf, 0, 0,
+ thumb_width - 2, thumb_height - 2,
+ border_pixbuf, 2, 2);
+ g_object_unref (pixbuf);
+ pixbuf = border_pixbuf;
+ }
+
+
+ return pixbuf;