home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1996 September
/
PCWK996.iso
/
sharewar
/
95
/
narzedzi
/
ambra
/
ambr32a1.exe
/
FILE
/
ARCHIVE.Z
/
ACROBAT
/
VIEWER32.EXE
/
PSPROCSET
/
5
< prev
next >
Wrap
Text File
|
1996-02-22
|
14KB
|
613 lines
%%BeginFile: pdf.prc
%%Copyright: Copyright 1987-1996 Adobe Systems Incorporated. All Rights Reserved.
% general operators for PDF
% initialization
/initialize { % - initialize -
PDF begin
PDFVars begin
newpath
} bd
/terminate { % - terminate -
end
end
} bd
% path construction operators
Level2? StartLoad
{ /m/moveto ld
/l/lineto ld
/c/curveto ld
/setSA/setstrokeadjust ld
/setOP/setoverprint ld
} EndLoad
Level2? not StartLoad
{ % In L1, simulate stroke adjustment before each moveto,
% lineto, and curveto, but only if stroke adjustment is on.
% (It's set via 'gs' operator.) Default at top of page: it's on.
/pl { % x y => x y
transform
0.25 sub round 0.25 add exch
0.25 sub round 0.25 add exch
itransform
} bd
/m { _sa? { pl } if moveto } bd
/l { _sa? { pl } if lineto } bd
/c { _sa? { pl } if curveto } bd
/setSA { /_sa? xdd } bd
/setOP/pop ld % Ignore setoverprint in L1.
} EndLoad
% x2 y2 x3 y3 v -
/v { currentpoint 6 2 roll c } bd
% x1 y1 x2 y2 y -
/y { 2 copy c } bd
/h/closepath ld
% graphic state operators
/d/setdash ld
/j/setlinejoin ld
/J/setlinecap ld
/M/setmiterlimit ld
/w/setlinewidth ld
/cf currentflat def % default flatness
/i { % flatness i -
dup 0 eq { pop cf } if % use default flatness if arg is 0
setflat
} bd
% path painting operators
% init _lp - force setting of color
/ilp { /_lp /none dd } bd
% set color before fill or stroke
/sfc { % setfillcolor
_lp /fill ne { % if fill not set
_sfcs % set colorspace
_sfc % set color
/_lp /fill dd % fill now set
} if
} bd
/ssc { % setstrokecolor
_lp /stroke ne { % if stroke not set
_sscs % set colorspace
_ssc % set color
/_lp /stroke dd % stroke now set
} if
} bd
% endpath w/o painting
/n { % - n -
_doClip 1 ge {
_doClip 1 eq { clip } { eoclip } ifelse
/_doClip 0 dd
} if
newpath
} bd
% fill
/f { % - f -
_doClip 1 ge
{
gsave sfc fill grestore
_doClip 1 eq { clip } { eoclip } ifelse
newpath
ilp
/_doClip 0 dd
}
{ sfc fill }
ifelse
} bd
% eofill
/f* { % - f* -
_doClip 1 ge
{
gsave sfc eofill grestore
_doClip 1 eq { clip } { eoclip } ifelse
newpath
ilp
/_doClip 0 dd
}
{ sfc eofill }
ifelse
} bd
% stroke
/S { % - S -
_doClip 1 ge
{
gsave ssc stroke grestore
_doClip 1 eq { clip } { eoclip } ifelse
newpath
ilp
/_doClip 0 dd
}
{ ssc stroke }
ifelse
} bd
/s { h S } bd % - s -
% fill, stroke, and clip
/B { % - B -
_doClip dup 1 ge % f clears _doClip
gsave f grestore
{
gsave S grestore
1 eq { clip } { eoclip } ifelse
newpath
ilp
/_doClip 0 dd
}
{ pop S }
ifelse
} bd
/b { h B } bd % - b -
% fill, stroke, and eoclip
/B* { % - B -
_doClip dup 1 ge % f* clears _doClip
gsave f* grestore
{
gsave S grestore
1 eq { clip } { eoclip } ifelse
newpath
ilp
/_doClip 0 dd
}
{ pop S }
ifelse
} bd
/b* { h B* } bd % - b* -
% remember to clip
/W { /_doClip 1 dd } bd
/W* { /_doClip 2 dd } bd
% gsave/grestore
/q/save ld
/Q { restore ilp } bd
% Categories and Resources for PDF 1.2
% All we use are "define' and "find". For Level 1, we simply store these in a
% global dictionary, _categories. This code is not currently used for the /Font category.
Level2? StartLoad
{ /defineRes/defineresource ld
/findRes/findresource ld
currentglobal
true setglobal
[/Function /ExtGState /Form]
{ /Generic /Category findresource dup length dict copy /Category defineresource pop }
forall
setglobal
} EndLoad
Level2? not StartLoad
{ /AlmostFull? % dict => boolean
{ dup maxlength exch length sub 2 le
} bind def
/Expand % dict factor => dict'
{ 1 index maxlength mul cvi dict % create a bigger dictionary
dup begin exch { def } forall end % copy all the elements
} bind def
% Avoid 'dictfull' errors by expanding dictionaries as needed.
/xput % dict key val => dict' ("Expanding put")
{ 3 2 roll
dup 3 index known not
{ dup AlmostFull? { 1.5 Expand } if
} if
dup 4 2 roll put
} bind def
/defineRes % resourceName resource categoryName => resource
{ _categories 1 index known not
{ /_categories _categories 2 index 10 dict xput store
} if
_categories exch 2 copy get 5 -1 roll 4 index xput put
} bind def
} EndLoad
% Set up the colorspace that will be installed the next time we fill.
/cs % name cs -
{
dup where { pop load } if % load if not standard name
dup /_fcs xdd % save fill colorspace
% Now set up array to save color components.
ucs % Get the underlying colorspace.
_cpcf exch get % Get the component vector.
/_fc xdd % Store that in _fc.
/_fp { } dd % No 'fill pattern' argument.
} bd
% Set up the colorspace that will be installed the next time we stroke.
/CS
{
dup where { pop load } if % load if not standard name
dup /_scs xdd ucs _cpcs exch get /_sc xdd /_sp { } dd
} bd
% Get the underlying colorspace, so we know how many color components
% to pass to setcolor.
% The colorspace [/Pattern base] can be used for both
% colored patterns, which take no color values (just the pattern), and uncolored patterns,
% which take 1, 3, or 4 color values PLUS the pattern. scn/SCN
% stores the pattern in _fp (_sp), which is pushed onto the stack before the
% call to setcolor. sc/SC set it to the null procedure.
%
% Since we support [/Pattern [/Indexed ...]] and
% [/Pattern [/Separation ...]], it's easiest just to make ucs recursive.
/ucs { % colorspace => name
dup type /arraytype eq
{ dup 0 get
dup /Indexed eq % [/Indexed ...]
{ pop 0 get }
{ /Pattern eq
{ dup length 2 eq % [/Pattern colorspace]
{ 1 get ucs } % Recurse.
{ 0 get } % [/Pattern]: 1 component
ifelse }
{ 0 get } % [/Separation ...]: 1 component
ifelse }
ifelse }
if }
bd
/_cpcf % components per color (fill). colorspace => components-vector
15 dict dup begin
/DefaultGray _f1 def
/DeviceGray _f1 def
/DefaultRGB _f3 def
/DeviceRGB _f3 def
/DeviceCMYK _f4 def
/CalGray _f1 def
/CalRGB _f3 def
/CalCMYK _f4 def
/Lab _f3 def
/Pattern _f0 def % colored
/Indexed _f1 def
/Separation _f1 def
/CIEBasedA _f1 def
/CIEBasedABC _f3 def
end
dd
/_cpcs % components per color (stroke). colorspace => components-vector
15 dict dup begin
/DefaultGray _s1 def
/DeviceGray _s1 def
/DefaultRGB _s3 def
/DeviceRGB _s3 def
/DeviceCMYK _s4 def
/CalGray _s1 def
/CalRGB _s3 def
/CalCMYK _s4 def
/Lab _s3 def
/Pattern _s0 def % colored
/Indexed _s1 def
/Separation _s1 def
/CIEBasedA _s1 def
/CIEBasedABC _s3 def
end
dd
Level2? not StartLoad { % L1 defs
% L1 setcolor fns set color space as well, so _sfcs does nothing
/_sfcs { } dd
/_sscs { } dd
/_sfc { _fc L1setcolor } dd
/_ssc { _sc L1setcolor } dd
/L1setcolor { %: color-components-array => -
aload length
% From the number of colors, we can tell which operator to use.
% Uncolored patterns will use their underlying color space.
dup 0 eq
{ pop .5 setgray } % Colored pattern
{ dup 1 eq
{ pop setgray } % DeviceGray, Indexed, Separation
{ 3 eq
{ setrgbcolor } % DeviceRGB, CalRGB, Lab
{ setcmykcolor } % DeviceCMYK, CalCMYK
ifelse }
ifelse }
ifelse
} bind dd
% set render intent % name ri -
/ri/pop ld
% makePat % patDict mtx => patDict
/makePat/pop ld % We use the dictionary only to check its PaintType.
/sethalftone % Emulate for L1
{ % halftoneDict => -
begin
HalftoneType 1 eq
{ Frequency Angle /SpotFunction load }
{ 0 0 currentdict }
ifelse
setscreen
end
} bind def
} EndLoad
Level2? StartLoad
{
% L2 defs
/_sfcs
{
_fcs setcolorspace
} bind dd % Set the colorspace for fill.
/_sscs
{
_scs setcolorspace
} bind dd % Set the colorspace for stroke
/_sfc % Set the fill color.
{
_fc aload pop % Push the color components ...
_fp % ... and maybe the fill pattern
setcolor % ... then set the color.
} bind dd
/_ssc
{
_sc aload pop _sp setcolor
} bind dd % Set the color for stroke.
% set render intent % name ri -
/ri
{
/findcolorrendering isdefined?
{
findcolorrendering pop
dup /ColorRendering resourcestatus
{
pop pop
/ColorRendering findresource
setcolorrendering
}
{
pop
} ifelse
}
{
pop
} ifelse
} bd
/makePat /makepattern ld
} EndLoad
% set fill or stroke color
/sc % set fill color % c1 ... cn sc -
{
_fc astore pop
ilp
} bd
/SC % set stroke color % c1 ... cn SC -
{
_sc astore pop
ilp
} bd
% set fill color for patterns.
% If the value on the top of the stack is not a name, then this
% is equivalent to 'sc'. Otherwise, the name refers to a pattern.
% If the current colorspace is /Pattern, then 'name' must be a
% colored pattern, but if it's [/Pattern base], then we have to
% examine the pattern to see whether it's colored. If it's a colored
% pattern, we use _f0 for the "components."
/scn { % c1 ... cn name scn -
dup type /nametype eq
{ /Pattern findRes % Get the value.
dup /_fpat xdd % Store that in _fpat
/_fp { _fpat } dd % Redefine _fp to push _fpat.
/PaintType get 1 eq % Colored?
{ /_fc _f0 dd ilp } % Yes. Set _fc to a 0-length array.
{ /_fc cpcf _fcs ucs get dd % No. Recompute _fc ...
sc } % ... and store c1..cn there.
ifelse }
{ sc }
ifelse
} bd
/SCN { % c1 ... cn name SCN -
dup type /nametype eq
{ /Pattern findRes % Get the value.
dup /_spat xdd % Store that in _spat
/_sp { _spat } dd % Redefine _sp to push _spat.
/PaintType get 1 eq % Colored?
{ /_sc _s0 dd ilp } % Yes. Set _sc to a 0-length array.
{ /_sc cpc _scs ucs get dd % No. Recompute _sc ...
SC } % ... and store c1..cn there.
ifelse }
{ SC }
ifelse
} bd
% color operators
/g { /DefaultGray cs sc } bd
/rg { /DefaultRGB cs sc } bd
/k { /DeviceCMYK cs sc } bd
/G { /DefaultGray CS SC } bd
/RG { /DefaultRGB CS SC } bd
/K { /DeviceCMYK CS SC } bd
% a b c d x y cm -
/cm { _mtx astore concat } bd
% x y width height re -
% Add the rectangle to the current path
/re {
4 2 roll m % x y m
1 index 0 rlineto % w 0 rlineto
0 exch rlineto % 0 h rlineto
neg 0 rlineto % -w 0 rlineto
h
} bd
% x y width height RC -
/RC/rectclip ld
% formdict EF -
/EF/execform ld
% exec-string PS -
/PS { cvx exec } bd
% initialize gstate once per page
/initgs {
/DefaultGray where
{ pop }
{ /DefaultGray /DeviceGray dd }
ifelse
/DefaultRGB where
{ pop }
{ /DefaultRGB /DeviceRGB dd }
ifelse
0 g 0 G
[] 0 d 0 j 0 J 10 M 1 w
true setSA
} bd
% The predefined spot functions
17 dict dup begin
/CosineDot
{ 180 mul cos exch 180 mul cos add 2 div } bd
/Cross
{ abs exch abs 2 copy gt { exch } if pop neg } bd
/Diamond % Photoshop's version
{ abs exch abs 2 copy add .75 le
{ dup mul exch dup mul add 1 exch sub }
{ 2 copy add 1.23 le
{ .85 mul add 1 exch sub }
{ 1 sub dup mul exch 1 sub dup mul add 1 sub }
ifelse }
ifelse } bd
/DoubleDot
{ 2 { 360 mul sin 2 div exch } repeat add } bd
/Ellipse
{ abs exch abs 2 copy 3 mul exch 4 mul add 3 sub dup 0 lt
{ pop dup mul exch .75 div dup mul add 4 div
1 exch sub }
{ dup 1 gt
{pop 1 exch sub dup mul exch 1 exch sub
.75 div dup mul add 4 div 1 sub }
{ .5 exch sub exch pop exch pop }
ifelse }
ifelse } bd
/EllipseB
{ dup 5 mul 8 div mul exch dup mul exch add sqrt 1 exch sub } bd
/EllipseC
{ dup .5 gt { 1 exch sub } if
dup .25 ge
{ .5 exch sub 4 mul dup mul 1 sub }
{ 4 mul dup mul 1 exch sub }
ifelse
exch
dup .5 gt { 1 exch sub } if
dup .25 ge
{ .5 exch sub 4 mul dup mul 1 sub }
{ 4 mul dup mul 1 exch sub }
ifelse
add -2 div } bd
/InvertedDoubleDot
{ 2 { 360 mul sin 2 div exch } repeat add neg } bd
/InvertedEllipseA
{ dup mul .9 mul exch dup mul add 1 sub } bd
/InvertedSimpleDot
{ dup mul exch dup mul add 1 sub } bd
/Line
{ exch pop abs neg } bd
/LineY % called "Line" in FrameMaker 5
{ pop } bd
/Rhomboid
{ abs exch abs 0.9 mul add 2 div } bd
% 0.8 in FrameMaker 5
/Round
{ abs exch abs 2 copy add 1 le
{ dup mul exch dup mul add 1 exch sub }
{ 1 sub dup mul exch 1 sub dup mul add 1 sub }
ifelse } bd
/SimpleDot
{ dup mul exch dup mul add 1 exch sub } bd
/Square
{ abs exch abs 2 copy lt { exch } if pop neg } bd
end
{ /Function defineRes pop } forall
/Identity {} /Function defineRes pop
Level2? StartLoad {
/gs
{
begin
/SA here { setstrokeadjust } if
/OP here { setoverprint } if
/BG here { setblackgeneration } if
/UCR here { setundercolorremoval } if
/HT here { sethalftone } if
/sethalftonephase isdefined? { /HTP here { sethalftonephase } if } if
/TR here
{ % A procedure or an array of 4 procedures.
dup xcheck { settransfer } { setcolortransfer } ifelse
} if
end
} bd
} EndLoad
Level2? not StartLoad {
/gs
{
begin
/SA here { /_sa? xdd } if
/HT here
{
begin
HalftoneType 1 eq
{ Frequency Angle /SpotFunction load setscreen }
if
end
} if
/TR here { dup type xcheck { settransfer } if } if
end
} bd
} EndLoad
% 'truncate2' and 'int' are used in code that interpolates from sampled values
% in function resources.
/truncate2 { 2 copy idiv 3 1 roll mod } bd
/int { % x x0 x1 y0 y1 => y
% On the line defined by (x0,y0) and (x1,y1), interpolate a
% value for y, given x.
dup 2 index sub 3 index 5 index sub div 6 -2 roll sub mul
exch pop add exch pop
} bd
%%EndFile