🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.postscript.programming
Article #1140

Re: Copypage in PS Level 3

#1140
From: Dale Wicks
Date: Fri, 25 Apr 2003 19:43
73 lines
3184 bytes
The following snipped out a postscript file shows how showpage is redefined using copypage to print 2 copies of a page/with merged data, with variable information on each page.

%----------------support procedures
/bd {bind def} bind def
/ld {load def} bd
/in { 72 mul } def
/ln { 12 mul } def
/mt/moveto ld
/np/newpath ld
/st/stroke ld

%% center text
/ct { 3 2 roll dup stringwidth pop 2 div 5 2 roll dup
        3 1 roll sub 2 div add 3 -1 roll sub exch mt show } def
            %% box with rounded corners
/boxDR { np 4 index 4 index 3 index dup 3 1 roll sub 2 div add
        mt dup 5 index 5 index 5 index 1 index 5 -1 roll arct
        dup 3 index 5 index 1 index 5 index 5 -1 roll arct
        dup 4 -1 roll 3 index 6 index 1 index 5 -1 roll arct
        3 index 3 -1 roll 5 -3 roll arct closepath } def
         %% gradient shaded box
/shadeR { gs dup 3 index exch sub 50 div 1.2 mul setlinewidth
    1 1 50 { dup -.008 mul 1 add setgray 3 index 2 index sub -50
        div mul dup 4 index add 5 index exch mt 3 index add 2 index
        exch lt st } for pop pop pop pop gr } def

%put text in a rounded box overlaying previous text
/tcopy { gs
                3.15 in 4.1 ln 5.35 in 1.1 ln 0.08 in boxDR clip
                3.15 in 4.1 ln 5.35 in 1.1 ln shadeR
                3.15 in 4.1 ln 5.35 in 1.1 ln 0.08 in boxDR st
                /Helvetica-Bold findfont 14 scalefont setfont
                2.2 ln exch 3.15 in 5.35 in ct gr } def

%redefine showpage
/unloaded? where
{ pop }
{ /showpage-redef-dict 10 dict def % Create our dictionary
    }
ifelse

showpage-redef-dict begin % Push the dict onto the dict stack
                                        % so our procs will be stored in it.
    /unloaded? dup where
    { pop
        false
        }
    { true
        /old-showpage /showpage load def
        }
    ifelse
    def

/ffont /Helvetica-Bold findfont 12 scalefont def
    /showpage {
        showpage-redef-dict begin
        (ORIGINAL) tcopy
        copypage
        (COPY-1) tcopy
        old-showpage
        end
        } def
    end

showpage-redef-dict /unloaded? get
{ showpage-redef-dict begin
        userdict begin
}
if

%% when showpage is in a postscript output file, 2 pages are printed
%% "ORIGINAL" prints on 1st page in a rounded box and "COPY-1" print on
%% 2nd page in same place
Technical Details
Message-ID: <1de8d77c.3@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!cyclone.bc.net!logbridge.uoregon.edu!xmission!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1de8d77c.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10c61a,4323ada0b987a5db
X-Google-Attributes: gid10c61a,public
X-Google-ArrivalTime: 2003-04-25 13:07:36 PST
From: "Dale Wicks" <dale@cu.net>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!64.152.100.70.MISMATCH!sjc70.webusenet.com!news.webusenet.com!cyclone.bc.net!logbridge.uoregon.edu!xmission!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.postscript.programming
Subject: Re: Copypage in PS Level 3
Message-ID: <1de8d77c.3@WebX.la2eafNXanI>
Date: Fri, 25 Apr 2003 12:43:28 -0700
References: <1de8d77c.-1@WebX.la2eafNXanI>
Lines: 77
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit