Change DocumentName using Ghostscript

459 views Asked by At

I have requirement of changing DocumentName that is being printed. This document name will display in printer spool. I am using Ghostscript c# wrapper to print PDF. It shows "Ghostscript output" in printer spool list. Ghostscript documentation provides a way but I didn't manage to make it work.

Here in 10.2 section they described it. https://www.ghostscript.com/doc/9.26/Devices.htm#Win

This is what I tried to run with CLI :

gswin64c.exe "D:\setup.ps" -o "D:/test.pdf" "C:\Users\ashish\Documents\tt.pdf"

Setup.ps

mark
  /NoCancel      true                       % don't show the cancel dialog
  /BitsPerPixel  4                          % force 4 bits/pixel
  /UserSettings
    <<
      /DocumentName  (Ghostscript document) % name for the Windows spooler
      /MaxResolution 360                    % maximum document resolution
    >>
  (mswinpr2) finddevice                     % select the Windows device driver
  putdeviceprops
setdevice

Result:

GPL Ghostscript 9.52 (2020-03-19)
Copyright (C) 2020 Artifex Software, Inc.  All rights reserved.
This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:
see the file COPYING for details.
| c:\Users\cjl\artifex\gs-release\9.52\ghostpdl-9.52\base\gsicc_manage.c:1888: gsicc_verify_device_profiles(): Mismatch of ICC profiles and device color model
| c:\Users\cjl\artifex\gs-release\9.52\ghostpdl-9.52\base\gsicc_manage.c:2015: gsicc_set_device_profile(): Error in device profiles
Error: /undefined in --.systemvar--
Operand stack:
   rangecheck   --dict:736/1123(ro)(G)--   .putdeviceprops
Execution stack:
   %interp_exit   .runexec2   --nostringval--   .systemvar   --nostringval--   2   %stopped_push   --nostringval--   .systemvar   .systemvar   false   1   %stopped_push   1990   1   3   %oparray_pop   1989   1   3   %oparray_pop   1977   1   3   %oparray_pop   1833   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   .systemvar   --nostringval--   2   %stopped_push   --nostringval--   1831   8   3   %oparray_pop   .systemvar   1814   8   3   %oparray_pop   .systemvar   1808   2   3   %oparray_pop
Dictionary stack:
   --dict:736/1123(ro)(G)--   --dict:0/20(G)--   --dict:75/200(L)--
Current allocation mode is local
Last OS error: Permission denied
Current file position is 430
GPL Ghostscript 9.52: Unrecoverable error, exit code 1

Thanks

0

There are 0 answers