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

Assigning different Stocks of paper!!!

Status
Not open for further replies.

Crauck

Programmer
Jul 26, 2002
24
US
Hello,

Keep in mind I am new to working with postscripts.

I am looking for a way to output to different color paper stock depending on what is printed on a page. It will almost be like mailmerged documents, output to a postscript file. And for example: say page 1 has "syx1" on it, we would want it to print on red paper, if not then white paper. Is there anyway this can be done????

Cristy
 
Maybe.

PostScript is device-independent. The only way to interact with your device, in regard to paper sizes or paper trays, finishing options, and so on, is through the "setpagedevice" operator.

It works by passing it a dictionary. Here's a simple and common example:

Code:
<< /PageSize [612 792] >> setpagedevice

So, you'll need to research what parameter to pass to setpagedevice, for your particular device. You can find the codes or statements for this in your PPD for your printer.

However, setpagedevice is destructive, in that in "resets" the current page. So, you can't just insert a call to setpagedevice in the middle of your page, when you encounter your target word. You'll erase the current page.

So there will almost certainly need to be some pre-processing involved.

1) scan for the keyword
2) insert a call to setpagedevice at the top of the page.

Something like that.

If I were to try to write a pure PostScript solution, it would get tricky. Maybe something with ReusableStreamDecode and currentfile would work.



Thomas D. Greer
Providing PostScript & PDF
Training, Development & Consulting
 
Isn't there anyway to use "If.. Then" Statements with "setpagedevice"???

Cristy
 
Yes, of course, but with the caveat I've described above.

Ok, let's write a simple PostScript program. You gave the example of "syx1". I'm just making an assumption here, that this will print on the page, and thus be in a string processed by "show". So our first plan is to redefine show, so that if it processes this string, to do a setpagedevice conditionally.

Code:
%!PS
/Courier 24 selectfont
10 500 moveto (syx1) show
showpage

That's our original program. Here it is re-written:

Code:
%!PS
/originalShow /show load def
/show
{ dup (syx1) eq
  { << /Tray 1 >> setpagedevice
    % this is an "imaginary" value for setpagedevice
    % i.e., it won't work, you need to look at your PPD
  } if
  originalShow
} def
/Courier 24 selectfont
10 500 moveto (syx1) show
showpage

This looks like it would work. Our new "show" procedure tests to see if the string on the stack is equal to "syx1". If it is, do our setpagedevice. If not, do nothing. Then, call the "originalShow" to paint the string on the page.

What happens though, is you get an error "nocurrentpoint", because setpagedevice erases the currentpage, which includes the currentpoint we created with "moveto".

So yes, you can use setpagedevice conditionally, but it has to be before you start to paint/mark the page.

In other words, by the time you encounter your target/test string, it's too late to use setpagedevice.



Thomas D. Greer
Providing PostScript & PDF
Training, Development & Consulting
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top