# Inserting Print Commands

Inserting Print Commands

Friday Nov 30, 2012

I'm often asked about printing to a different paper tray from a legacy application on Windows.  When I say legacy, I simply mean an application that doesn't support Windows printer drivers per-se.  These application could be DOS-based or even Unix/Linux.  They create their own PCL or PS datastream and the Windows printer queue is simply a way to get the file to the printer.

Your need might be to change the paper tray or some other change such as resolution, orientation, paper size etc.  Your legacy application might not be sending the correct (or any) commands to the printer.  In these cases you can leverage the Windows job separator to insert your own commands.

For example, we have a DOS application that sends down PCL including some basic text along with fonts but no tray selection.  In this case we would create a file that includes the commands we need to insert.

Sample: tray5.pcl

This file includes:

`<esc>&l21H`

These commands can be found in most manufacturers PCL/PS/PDL programming guides.  In most cases the commands are interchangeable.  The command above is the PCL set for tray 5.

Next you need a separator page file that includes the trigger to use the file you just created.

Sample: traySelection.sep

This file includes:

`@Fc:\printerCommands\tray5.pcl`

The @F tells the separator page component of the the Windows Spooler to insert the data in the file to the datastream.  The @ at the start of the file is there as some system seem to ignore the separator commands without it (undocumented feature!).

NOTE: Microsoft updates in the past years have tightened security to the point where these 2 files might need to be placed in c:\windows\system32.

I've also used this to download custom fonts or macros to a print device that doesn't support storage of fonts and resources.

If you find that your output contains some commands or printer resets that don't allow your commands to register, you can go to the extent of "swallowing" those commands.  Assuming that they are of a consistent length.  See my article on this: (swallowing-pcl-commands).

Further details on separator page usage can be found here:

http://support.microsoft.com/kb/102712