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 724044 - Can not print PostScript files as PDF
Can not print PostScript files as PDF
Status: RESOLVED FIXED
Product: evince
Classification: Core
Component: printing
3.10.x
Other All
: Normal normal
: ---
Assigned To: Evince Maintainers
Evince Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-02-10 15:45 UTC by Debarshi Ray
Modified: 2014-03-27 14:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screenshot (200.79 KB, image/png)
2014-02-10 15:45 UTC, Debarshi Ray
  Details
ps: Don't advertize CAN_GENERATE_PDF (884 bytes, patch)
2014-02-10 15:49 UTC, Debarshi Ray
reviewed Details | Review
Allow printing to all formats supported by backend (4.38 KB, patch)
2014-03-03 16:40 UTC, Marek Kašík
needs-work Details | Review
Allow printing to all formats supported by backend (4.30 KB, patch)
2014-03-21 13:16 UTC, Marek Kašík
committed Details | Review
The warning change (1.13 KB, patch)
2014-03-21 13:17 UTC, Marek Kašík
committed Details | Review

Description Debarshi Ray 2014-02-10 15:45:04 UTC
Created attachment 268687 [details]
Screenshot

It appears that we can not print PostScript files as PDF (see attached screenshot). So, maybe we should not offer the PDF option in the dialog.
Comment 1 Debarshi Ray 2014-02-10 15:49:45 UTC
Created attachment 268688 [details] [review]
ps: Don't advertize CAN_GENERATE_PDF
Comment 2 Carlos Garcia Campos 2014-02-10 17:53:45 UTC
Review of attachment 268688 [details] [review]:

::: backend/ps/ev-spectre.c
@@ +411,3 @@
 		EV_FILE_EXPORTER_CAN_COLLATE |
 		EV_FILE_EXPORTER_CAN_REVERSE |
+		EV_FILE_EXPORTER_CAN_GENERATE_PS;

This is not correct. These are the capabilities of the backend, and the PS backend can generate PDF files. Another thing is what the actual printer supports. I wonder why you got that error when printing a PS file as PDF. It's definitely another bug somewhere else.
Comment 3 Marek Kašík 2014-03-03 16:40:52 UTC
Created attachment 270819 [details] [review]
Allow printing to all formats supported by backend

Hi,

I've looked at the problem and it seems to me that the "if (!gtk_printer_accepts_ps (export->printer))" in the ev-print-operation.c is not correct any more. We should check whether requested file format is supported by the current backend.
The attached patch implements this (I'm not sure about the warning message so propose something else if needed).

Regards

Marek
Comment 4 Carlos Garcia Campos 2014-03-17 11:27:47 UTC
Review of attachment 270819 [details] [review]:

Looks good to me in general, but I have some comments. Thanks

::: libview/ev-print-operation.c
@@ +1178,3 @@
+		else
+			format = EV_FILE_FORMAT_PS;
+	}

I would move this to a helper function, ev_file_exporter_get_format_from_print_settings() or something like that.

@@ +1187,3 @@
+	       gtk_printer_accepts_pdf (export->printer) &&
+	       ev_file_exporter_get_capabilities (EV_FILE_EXPORTER (op->document)) &
+	                                          EV_FILE_EXPORTER_CAN_GENERATE_PDF))) {

This expression is too complex. I don't think we need to check the backend capabilities here, because the options shown in the dialog are based on that already, so if we get PDF here is because either it was selected by the user in the dialog or fell back in previous expression that already checks backend capabilities.

So, here we should only make sure that the actual printer supports the format selected.

@@ +1193,3 @@
                                      GTK_PRINT_ERROR,
                                      GTK_PRINT_ERROR_GENERAL,
+                                     _("Requested format is not supported by this printer or backend."));

We can't change strings now. We could move this change to a different patch. I don't think we should expose the backend error, because it shouldn't happen, if the backend doesn't support the format, it won't be exposed in the dialog.
Comment 5 Marek Kašík 2014-03-21 13:16:47 UTC
Created attachment 272561 [details] [review]
Allow printing to all formats supported by backend

Thank you for the review.

(In reply to comment #4)
> Review of attachment 270819 [details] [review]:
> 
> Looks good to me in general, but I have some comments. Thanks
> 
> ::: libview/ev-print-operation.c
> @@ +1178,3 @@
> +        else
> +            format = EV_FILE_FORMAT_PS;
> +    }
> 
> I would move this to a helper function,
> ev_file_exporter_get_format_from_print_settings() or something like that.

I've moved it to static _get_output_format() function. Moving it to ev-file-exporter.h would mean to add GTKUNIXPRINT_CFLAGS and GTKUNIXPRINT_LIBS to all parts which include the header file. But if you want to move it there I will do the move.


