Bug 702111 - MediaType parameter lost
Summary: MediaType parameter lost
Status: RESOLVED WORKSFORME
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: CUPS driver (show other bugs)
Version: master
Hardware: PC Linux
: P4 normal
Assignee: Till Kamppeter
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-11 03:12 UTC by Andreas Gruenbacher
Modified: 2021-10-31 10:03 UTC (History)
3 users (show)

See Also:
Customer:
Word Size: ---


Attachments
This is the expected result (23.34 KB, application/octet-stream)
2020-02-11 03:13 UTC, Andreas Gruenbacher
Details
This is what GhostScript produces instead (23.34 KB, application/octet-stream)
2020-02-11 03:14 UTC, Andreas Gruenbacher
Details
Patch (3.20 KB, patch)
2020-08-08 19:12 UTC, Peter Cherepanov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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