0

I am trying to print a postscript file where the first page has to use one tray and the second page has to use a second one.

I have tried this using setDevice but it does not work. The printer either sends all pages to one tray or to another but does not switch between pages.

I tried with the following command

    <</ManualFeed false /MediaPosition 0>> setpagedevice

I tried placing it before the %%BeginPageSetup and within the %%BeginPageSetup but it does not make a difference. I use ghostscript command to send it to the printer.

<</ManualFeed false /MediaPosition 0>> setpagedevice
%%Page: 1 1
%%BeginPageSetup
GS_pswrite_2_0_1001 begin
595 842 /a4 setpagesize
/pagesave save store 197 dict begin
0.1 0.1 scale
%%EndPageSetup
gsave mark
...
cleartomark end end pagesave restore
 showpage
%%PageTrailer
<</ManualFeed false /MediaPosition 1>> setpagedevice
%%Page: 2 2
%%BeginPageSetup
GS_pswrite_2_0_1001 begin
595 842 /a4 setpagesize
/pagesave save store 197 dict begin
0.1 0.1 scale
%%EndPageSetup
gsave mark
...
cleartomark end end pagesave restore
 showpage
%%PageTrailer

Here is the prolog

%%BeginProlog
% This copyright applies to everything between here and the %%EndProlog:
% Copyright (C) 2008 Artifex Software, Inc.  All rights reserved.
%%BeginResource: procset GS_pswrite_2_0_1001 1.001 0
/GS_pswrite_2_0_1001 80 dict dup begin
/PageSize 2 array def/setpagesize{ PageSize aload pop 3 index eq exch
4 index eq and{ pop pop pop}{ PageSize dup  1
5 -1 roll put 0 4 -1 roll put dup null eq {false} {dup where} ifelse{ exch get exec}
{ pop/setpagedevice where
{ pop 1 dict dup /PageSize PageSize put setpagedevice}
{ /setpage where{ pop PageSize aload pop pageparams 3 {exch pop} repeat
setpage}if}ifelse}ifelse}ifelse} bind def
/!{bind def}bind def/#{load def}!/N/counttomark #
/rG{3{3 -1 roll 255 div}repeat setrgbcolor}!/G{255 div setgray}!/K{0 G}!
/r6{dup 3 -1 roll rG}!/r5{dup 3 1 roll rG}!/r3{dup rG}!
/w/setlinewidth #/J/setlinecap #
/j/setlinejoin #/M/setmiterlimit #/d/setdash #/i/setflat #
/m/moveto #/l/lineto #/c/rcurveto #
/p{N 2 idiv{N -2 roll rlineto}repeat}!
/P{N 0 gt{N -2 roll moveto p}if}!
/h{p closepath}!/H{P closepath}!
/lx{0 rlineto}!/ly{0 exch rlineto}!/v{0 0 6 2 roll c}!/y{2 copy c}!
/re{4 -2 roll m exch dup lx exch ly neg lx h}!
/^{3 index neg 3 index neg}!
/f{P fill}!/f*{P eofill}!/s{H stroke}!/S{P stroke}!
/q/gsave #/Q/grestore #/rf{re fill}!
/Y{P clip newpath}!/Y*{P eoclip newpath}!/rY{re Y}!
/|={pop exch 4 1 roll 1 array astore cvx 3 array astore cvx exch 1 index def exec}!
/|{exch string readstring |=}!
/+{dup type/nametype eq{2 index 7 add -3 bitshift 2 index mul}if}!
/@/currentfile #/${+ @ |}!
/B{{2 copy string{readstring pop}aload pop 4 array astore cvx
3 1 roll}repeat pop pop true}!
/Ix{[1 0 0 1 11 -2 roll exch neg exch neg]exch}!
/,{true exch Ix imagemask}!/If{false exch Ix imagemask}!/I{exch Ix image}!
/Ic{exch Ix false 3 colorimage}!
/F{/Columns counttomark 3 add -2 roll/Rows exch/K -1/BlackIs1 true>>
/CCITTFaxDecode filter}!/FX{<</EndOfBlock false F}!
/X{/ASCII85Decode filter}!/@X{@ X}!/&2{2 index 2 index}!
/@F{@ &2<<F}!/@C{@X &2 FX}!
/$X{+ @X |}!/&4{4 index 4 index}!/$F{+ @ &4<<F |}!/$C{+ @X &4 FX |}!
/IC{3 1 roll 10 dict begin 1{/ImageType/Interpolate/Decode/DataSource
/ImageMatrix/BitsPerComponent/Height/Width}{exch def}forall
currentdict end image}!
/~{@ read {pop} if}!
end def
%%EndResource
/pagesave null def
%%EndProlog

Thanks for you help,

Pat

user2097439
  • 201
  • 2
  • 16

1 Answers1

0

This isn't really a Ghostscript question.

The selection of tray position is device-dependent, you need to find out what your particular PostScript printer needs. If that fragment of PostScript is correct, then all I can suggest is that you try putting the setpagedevice after the setpagesize. I can't recall offhand exactly what that routine does, and you haven't included the entire prolog, but it certainly will involve a call to setpagedevice.

The obvious way to test this, of course, is to send a simple 'do nothing' PostScript test program with the tray selection commands to the printer:

%!
<</ManualFeed false /MediaPosition 0>> setpagedevice
showpage
<</ManualFeed false /MediaPosition 1>> setpagedevice
showpage

That should eject a blank page from each tray. If that doesn't work, then you need some other magic for your printer.

I note that the PostScript is fairly obviously the output from Ghostscript's ps2write device. You can have that device inject the PostScript for you by using the PSPageOptions switch. Of course, the PostScript still has to be correct for the device.

KenS
  • 30,202
  • 3
  • 34
  • 51
  • Sorry you are right, added the prolog to the question. Since it seemed very cryptic I had left it out. – user2097439 Jun 19 '20 at 06:33
  • Goodness, what version of Ghostscript are you running ? That looks the old, obselete, deprecated (and now removed) pswrite device, rather than the ps2write device. If you are using pswrite I'd very much suggest you stop, update to a reasonably recent version, and use ps2write instead. – KenS Jun 19 '20 at 08:48
  • OK dumb question, is this PostScript file one you are producing yourself ? If so what command line are you using to create it ? Did you try the simple PostScript in my answer ? What result did you get from that ? – KenS Jun 19 '20 at 12:09