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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get paper tray source

Status
Not open for further replies.

schmitte

Programmer
Nov 23, 2005
3
FR
I want to test the paper tray source to execute some code if I am on a specific tray. For exemaple I want to display a logo on my page when I am on tray 1 and don't display logo if I am on another tray.
 
Paper Tray "calls" are device-specific. You'll find the appropriate commands in your PPD. You can read the current page device with the "currentpagedevice" operator.

Thomas D. Greer
 
I am new in postscript language, please have you an example to explain to me how to do that? I want to print to an HP2420 printer, I have look the ppd file and I think my solution is in the parameter /mediatype or /Inputslot, is this right ?
Thank's in advance for your answer...

*%==========================================
*% Media Type
*%=========================================
*OpenUI *MediaType/Media Type: PickOne
*OrderDependency: 20 AnySetup *MediaType
*DefaultMediaType: None
*MediaType None/None: "
<</ManualFeed false /MediaType null >> setpagedevice"
*End
*MediaType Plain/Plain: "
<</ManualFeed false /MediaType (Plain)>> setpagedevice"
*End
*MediaType Preprinted/Preprinted: "
<</ManualFeed false /MediaType (Preprinted)>> setpagedevice"
*End
*MediaType Letterhead/Letterhead: "
<</ManualFeed false /MediaType (Letterhead)>> setpagedevice"
*End
*MediaType Transparency/Transparency: "
<</ManualFeed false /MediaType (Transparency)>> setpagedevice"
*End
*MediaType Prepunched/Prepunched: "
<</ManualFeed false /MediaType (Prepunched)>> setpagedevice"
*End
*MediaType Labels/Labels: "
<</ManualFeed false /MediaType (Labels)>> setpagedevice"
*End
*MediaType Bond/Bond: "
<</ManualFeed false /MediaType (Bond)>> setpagedevice"
*End
*MediaType Recycled/Recycled: "
<</ManualFeed false /MediaType (Recycled)>> setpagedevice"
*End
*MediaType Color/Color: "
<</ManualFeed false /MediaType (Color)>> setpagedevice"
*End
*MediaType Rough/Rough: "
<</ManualFeed false /MediaType (Rough)>> setpagedevice"
*End
*MediaType Card_Stock/Card Stock <3e>164 g/m2: "
<</ManualFeed false /MediaType (Card Stock)>> setpagedevice"
*End
*MediaType Envelope/Envelope: "
<</ManualFeed false /MediaType (Envelope)>> setpagedevice"
*End

*%=================================================
*% Paper Sources
*%=================================================
*OpenUI *InputSlot: PickOne
*OrderDependency: 20 AnySetup *InputSlot
*DefaultInputSlot: Tray2
*InputSlot Tray1/Tray 1: "<</ManualFeed false /MediaPosition 3>> setpagedevice"
*InputSlot Tray2/Tray 2: "<</ManualFeed false /MediaPosition 0>> setpagedevice"
 
Let me ask you this, how are you planning on implementing your conditional code? Are you going to author some PostScript, perhaps using /BeginPage or /EndPage, and stick it at the top?

Or are you going to "insert" some PostScript, based on finding strings in your original PostScript? In other words, are you using some other language to "search" through your PostScript code?

Your PPD is telling you that this code selects Tray 1:

Code:
<</ManualFeed false /MediaPosition 3>> setpagedevice

So, if you find that within your PostScript, you know it's trying to print on Tray 1. You could possibly insert your logo code directly after that statement.

If you want to try it dynamically, using PostScript, you could use "currentpagedevice".

Code:
currentpagedevice /ManualFeed get not
currentpagedevice /MediaPosition 3 get and
{ %% on Tray 1
  %% do logo here
} if

You would wrap all of that up into a /BeginPage procedure, which gets called each time there is a showpage, so that it would execute on each page.

Code:
<<
/BeginPage
{
  pop
  currentpagedevice /ManualFeed get not
  currentpagedevice /MediaPosition 3 get and
  { %% on Tray 1
    %% do logo here
  } if
} bind
>> setpagedevice

Further, you should encode your logo as a PostScript Form, so the display list is cached for better performance. More information about that is available in articles I've written on my site.

All code posted here is untested!

Thomas D. Greer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top