Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ghostscript ps file not recognizing mediaposition

Status
Not open for further replies.

treichert

Programmer
Jan 24, 2006
1
US
I have a ps file generated from a pdf (generated from distiller (generated from a mulitple single page ps files)).
the idea here is that the product we have producing singular ps files, we then use distiller to combine them into a single pdf (optimized for resources), but we have 2 page letter that need to be printed on different stocks, so I use ghostscript to turn the pdf back into a (single) ps file.
I was then hoping to insert "<</mediaposition 1>> setpagedevice" calls to pull from different trays. I have had success with this on almost all my ps files until this ghostscript version. I have places the call after "%%PageTrailer" normally, but it does not work now.
the ghostscript ps file will read my first mediaposition call but then "ignore" the rest of them. my printer is a ricoh 2090. thanks for any help,

here is a portion of the ps file:
%!PS-Adobe-3.0
%%Pages: (atend)
%%BoundingBox: 7 16 591 785
%%HiResBoundingBox: 7.100000 16.000000 590.100000 784.800000
%.......................................
%%Creator: AFPL Ghostscript 853 (pswrite)
%%CreationDate: 2006/01/23 16:03:28
%%DocumentData: Clean7Bit
%%LanguageLevel: 2
%%EndComments
%%BeginProlog
% This copyright applies to everything between here and the %%EndProlog:
% Copyright (C) 2005 artofcode LLC, Benicia, CA. All rights reserved.
%%BeginResource: procset GS_pswrite_2_0_1001
/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 readonly def
%%EndResource
/pagesave null def
%%EndProlog
%%Page: 1 1
%%BeginPageSetup
GS_pswrite_2_0_1001 begin
612 792 /letter setpagesize
/pagesave save store 197 dict begin
0.1 0.1 scale
%%EndPageSetup
gsave mark

...

cleartomark end end pagesave restore
showpage
%%PageTrailer
%%Page: 2 2
%%BeginPageSetup
GS_pswrite_2_0_1001 begin
612 792 /letter setpagesize
/pagesave save store 197 dict begin
0.1 0.1 scale
%%EndPageSetup
gsave mark

...

cleartomark end end pagesave restore
showpage
%%PageTrailer
%%Page: 3 3

...
 
I believe that it should be MediaPosition, not mediaposition. This call (as part of setpagedevice) should be the first call at the beginning of a new page description. %%PageTrailer and DSC are nice to follow, but won't help once it reaches the actual printer (comments are ignored by the printer, the print managers are what pay attention to these comments).

Once the page media has been set, and the actual rendering has begun, it's unlikely that the printer will allow media changes like tray calls. I don't know where you placed the actual MediaPosition relative to the specific page, but it sounds like it might have been at the end of a page instead of the beginning. Personally I have to use this so it does not crash on ghostscript, yet allows me to use it on Xerox printers (this is a contrived sample, adjust for your case; something similar to this should be at the start of every new page):

currentpagedevice /MediaPosition known {
<<
/Duplex false
/Tumble false
/MediaPosition 2
/MediaClass (Special)
>>
setpagedevice
1.0 0.0 0.0 setrgbcolor
} {
<<
/Duplex false
/Tumble false
>>
setpagedevice
0.0 0.0 1.0 setrgbcolor
} ifelse
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top