Bug 702111

Summary: MediaType parameter lost
Product: Ghostscript Reporter: Andreas Gruenbacher <andreas.gruenbacher>
Component: CUPS driverAssignee: Till Kamppeter <till.kamppeter>
Status: RESOLVED WORKSFORME    
Severity: normal CC: htl10, mike, sphinx.pinastri
Priority: P4    
Version: master   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---
Attachments: This is the expected result
This is what GhostScript produces instead
Patch

Description Andreas Gruenbacher 2020-02-11 03:12:13 UTC
When I pipe the following snippet of PostScript code:

%!PS-Adobe
<< /PageSize [300 300] /MediaType (Square) /cupsMediaType 12345 >> setpagedevice
/Helvetica findfont 24 scalefont setfont
10 10 moveto
(Hello World) show
showpage

into "gs -q -sDEVICE=cups -sOutputFile=foo.cups -", the "cupsMediaType" parameter ends up in foo.cups as expected, but "MediaType" is lost.  I found out that in cups_put_params, param_read_int returns 0 for "cupsMediaType", but param_read_string returns 1 for "MediaType", so the "MediaType" parameter apparently isn't in the parameter list.
Comment 1 Andreas Gruenbacher 2020-02-11 03:13:31 UTC
Created attachment 18843 [details]
This is the expected result

Note that 'strings foo.cups.good' will show the string "Square".
Comment 2 Andreas Gruenbacher 2020-02-11 03:14:05 UTC
Created attachment 18844 [details]
This is what GhostScript produces instead
Comment 3 Peter Cherepanov 2020-08-08 19:05:20 UTC
Ghostscript has a special option for cups: -dNOMEDIAATTRS .
This option disables normal media selection and passes media attributes to cups driver, as requested by the bug report. In short, Ghostscript works as designed.
Comment 4 Peter Cherepanov 2020-08-08 19:12:01 UTC
Created attachment 19577 [details]
Patch

This is a partial clean-up of macros in the cups driver. It helped me to solve this case, and may be worth to adopt to the code base.
Comment 5 Ken Sharp 2021-10-31 10:03:50 UTC
Closing as 'works for me' per Peter's comment #3