After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 437998 - evince cannot print djvu files
evince cannot print djvu files
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: printing
0.8.x
Other All
: Normal normal
: ---
Assigned To: Evince Maintainers
Evince Maintainers
: 470436 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2007-05-12 22:19 UTC by asubedi
Modified: 2007-08-26 14:23 UTC
See Also:
GNOME target: ---
GNOME version: 2.17/2.18


Attachments
patch to add djvu document print support (3.80 KB, patch)
2007-05-14 08:54 UTC, asubedi
committed Details | Review
this patch modifies the DjvuDocument type to add printing support (493 bytes, patch)
2007-05-14 08:56 UTC, asubedi
committed Details | Review

Description asubedi 2007-05-12 22:19:58 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.
Comment 1 Nickolay V. Shmyrev 2007-05-12 22:46:07 UTC
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
Comment 2 asubedi 2007-05-14 08:54:01 UTC
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
Comment 3 asubedi 2007-05-14 08:56:50 UTC
Created attachment 88147 [details] [review]
this patch modifies the DjvuDocument type to add printing support

This patch just adds two fileds to _DjvuDocument.
Comment 4 Carlos Garcia Campos 2007-05-14 10:30:58 UTC
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
Comment 5 Nickolay V. Shmyrev 2007-05-14 16:35:46 UTC
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.

Comment 6 asubedi 2007-05-25 23:51:53 UTC
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?
Comment 7 Carlos Garcia Campos 2007-08-26 14:23:46 UTC
*** Bug 470436 has been marked as a duplicate of this bug. ***