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 441319 - evince does not print dvi files
evince does not print dvi files
Product: evince
Classification: Core
Component: printing
git master
Other All
: High critical
: ---
Assigned To: Evince Maintainers
Evince Maintainers
Depends on:
Reported: 2007-05-25 23:57 UTC by asubedi
Modified: 2007-06-17 19:20 UTC
See Also:
GNOME target: ---
GNOME version: 2.19/2.20

Patch to add dvi printing support. (4.50 KB, patch)
2007-06-06 12:01 UTC, asubedi
needs-work Details | Review
fixed up the previous patch (4.53 KB, patch)
2007-06-07 10:35 UTC, asubedi
none Details | Review
dvi printing using dvipdfm (4.56 KB, patch)
2007-06-07 16:14 UTC, asubedi
committed Details | Review

Description asubedi 2007-05-25 23:57:31 UTC
Please describe the problem:
I am trying to implement the dvi file exporter. I also implemented the djvu exporter, which was helped by a function contained the libdjvulibre library that converted djvu files to ps. However, I can't seem to find such library for dvi format. So, would the right way to implement this be by converting dvi to ps directly by dvips command?

Steps to reproduce:

Actual results:

Expected results:

Does this happen every time?

Other information:
Comment 1 Nickolay V. Shmyrev 2007-05-26 07:10:20 UTC
You can invoke dvips with g_spawn
Comment 2 asubedi 2007-06-06 12:01:41 UTC
Created attachment 89470 [details] [review]
Patch to add dvi printing support.

Preliminary dvi printing support. Haven't done the setting height and width support as I haven't had time to look at how evince sends height and width to *exporter_begin functions.
Comment 3 Carlos Garcia Campos 2007-06-06 13:15:18 UTC
Comment on attachment 89470 [details] [review]
Patch to add dvi printing support.

Thanks for the patch! Some comments below

>+static void
>+dvi_document_file_exporter_end (EvFileExporter *exporter)
>+	gchar *command_line;
>+	gchar **argv;
>+	GError *err = NULL;
>+	gboolean success;
>+	GPid child_pid = -1;

it seems you are not using child_pid in the function

>+	DviDocument *dvi_document = DVI_DOCUMENT(exporter);
>+	command_line = g_strdup_printf ("%s %s %s -o%s", /* dvips filename.dvi -pp1,2,.. -ops_filename */
>+					"dvips",
>+					dvi_document->context->filename,
>+					dvi_document->opts->str,
>+					dvi_document->ps_filename);
>+	g_shell_parse_argv (command_line, NULL, &argv, &error);

does it compiles? error is not defined, it should be err instead. 

>+	if (err) {
>+                g_warning ("Error %s", err->message);

err should be freed here with g_error_free()

>+                return NULL;

you are returning NULL in a void function. 

>+        }
>+	success = g_spawn_sync (NULL,
>+				argv,
>+				NULL,
>+				NULL,
>+				NULL,
>+				NULL, 
>+				NULL,
>+				NULL,
>+				NULL);

success variable is not used for anything. You should also check the dvips exit status to make sure the command didn't fail. Instead of using g_spawn_sync() with all of those NULL, you can use g_spawn_command_line_sync. I would also check here that the resulting ps file actually exists. 

>+	g_free(command_line);
>+	g_strfreev(argv);
>+static void
>+dvi_document_file_exporter_iface_init (EvFileExporterIface *iface)
>+        iface->format_supported = dvi_document_file_exporter_format_supported;
>+        iface->begin = dvi_document_file_exporter_begin;
>+        iface->do_page = dvi_document_file_exporter_do_page;
>+        iface->end = dvi_document_file_exporter_end;
> #define RGB2ULONG(r,g,b) ((0xFF<<24)|(r<<16)|(g<<8)|(b))
> static gboolean
>@@ -480,4 +577,7 @@
> {
> 	dvi_document->context = NULL;
> 	dvi_document_init_params (dvi_document);
>+	dvi_document->ps_filename = NULL;
>+	dvi_document->opts = g_string_new ("");

it's probably better to create the string on demand, I mean, like you are doing with ps_filename.

> }
Comment 4 asubedi 2007-06-07 10:35:04 UTC
Created attachment 89542 [details] [review]
fixed up the previous patch

Sorry for the crappy patch last time. Should not have sent it when sleepy, although it compiled and worked fine on my laptop.

This patch should be much better. However, I am not checking if ps file actually exists as I could not find glib function to check if a file exists. Also, other backends do not do that check.
Comment 5 asubedi 2007-06-07 16:14:12 UTC
Created attachment 89553 [details] [review]
dvi printing using dvipdfm

This uses dvipdfm as opposed to dvips. The reason is that dvips will print a page only once no matter how many times a page number has been specified in -pp option. For example, dvips -pp2,2,2, will print only one page (pg 2). So dvi backend will not be able to print multiple copies. dvipdfm eliminates this restriction. 

One thing I noticed was that enabling PDF using *_exporter_format_supported will also cause PS option to be visible in printing dialog even though PS exporting is not supported. However, I guess this is for another bug report...
Comment 6 Nickolay V. Shmyrev 2007-06-17 19:20:52 UTC
Patch is applied, thanks a lot.