GNOME Bugzilla – Bug 437998
evince cannot print djvu files
Last modified: 2007-08-26 14:23:46 UTC
Please describe the problem: Evince cannot print djvu files Steps to reproduce: 1. Open a djvu file 2. Try to print it. 3. Actual results: The print menu is disabled. Expected results: The document is sent to the printer. Does this happen every time? Yes Other information: I will work on this if someone acts as a gnome love mentor.
Well, if you need to know something, just ask. Djvulibre can export document in ps file, we just need to implement exporter interface of ev-document like it was done for pdf and ps
Created attachment 88146 [details] [review] patch to add djvu document print support The patch adds the following functions: djvu_document_file_exporter_iface_init djvu_document_file_exporter_format_supported djvu_document_file_exporter_begin djvu_document_file_exporter_do_page djvu_document_file_exporter_end
Created attachment 88147 [details] [review] this patch modifies the DjvuDocument type to add printing support This patch just adds two fileds to _DjvuDocument.
Comment on attachment 88146 [details] [review] patch to add djvu document print support Hi asubedi, thanks a lot for the patch. In general it looks good to me, but I have some minor comments (see below) >+/* EvFileExporterIface */ >+static gboolean >+djvu_document_file_exporter_format_supported (EvFileExporter *exporter, >+ EvFileExporterFormat format) >+{ >+ return (format == EV_FILE_FORMAT_PS); // only exporting to PS is implemented. Do not use C++ comments, use /* */ instead. >+} >+ > static void >+djvu_document_file_exporter_begin (EvFileExporter *exporter, >+ EvFileExporterFormat format, >+ const char *filename, /* for storing the temp ps file */ >+ int first_page, >+ int last_page, >+ double width, >+ double height, >+ gboolean duplex) >+{ >+ DjvuDocument *djvu_document = DJVU_DOCUMENT (exporter); >+ >+ djvu_document->ps_filename = filename; I think it's better to duplicate the string here, filename could be freed between _begin and _end. >+ djvu_document->opts = g_string_new("-page="); You are ignoring width and height arguments, however djvu has an option to specify a zoom factor. With these arguments width and height (desired size) and the original page size you can obtain the zoom factor to use. >+} >+ >+static void >+djvu_document_file_exporter_end (EvFileExporter *exporter) >+{ >+ DjvuDocument *djvu_document = DJVU_DOCUMENT (exporter); >+ >+ FILE *fn = fopen(djvu_document->ps_filename, "w"); >+ g_return_if_fail (fn != NULL); You are leaking the string here when fopen fails. I think it's better to check if fn != NULL and return silently (or with a g_warning) freeing all the resources before. You should also check opts and filename in djvu_document_finalize to free them if they haven't been freed yet
I've committed the changes with slight modifications as Carlos descirbed. Zooming is left as is so we are waiting for another patch. We also need dvi printing support, it should not be really hard.
From looking at how postscript exporting works, I thought that zooming was not handled there. In any case, the djvu library magnifies both width and height by the same proportion. However, in djvu_document_file_exporter_begin, both height and width are specified. How to handle this?
*** Bug 470436 has been marked as a duplicate of this bug. ***