title: How to override default paper size for bypass tray of a printer through ghostscript?
body: <p>I'm trying to create a program to generate a postscript file from a PDF to send directly to a printer. This postscript includes printing configuration such as duplex printing, number of copies, color, paper size, etc.</p>
  <p>However, the current problem is when trying to print files by using the bypass tray when the paper size is anything other than letter. For some reason, the printer always defaults to its paper size configuration (letter) when using the custom program, which results in an offset and cropped print, yet when printing directly from other programs, those prints are fine. Only by changing the printer's default paper size for its bypass tray do those prints (the ones from the custom program) turn up OK, but then anything other than the paper size I'm trying to print gets messed up.</p>
  <p>Many different switches and setpagedevice options have been tried to get the direct printing of the generated postscripts to work, even trying similar configurations to the postscript generated by other programs, but it still prints files with different paper size than the printer's default wrong. And on the topic of changing the printer's default paper size, the model currently used (a RICOH IM600) has no auto detect paper size function.</p>
  <p>This is the Ghostscript command used for creating the postscript file:</p>
  <p><code>gs -dSAFER -dBATCH -dNOMEDIAATTRS -dNOT3CCITT -dNOINTERPOLATE -dShowAcroForm -dDEVICEWIDTHPOINTS=612 -dDEVICEHEIGHTPOINTS=936 -sProcessColorModel=DeviceCMYK -r600 -dNOPAUSE -sDEVICE=ps2write -dPSFitPage -dFIXEDMEDIA -dProduceDSC=true -sOutputFile=output.ps -c &quot;&lt;&lt;/PSDocOptions (&lt;&lt;/NumCopies 1 /Duplex true /Tumble false /MediaPosition 0 /MediaType (Auto) /Policies &lt;&lt;/PolicyNotFound 1 /PageSize 1 &gt;&gt; &gt;&gt; setpagedevice)&gt;&gt; setdistillerparams&quot; -input.pdf</code></p>
  <p>And the files are sent to the printer through TCP over port 9100</p>
  <p>What is shown in the command comes from the official Ghostscript documentation for most of the switches and the Postscript Language Reference for the pagedevice options. Though a few switches used come from what is shown at the beginning of the postscript file generated through the other programs' print option (captured using a virtual printer).</p>
  <p>Is there some other switch or page option to prevent the printer from overriding the configuration set in the postscript file?</p>
  <p>Edit: One thing I discovered upon further experimentation with the Ghostscript switches is that when I omit the DEVICEHEIGHTPOINTS and DEVICEWIDTHPOINTS switches, the ps file is generated exactly as it is being printed, with a letter paper size. Pretty much the only difference between the .ps file as seen in the computer and the print is the extra space that comes from the bigger medium I'm trying to print in. I also tried the /LockDistillerParams option but it did nothing for me.</p>