> @@ +1187,3 @@
> +           gtk_printer_accepts_pdf (export->printer) &&
> +           ev_file_exporter_get_capabilities (EV_FILE_EXPORTER (op->document))
> &
> +                                             
> EV_FILE_EXPORTER_CAN_GENERATE_PDF))) {
> 
> This expression is too complex. I don't think we need to check the backend
> capabilities here, because the options shown in the dialog are based on that
> already, so if we get PDF here is because either it was selected by the user in
> the dialog or fell back in previous expression that already checks backend
> capabilities.
> 
> So, here we should only make sure that the actual printer supports the format
> selected.

Done.


> @@ +1193,3 @@
>                                       GTK_PRINT_ERROR,
>                                       GTK_PRINT_ERROR_GENERAL,
> +                                     _("Requested format is not supported by
> this printer or backend."));
> 
> We can't change strings now. We could move this change to a different patch. I
> don't think we should expose the backend error, because it shouldn't happen, if
> the backend doesn't support the format, it won't be exposed in the dialog.

I've split the patch to 2 patches and removed the note about the backend.
Comment 6 Marek Kašík 2014-03-21 13:17:04 UTC
Created attachment 272562 [details] [review]
The warning change
Comment 7 Carlos Garcia Campos 2014-03-22 08:59:25 UTC
(In reply to comment #5)
> Created an attachment (id=272561) [details] [review]
> Allow printing to all formats supported by backend
> 
> Thank you for the review.
> 
> (In reply to comment #4)
> > Review of attachment 270819 [details] [review] [details]:
> > 
> > Looks good to me in general, but I have some comments. Thanks
> > 
> > ::: libview/ev-print-operation.c
> > @@ +1178,3 @@
> > +        else
> > +            format = EV_FILE_FORMAT_PS;
> > +    }
> > 
> > I would move this to a helper function,
> > ev_file_exporter_get_format_from_print_settings() or something like that.
> 
> I've moved it to static _get_output_format() function. Moving it to
> ev-file-exporter.h would mean to add GTKUNIXPRINT_CFLAGS and GTKUNIXPRINT_LIBS
> to all parts which include the header file. But if you want to move it there I
> will do the move.

Sure, I meant to use a static function.

> 
> > @@ +1187,3 @@
> > +           gtk_printer_accepts_pdf (export->printer) &&
> > +           ev_file_exporter_get_capabilities (EV_FILE_EXPORTER (op->document))
> > &
> > +                                             
> > EV_FILE_EXPORTER_CAN_GENERATE_PDF))) {
> > 
> > This expression is too complex. I don't think we need to check the backend
> > capabilities here, because the options shown in the dialog are based on that
> > already, so if we get PDF here is because either it was selected by the user in
> > the dialog or fell back in previous expression that already checks backend
> > capabilities.
> > 
> > So, here we should only make sure that the actual printer supports the format
> > selected.
> 
> Done.
> 
> 
> > @@ +1193,3 @@
> >                                       GTK_PRINT_ERROR,
> >                                       GTK_PRINT_ERROR_GENERAL,
> > +                                     _("Requested format is not supported by
> > this printer or backend."));
> > 
> > We can't change strings now. We could move this change to a different patch. I
> > don't think we should expose the backend error, because it shouldn't happen, if
> > the backend doesn't support the format, it won't be exposed in the dialog.
> 
> I've split the patch to 2 patches and removed the note about the backend.

Thanks!
Comment 8 Carlos Garcia Campos 2014-03-22 09:04:39 UTC
Review of attachment 272561 [details] [review]:

Thanks, please see my review commits and push after freeze.

::: libview/ev-print-operation.c
@@ +1143,3 @@
 
+static EvFileExporterFormat
+_get_output_format (EvFileExporter   *exporter,

We use the _ prefix only for private methods defined in headers, not for static methods. Use ev_file_exportrr_get_output_format() or just get_file_exporter_format()

@@ +1206,3 @@
+
+	if (!((format == EV_FILE_FORMAT_PS && gtk_printer_accepts_ps (export->printer)) ||
+	      (format == EV_FILE_FORMAT_PDF && gtk_printer_accepts_pdf (export->printer)))) {

I think it's easier to read something like

if ((format == EV_FILE_FORMAT_PS && !gtk_printer_accepts_ps (export->printer)) ||
     (format == EV_FILE_FORMAT_PDF && !gtk_printer_accepts_pdf (export->printer)) {
Comment 9 Carlos Garcia Campos 2014-03-22 09:05:53 UTC
Review of attachment 272562 [details] [review]:

Push it only to master after the freeze or ask for a string freeze break if you want to land it to stable too
Comment 10 Marek Kašík 2014-03-24 10:19:20 UTC
Thank you for the review, I'll push it to master after freeze then.
Comment 11 Carlos Garcia Campos 2014-03-24 19:23:43 UTC
I already branched, so you can push both patches to master now, but to stable only after the release.
Comment 12 Marek Kašík 2014-03-27 14:52:10 UTC
Comment on attachment 272561 [details] [review]
Allow printing to all formats supported by backend

Thank you for the review. I've pushed this patch to master and gnome-3-12.
Comment 13 Marek Kašík 2014-03-27 14:52:54 UTC
Comment on attachment 272562 [details] [review]
The warning change

I've pushed this one to master.

Thank you for your help.

Regards

Marek