1 #include <pdf-document.h>
3 #include <libgnomevfs/gnome-vfs-mime-utils.h>
4 #include <libgnomevfs/gnome-vfs-uri.h>
5 #include <libgnomevfs/gnome-vfs-utils.h>
6 #include <libgnomevfs/gnome-vfs-init.h>
8 #include <ev-document.h>
9 #include <ev-document-thumbnails.h>
14 evince_thumbnail_pngenc_get (const char *uri, const char *thumbnail)
16 EvDocument *document = NULL;
21 mime_type = gnome_vfs_get_mime_type (uri);
22 if (mime_type == NULL)
25 if (!strcmp (mime_type, "application/pdf"))
26 document = g_object_new (PDF_TYPE_DOCUMENT, NULL);
30 if (!ev_document_load (document, uri, &error)) {
31 if (error->domain == EV_DOCUMENT_ERROR &&
32 error->code == EV_DOCUMENT_ERROR_ENCRYPTED) {
33 /* FIXME: Create a thumb for cryp docs */
39 pixbuf = ev_document_thumbnails_get_thumbnail
40 (EV_DOCUMENT_THUMBNAILS (document), 1, 100);
45 pdflogo = gdk_pixbuf_new_from_file (DATADIR"/pdf-icon.png", NULL);
46 if (pdflogo != NULL) {
47 int delta_height, delta_width;
49 delta_width = gdk_pixbuf_get_width (pixbuf) -
50 gdk_pixbuf_get_width (pdflogo);
51 delta_height = gdk_pixbuf_get_height (pixbuf) -
52 gdk_pixbuf_get_height (pdflogo);
54 gdk_pixbuf_composite (pdflogo, pixbuf,
55 delta_width, delta_height,
56 gdk_pixbuf_get_width (pdflogo),
57 gdk_pixbuf_get_height (pdflogo),
58 delta_width, delta_height,
60 GDK_INTERP_NEAREST, 100);
62 gdk_pixbuf_unref (pdflogo);
64 if (gdk_pixbuf_save (pixbuf, thumbnail, "png", NULL, NULL)) {
65 gdk_pixbuf_unref (pixbuf);
66 g_object_unref (document);
69 gdk_pixbuf_unref (pixbuf);
70 g_object_unref (document);
77 main (int argc, char *argv[])
83 g_print ("%s: thumbnailer for Nautilus\n", argv[0]);
84 g_print ("usage: %s <input-filename> <output-filename>\n", argv[0]);
88 res = gnome_vfs_init ();
90 uri = gnome_vfs_make_uri_from_shell_arg (argv[1]);
92 if (evince_thumbnail_pngenc_get (uri, argv[2])) {