后记:知道我需要什么,但不知道如何去做

发布于 2025-01-15 07:48:24 字数 1503 浏览 3 评论 0原文

我们通过将 ps 和 eps 文件粘合在一起并叠加数据来打印客户表格来创建打印文件......然后将这些文件发送到打印机。

由于打印机发生了变化,我们必须调整脚本。我们现在正在研究 XEROX 打印机,它们是非常不同的动物。

我们已经建立了一个程序来设置打印托盘,它需要更改。Xerox

 /stray 
{   
/Pagedv exch def
 #ifdef :OK431   
/DriverOps /ProcSet 2 copy resourcestatus{pop pop findresource Pagedv exch /setinputslot get exec}{pop pop}ifelse globaldict /OK@_CustTray 0 put
 #elif :O4600   
 /PageSub Pagedv 1 sub def   currentpagedevice /InputAttributes get PageSub known{ Pagedv statusdict /setpapertray 2 copy known{ get {exec}stopped {pop}{globaldict /OK@_CustTray PageSub put}ifelse (<<) cvx exec /Policies (<<) cvx exec /PageSize 7 (>>) cvx
 exec (>>) cvx exec setpagedevice }{pop pop pop}ifelse }if
 #elif :HPPRO   
  currentpagedevice /InputAttributes get Pagedv  <</MediaPosition Pagedv >> setpagedevice
 #else   
 <<currentpagedevice /InputAttributes get Pagedv get {}forall /InputAttributes << /Priority [Pagedv] >> >> setpagedevice

不不根据 PPD 使用数字,它使用字符串(即 Tray-1)

Pagedv 是一个整数,因此我需要在将其返回给调用者之前将文字“Tray-”附加(连接)到它上面

> #elif :XRX   
>  currentpagedevice /InputAttributes get Pagedv  << (Tray-Pagedv) xerox$MediaInputTray >> setpagedevice

我有一个连接程序我只是不确定在这种情况下如何使用它。

/concatstrings % (a) (b) -> (ab)     
{ exch dup length    
    2 index length add string    
    dup dup 4 2 roll copy length
    4 -1 roll putinterval    
} bind def

We create printfiles by gluing ps and eps files together and overlay data to print customer forms.. and then send those files to the printer.

As printers have changed we have had to adjust the scripts.. We are now looking at XEROX printers and they are very different animals..

We've built a procedure that sets the tray to print from and it needs a change..

 /stray 
{   
/Pagedv exch def
 #ifdef :OK431   
/DriverOps /ProcSet 2 copy resourcestatus{pop pop findresource Pagedv exch /setinputslot get exec}{pop pop}ifelse globaldict /OK@_CustTray 0 put
 #elif :O4600   
 /PageSub Pagedv 1 sub def   currentpagedevice /InputAttributes get PageSub known{ Pagedv statusdict /setpapertray 2 copy known{ get {exec}stopped {pop}{globaldict /OK@_CustTray PageSub put}ifelse (<<) cvx exec /Policies (<<) cvx exec /PageSize 7 (>>) cvx
 exec (>>) cvx exec setpagedevice }{pop pop pop}ifelse }if
 #elif :HPPRO   
  currentpagedevice /InputAttributes get Pagedv  <</MediaPosition Pagedv >> setpagedevice
 #else   
 <<currentpagedevice /InputAttributes get Pagedv get {}forall /InputAttributes << /Priority [Pagedv] >> >> setpagedevice

Xerox doesn't use a number according to the PPD it uses a string (ie Tray-1)

Pagedv is an integer so I need to append (concatenate) the literal "Tray-" onto it before we return it to the caller

> #elif :XRX   
>  currentpagedevice /InputAttributes get Pagedv  << (Tray-Pagedv) xerox$MediaInputTray >> setpagedevice

I have a concatenate procedure I'm just not sure how to use it in this case.

/concatstrings % (a) (b) -> (ab)     
{ exch dup length    
    2 index length add string    
    dup dup 4 2 roll copy length
    4 -1 roll putinterval    
} bind def

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小帐篷 2025-01-22 07:48:24

如果你想连接两个字符串来生成一个新字符串,并且你拥有的是一个字符串和一个整数(Pagedv),那么你需要做的第一件事就是将整数转换为字符串。

为此,您需要一个足够大的空字符串来保存结果,然后将其和整数传递给 cvs 运算符。因此,PostScript 片段如下所示:

Pagedv      % The operand to convert to string
256 string  % A 256 element string to receive the result
            % stack is now - integer string
cvs         % consumes integer and string and returns a substring
            % stack is now - substring

因此,如果 Pagedv 的值为 1,那么您现在将拥有长度为 1 的 PostScript 字符串 (1)

如果您已经定义了 /concatstrings 函数,并且确定它可用(即在字典堆栈上的字典中并且不会被同名的另一个函数隐藏),那么您只需执行以下操作:

(Tray-) exch concatstrings

这将产生一个字符串 (Tray-1).您可能会发现避免调用函数并在本地一次性完成整个事情会更简单。

Pagedv 256 string cvs         % convert integer to string
dup length 5 add string       % copy new string, get length, create final string big enough to hold Tray-result
                              % The above is probably overkill, very few printers have more than 9 trays! But best to be safe
dup 0 (Tray-) putinterval     % copy final string, put Tray- at start of final string
dup 5 4 -1 roll putinterval   % copy final string, put converted integer string into final result, starting at position 5.

Well if you want to concatenate two strings to produce a new string, and what you have is a string and an integer (Pagedv), then the first thing you need to do is turn the integer into a string.

To do that you'll need an empty string big enough to hold the result, and then pass that and the integer to the cvs operator. So a PostScript fragment like this:

Pagedv      % The operand to convert to string
256 string  % A 256 element string to receive the result
            % stack is now - integer string
cvs         % consumes integer and string and returns a substring
            % stack is now - substring

So if you had a value of 1 for Pagedv then you would now have a PostScript string (1) of length 1.

If you've already defined your /concatstrings function, and are certain it will be available (ie in a dictionary on the dictionary stack and not concealed by another function of the same name) then you would just do:

(Tray-) exch concatstrings

Which would result in a string of (Tray-1). You might find it simpler to avoid calling a function and just do the whole thing at once locally.

Pagedv 256 string cvs         % convert integer to string
dup length 5 add string       % copy new string, get length, create final string big enough to hold Tray-result
                              % The above is probably overkill, very few printers have more than 9 trays! But best to be safe
dup 0 (Tray-) putinterval     % copy final string, put Tray- at start of final string
dup 5 4 -1 roll putinterval   % copy final string, put converted integer string into final result, starting at position 5.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文