2 |
- |
1 |
% Copyright (C) 1996, 2000 Aladdin Enterprises. All rights reserved.
|
|
|
2 |
%
|
|
|
3 |
% This software is provided AS-IS with no warranty, either express or
|
|
|
4 |
% implied.
|
|
|
5 |
%
|
|
|
6 |
% This software is distributed under license and may not be copied,
|
|
|
7 |
% modified or distributed except as expressly authorized under the terms
|
|
|
8 |
% of the license contained in the file LICENSE in this distribution.
|
|
|
9 |
%
|
|
|
10 |
% For more information about licensing, please refer to
|
|
|
11 |
% http://www.ghostscript.com/licensing/. For information on
|
|
|
12 |
% commercial licensing, go to http://www.artifex.com/licensing/ or
|
|
|
13 |
% contact Artifex Software, Inc., 101 Lucas Valley Road #110,
|
|
|
14 |
% San Rafael, CA 94903, U.S.A., +1(415)492-9861.
|
|
|
15 |
|
|
|
16 |
% $Id: gs_pdfwr.ps,v 1.52 2005/10/20 13:04:16 leonardo Exp $
|
|
|
17 |
% PDF writer additions to systemdict.
|
|
|
18 |
|
|
|
19 |
% This file should be included iff the pdfwrite "device" is included
|
|
|
20 |
% in the executable.
|
|
|
21 |
|
|
|
22 |
% ---------------- Predefined configurations ---------------- %
|
|
|
23 |
|
|
|
24 |
% These correspond to the 4 predefined settings in Acrobat Distiller 5,
|
|
|
25 |
% plus a "default" setting that doesn't downsample images.
|
|
|
26 |
|
|
|
27 |
/.a2112 [2 1 1 2] readonly def
|
|
|
28 |
/.a1111 [1 1 1 1] readonly def
|
|
|
29 |
/.standardfonts [
|
|
|
30 |
/Courier /Courier-Bold /Courier-Oblique /Courier-BoldOblique
|
|
|
31 |
/Helvetica /Helvetica-Bold /Helvetica-Oblique /Helvetica-BoldOblique
|
|
|
32 |
/Times-Roman /Times-Bold /Times-Italic /Times-BoldItalic
|
|
|
33 |
/Symbol /ZapfDingbats
|
|
|
34 |
] readonly def
|
|
|
35 |
|
|
|
36 |
% Parameters common to all non-default configurations.
|
|
|
37 |
% Note that the default configuration overrides a few of these.
|
|
|
38 |
/.defaultImageDict mark
|
|
|
39 |
/QFactor 0.9 /Blend 1
|
|
|
40 |
/HSamples .a2112 /VSamples .a2112
|
|
|
41 |
.dicttomark readonly def
|
|
|
42 |
/.distillercommon mark
|
|
|
43 |
/AlwaysEmbed []
|
|
|
44 |
/AntiAliasColorImages false
|
|
|
45 |
/AntiAliasGrayImages false
|
|
|
46 |
/AntiAliasMonoImages false
|
|
|
47 |
/ASCII85EncodePages false
|
|
|
48 |
/AutoFilterColorImages true
|
|
|
49 |
/AutoFilterGrayImages true
|
|
|
50 |
/AutoPositionEPSFiles true
|
|
|
51 |
/Binding /Left
|
|
|
52 |
/CalCMYKProfile (None) % (U.S. Web Coated (SWOP) v2)
|
|
|
53 |
/CalGrayProfile (None) % (Dot Gain 20%)
|
|
|
54 |
/CalRGBProfile (None) % (sRGB IEC61966-2.1)
|
|
|
55 |
/ColorImageDepth -1
|
|
|
56 |
/ColorImageDict .defaultImageDict
|
|
|
57 |
/ColorImageDownsampleThreshold 1.5
|
|
|
58 |
/ColorImageFilter /DCTEncode
|
|
|
59 |
/CompressPages true
|
|
|
60 |
/ConvertImagesToIndexed true
|
|
|
61 |
/DefaultRenderingIntent /Default
|
|
|
62 |
/DetectBlends true
|
|
|
63 |
/DownsampleColorImages true
|
|
|
64 |
/DownsampleGrayImages true
|
|
|
65 |
/DownsampleMonoImages true
|
|
|
66 |
/EmitDSCWarnings false
|
|
|
67 |
/EncodeColorImages true
|
|
|
68 |
/EncodeGrayImages true
|
|
|
69 |
/EncodeMonoImages true
|
|
|
70 |
/EndPage -1
|
|
|
71 |
/GrayImageDepth -1
|
|
|
72 |
/GrayImageDict .defaultImageDict
|
|
|
73 |
/GrayImageDownsampleThreshold 1.5
|
|
|
74 |
/GrayImageFilter /DCTEncode
|
|
|
75 |
/ImageMemory 524288
|
|
|
76 |
/LockDistillerParams false
|
|
|
77 |
/MaxSubsetPct 100
|
|
|
78 |
/MonoImageDepth -1
|
|
|
79 |
/MonoImageDict mark
|
|
|
80 |
/K -1
|
|
|
81 |
.dicttomark readonly
|
|
|
82 |
/MonoImageDownsampleThreshold 1.5
|
|
|
83 |
/MonoImageFilter /CCITTFaxEncode
|
|
|
84 |
/OffOptimizations 0
|
|
|
85 |
/OPM 1
|
|
|
86 |
/Optimize true
|
|
|
87 |
/ParseDSCComments true
|
|
|
88 |
/ParseDSCCommentsForDocInfo true
|
|
|
89 |
/PreserveCopyPage true
|
|
|
90 |
/PreserveHalftoneInfo false
|
|
|
91 |
/sRGBProfile (None) % (sRGB IEC61966-2.1)
|
|
|
92 |
/StartPage 1
|
|
|
93 |
/SubsetFonts true
|
|
|
94 |
/TransferFunctionInfo /Preserve
|
|
|
95 |
/UseFlateCompression true
|
|
|
96 |
/UsePrologue false
|
|
|
97 |
.dicttomark readonly def
|
|
|
98 |
|
|
|
99 |
/.distillersettings mark
|
|
|
100 |
|
|
|
101 |
/default mark
|
|
|
102 |
/AutoRotatePages /PageByPage
|
|
|
103 |
/CannotEmbedFontPolicy /Warning
|
|
|
104 |
/ColorACSImageDict .defaultImageDict
|
|
|
105 |
/ColorConversionStrategy /LeaveColorUnchanged
|
|
|
106 |
% /ColorImageDownsampleType
|
|
|
107 |
% /ColorImageResolution
|
|
|
108 |
% /CompatibilityLevel
|
|
|
109 |
/CreateJobTicket false
|
|
|
110 |
/DoThumbnails false
|
|
|
111 |
/DownsampleColorImages false % override
|
|
|
112 |
/DownsampleGrayImages false % override
|
|
|
113 |
/DownsampleMonoImages false % override
|
|
|
114 |
/EmbedAllFonts true
|
|
|
115 |
/GrayACSImageDict .defaultImageDict
|
|
|
116 |
% /GrayImageDownsampleType
|
|
|
117 |
% /GrayImageResolution
|
|
|
118 |
% /MonoImageDownsampleType
|
|
|
119 |
% /MonoImageResolution
|
|
|
120 |
/NeverEmbed .standardfonts
|
|
|
121 |
/Optimize false % override
|
|
|
122 |
/PreserveEPSInfo true
|
|
|
123 |
/PreserveOPIComments true
|
|
|
124 |
/PreserveOverprintSettings true
|
|
|
125 |
/UCRandBGInfo /Preserve
|
|
|
126 |
.dicttomark readonly
|
|
|
127 |
|
|
|
128 |
/.screenACSImageDict mark
|
|
|
129 |
/QFactor 0.76 /Blend 1 /ColorTransform 1
|
|
|
130 |
/HSamples .a2112 /VSamples .a2112
|
|
|
131 |
.dicttomark readonly def
|
|
|
132 |
/screen mark
|
|
|
133 |
/AutoRotatePages /PageByPage
|
|
|
134 |
% /CalGrayProfile (None)
|
|
|
135 |
/CannotEmbedFontPolicy /Warning
|
|
|
136 |
/ColorACSImageDict .screenACSImageDict
|
|
|
137 |
/ColorConversionStrategy /sRGB
|
|
|
138 |
/ColorImageDownsampleType /Average
|
|
|
139 |
/ColorImageResolution 72
|
|
|
140 |
/CompatibilityLevel 1.3
|
|
|
141 |
/CreateJobTicket false
|
|
|
142 |
/DoThumbnails false
|
|
|
143 |
/EmbedAllFonts true
|
|
|
144 |
/GrayACSImageDict .screenACSImageDict
|
|
|
145 |
/GrayImageDownsampleType /Average
|
|
|
146 |
/GrayImageResolution 72
|
|
|
147 |
/MonoImageDownsampleType /Average
|
|
|
148 |
/MonoImageResolution 300
|
|
|
149 |
/NeverEmbed .standardfonts
|
|
|
150 |
/PreserveEPSInfo false
|
|
|
151 |
/PreserveOPIComments false
|
|
|
152 |
/PreserveOverprintSettings false
|
|
|
153 |
/UCRandBGInfo /Remove
|
|
|
154 |
.dicttomark readonly
|
|
|
155 |
|
|
|
156 |
/ebook mark
|
|
|
157 |
/AutoRotatePages /All
|
|
|
158 |
% /CalGrayProfile (None)
|
|
|
159 |
/CannotEmbedFontPolicy /Warning
|
|
|
160 |
/ColorACSImageDict .screenACSImageDict
|
|
|
161 |
/ColorConversionStrategy /sRGB
|
|
|
162 |
/ColorImageDownsampleType /Bicubic
|
|
|
163 |
/ColorImageResolution 150
|
|
|
164 |
/CompatibilityLevel 1.4
|
|
|
165 |
/CreateJobTicket false
|
|
|
166 |
/DoThumbnails false
|
|
|
167 |
/EmbedAllFonts true
|
|
|
168 |
/GrayACSImageDict .screenACSImageDict
|
|
|
169 |
/GrayImageDownsampleType /Bicubic
|
|
|
170 |
/GrayImageResolution 150
|
|
|
171 |
/MonoImageDownsampleType /Bicubic
|
|
|
172 |
/MonoImageResolution 300
|
|
|
173 |
/NeverEmbed .standardfonts
|
|
|
174 |
/PreserveEPSInfo false
|
|
|
175 |
/PreserveOPIComments false
|
|
|
176 |
/PreserveOverprintSettings false
|
|
|
177 |
/UCRandBGInfo /Remove
|
|
|
178 |
.dicttomark readonly
|
|
|
179 |
|
|
|
180 |
/.printerACSImageDict mark
|
|
|
181 |
/QFactor 0.4 /Blend 1 /ColorTransform 1
|
|
|
182 |
/HSamples .a1111 /VSamples .a1111
|
|
|
183 |
.dicttomark readonly def
|
|
|
184 |
/printer mark
|
|
|
185 |
/AutoRotatePages /None
|
|
|
186 |
% /CalGrayProfile (None)
|
|
|
187 |
/CannotEmbedFontPolicy /Warning
|
|
|
188 |
/ColorACSImageDict .printerACSImageDict
|
|
|
189 |
/ColorConversionStrategy /UseDeviceIndependentColor
|
|
|
190 |
/ColorImageDownsampleType /Bicubic
|
|
|
191 |
/ColorImageResolution 300
|
|
|
192 |
/CompatibilityLevel 1.4
|
|
|
193 |
/CreateJobTicket true
|
|
|
194 |
/DoThumbnails false
|
|
|
195 |
/EmbedAllFonts true
|
|
|
196 |
/GrayACSImageDict .printerACSImageDict
|
|
|
197 |
/GrayImageDownsampleType /Bicubic
|
|
|
198 |
/GrayImageResolution 300
|
|
|
199 |
/MonoImageDownsampleType /Bicubic
|
|
|
200 |
/MonoImageResolution 1200
|
|
|
201 |
/NeverEmbed []
|
|
|
202 |
/PreserveEPSInfo true
|
|
|
203 |
/PreserveOPIComments true
|
|
|
204 |
/PreserveOverprintSettings true
|
|
|
205 |
/UCRandBGInfo /Preserve
|
|
|
206 |
.dicttomark readonly
|
|
|
207 |
|
|
|
208 |
/.prepressACSImageDict mark
|
|
|
209 |
/QFactor 0.15 /Blend 1 /ColorTransform 1
|
|
|
210 |
/HSamples .a1111 /VSamples .a1111
|
|
|
211 |
.dicttomark readonly def
|
|
|
212 |
/prepress mark
|
|
|
213 |
/AutoRotatePages /None
|
|
|
214 |
/CannotEmbedFontPolicy /Error
|
|
|
215 |
/ColorACSImageDict .prepressACSImageDict
|
|
|
216 |
/ColorConversionStrategy /LeaveColorUnchanged
|
|
|
217 |
/ColorImageDownsampleType /Bicubic
|
|
|
218 |
/ColorImageResolution 300
|
|
|
219 |
/CompatibilityLevel 1.4
|
|
|
220 |
/CreateJobTicket true
|
|
|
221 |
/DoThumbnails true
|
|
|
222 |
/EmbedAllFonts true
|
|
|
223 |
/GrayACSImageDict .prepressACSImageDict
|
|
|
224 |
/GrayImageDownsampleType /Bicubic
|
|
|
225 |
/GrayImageResolution 300
|
|
|
226 |
/MonoImageDownsampleType /Bicubic
|
|
|
227 |
/MonoImageResolution 1200
|
|
|
228 |
/NeverEmbed []
|
|
|
229 |
/PreserveEPSInfo true
|
|
|
230 |
/PreserveOPIComments true
|
|
|
231 |
/PreserveOverprintSettings true
|
|
|
232 |
/UCRandBGInfo /Preserve
|
|
|
233 |
.dicttomark readonly
|
|
|
234 |
|
|
|
235 |
% Define distiller settings for the ps2write device and for the ps2ps2 script :
|
|
|
236 |
/PSL2Printer mark
|
|
|
237 |
/AutoRotatePages /None
|
|
|
238 |
/CannotEmbedFontPolicy /Error
|
|
|
239 |
/ColorACSImageDict .prepressACSImageDict
|
|
|
240 |
/ColorConversionStrategy /LeaveColorUnchanged
|
|
|
241 |
/ColorImageDownsampleType /Bicubic
|
|
|
242 |
/ColorImageResolution 600
|
|
|
243 |
/CompatibilityLevel 1.2 % Always 1.2 with ps2write.
|
|
|
244 |
% /CreateJobTicket true % Not sure
|
|
|
245 |
/DoThumbnails false
|
|
|
246 |
/EmbedAllFonts true
|
|
|
247 |
/GrayACSImageDict .prepressACSImageDict
|
|
|
248 |
/GrayImageDownsampleType /Bicubic
|
|
|
249 |
/GrayImageResolution 600
|
|
|
250 |
/MonoImageDownsampleType /Bicubic
|
|
|
251 |
/MonoImageResolution 1200
|
|
|
252 |
/NeverEmbed []
|
|
|
253 |
/PreserveEPSInfo true
|
|
|
254 |
/PreserveOPIComments true
|
|
|
255 |
/PreserveOverprintSettings true
|
|
|
256 |
/UCRandBGInfo /Preserve
|
|
|
257 |
|
|
|
258 |
/PreserveHalftoneInfo true
|
|
|
259 |
/TransferFunctionInfo /Preserve
|
|
|
260 |
/MaxViewerMemorySize 8000000
|
|
|
261 |
/CompressPages false
|
|
|
262 |
/CompressFonts false
|
|
|
263 |
/ASCII85EncodePages true
|
|
|
264 |
.dicttomark readonly
|
|
|
265 |
|
|
|
266 |
.dicttomark readonly def
|
|
|
267 |
|
|
|
268 |
% ---------------- End of predefined configurations ---------------- %
|
|
|
269 |
|
|
|
270 |
% Set optimizations for converting PostScript to PDF.
|
|
|
271 |
% The ps2pdf* scripts invoke this.
|
|
|
272 |
/.setpdfwrite { % - .setpdfwrite -
|
|
|
273 |
% Set a large VM threshold to reduce garbage collection.
|
|
|
274 |
currentuserparams /VMThreshold get 3000000 .max setvmthreshold
|
|
|
275 |
} bind def
|
|
|
276 |
|
|
|
277 |
% ---------------- pdfmark and DSC processing ---------------- %
|
|
|
278 |
|
|
|
279 |
/.write_small_positive_real % <file> <real> .write_small_positive_real -
|
|
|
280 |
{ % The argument must be grater than 0 and must be strongly samller than 0.1.
|
|
|
281 |
% The conversion isn't simple due to the low (24 bits) precision
|
|
|
282 |
% of the floating point arithmetics in Postscript.
|
|
|
283 |
% For best result we first use the 1e8 factor since its binary
|
|
|
284 |
% representation 101111101011110000100000000 well rounds into 14 significant
|
|
|
285 |
% bits : 101111101011110000000000000 .
|
|
|
286 |
1 index (.) writestring
|
|
|
287 |
{ dup 100000000 mul
|
|
|
288 |
dup 10 mul 1 ge {
|
|
|
289 |
% Will need not greater than 0.1 due to a rounding below.
|
|
|
290 |
pop exit
|
|
|
291 |
} if
|
|
|
292 |
exch pop
|
|
|
293 |
1 index (00000000) writestring
|
|
|
294 |
} loop
|
|
|
295 |
% Now it is not smaller than 1e-9, use simple digitizing.
|
|
|
296 |
{ dup 10 mul
|
|
|
297 |
dup 10 mul 1 ge {
|
|
|
298 |
pop exit
|
|
|
299 |
} if
|
|
|
300 |
exch pop
|
|
|
301 |
1 index (0) writestring
|
|
|
302 |
} loop
|
|
|
303 |
% Now 0.01 <= n < 0.1, but rounding may give 0.1 .
|
|
|
304 |
% Convert to integer with 7 digits precision :
|
|
|
305 |
100000000 % precision factor 1e8 % f n r
|
|
|
306 |
dup 10 idiv 3 1 roll mul 0.5 add cvi % f r' N
|
|
|
307 |
2 copy le {
|
|
|
308 |
% The rounding overflows, suppress it.
|
|
|
309 |
% Note it carries out an additional digit,
|
|
|
310 |
% that's why we needed <0.1 above.
|
|
|
311 |
pop pop (1) writestring
|
|
|
312 |
} {
|
|
|
313 |
% Didn't cary out, put 0.
|
|
|
314 |
2 index (0) writestring
|
|
|
315 |
exch % f N r
|
|
|
316 |
% Continue the simple digitizing :
|
|
|
317 |
{ 10 idiv dup % f N r' r'
|
|
|
318 |
2 index exch idiv % f N r' d
|
|
|
319 |
(0123456789) exch 1 getinterval % f N r' (d)
|
|
|
320 |
3 index exch writestring % f N r'
|
|
|
321 |
dup 3 2 roll exch mod % f r' N'
|
|
|
322 |
dup 0 eq {
|
|
|
323 |
% Don't write trailing zeros.
|
|
|
324 |
exit
|
|
|
325 |
} if
|
|
|
326 |
exch % f N' r'
|
|
|
327 |
} loop
|
|
|
328 |
pop pop pop
|
|
|
329 |
} ifelse
|
|
|
330 |
} bind def
|
|
|
331 |
|
|
|
332 |
% Encode values to pass for the /pdfmark or /DSC pseudo-parameter.
|
|
|
333 |
/.pdf===dict mark
|
|
|
334 |
/arraytype
|
|
|
335 |
{ dup xcheck { ({) (}) } { ([) (]) } ifelse
|
|
|
336 |
% Stack: file obj left right
|
|
|
337 |
4 1 roll 2 index exch writestring () exch
|
|
|
338 |
{ exch 2 index exch writestring
|
|
|
339 |
1 index exch pdf===only ( )
|
|
|
340 |
}
|
|
|
341 |
forall pop exch writestring
|
|
|
342 |
} bind
|
|
|
343 |
/packedarraytype 1 index
|
|
|
344 |
/dicttype
|
|
|
345 |
{ 1 index (<<\n) writestring
|
|
|
346 |
{ 2 index 3 -1 roll pdf===only 1 index ( ) writestring
|
|
|
347 |
1 index exch pdf===only dup (\n) writestring
|
|
|
348 |
}
|
|
|
349 |
forall (>>) writestring
|
|
|
350 |
} bind
|
|
|
351 |
/nametype {
|
|
|
352 |
% If the name string includes any non-regular characters,
|
|
|
353 |
% write it with two preceding and one following null character(s).
|
|
|
354 |
% (Null characters in the name itself are not allowed.)
|
|
|
355 |
% This non-standard escape convention is required for passing names
|
|
|
356 |
% that include non-regular characters, because PostScript provides
|
|
|
357 |
% no way to do this. The pdf_scan_token procedure in the C code of
|
|
|
358 |
% the pdfwrite driver is currently the only place that recognizes
|
|
|
359 |
% this convention.
|
|
|
360 |
dup .namestring (\000\011\012\014\015 %()/<>[]{}) .stringbreak null ne {
|
|
|
361 |
dup .namestring (\000) .stringbreak null ne {
|
|
|
362 |
/rangecheck signalerror
|
|
|
363 |
} if
|
|
|
364 |
1 index <0000> writestring 1 index exch write===only 0 write
|
|
|
365 |
} {
|
|
|
366 |
write===only
|
|
|
367 |
} ifelse
|
|
|
368 |
} bind
|
|
|
369 |
/realtype {
|
|
|
370 |
% Prevent using floating point format - see Bug 688167.
|
|
|
371 |
dup dup 0 lt { neg } if 0.01 lt {
|
|
|
372 |
dup 0 eq {
|
|
|
373 |
pop (0) writestring
|
|
|
374 |
} {
|
|
|
375 |
dup 0 lt {
|
|
|
376 |
1 index (-) writestring neg
|
|
|
377 |
} if
|
|
|
378 |
.write_small_positive_real
|
|
|
379 |
} ifelse
|
|
|
380 |
} {
|
|
|
381 |
write===only
|
|
|
382 |
} ifelse
|
|
|
383 |
} bind
|
|
|
384 |
.dicttomark readonly def
|
|
|
385 |
/pdf===only { % <file> <obj> pdf===only -
|
|
|
386 |
.pdf===dict 1 index type .knownget { exec } { write===only } ifelse
|
|
|
387 |
} bind def
|
|
|
388 |
/.pdfcvbuf 30 string def % enough for most arguments
|
|
|
389 |
userdict /.pdfcvstring () put
|
|
|
390 |
/.pdfcvs { % <obj> .pdfcvs <string>
|
|
|
391 |
currentglobal exch false .setglobal
|
|
|
392 |
/.pdfcvstring () store
|
|
|
393 |
% We can't handle long values yet.
|
|
|
394 |
{ pop dup length 0 eq { pop } {
|
|
|
395 |
/.pdfcvstring .pdfcvstring 3 -1 roll concatstrings store
|
|
|
396 |
} ifelse //.pdfcvbuf
|
|
|
397 |
} /NullEncode filter dup 3 -1 roll pdf===only
|
|
|
398 |
closefile
|
|
|
399 |
.setglobal .pdfcvstring
|
|
|
400 |
} bind def
|
|
|
401 |
|
|
|
402 |
% Redefine pdfmark to pass the data to the driver.
|
|
|
403 |
% We use a pseudo-parameter named /pdfmark whose value is an array:
|
|
|
404 |
% /key1 (value1) ... (CTM) /type
|
|
|
405 |
/.pdfputparams { % -mark- <key1> <value1> ... .pdfputparams <result...>
|
|
|
406 |
currentdevice null false counttomark 1 add 3 roll
|
|
|
407 |
% Don't allow the page device to get cleared....
|
|
|
408 |
{.putdeviceparams} .currentpagedevice pop {.setpagedevice} 3 .execn
|
|
|
409 |
} bind def
|
|
|
410 |
% Convert relevant operands to strings in an array.
|
|
|
411 |
/.pdfcvsloop { % -mark- values ... markname start step .pdfcvsloop
|
|
|
412 |
% [values ... ctm markname]
|
|
|
413 |
matrix currentmatrix .pdfcvs 4 1 roll
|
|
|
414 |
counttomark 1 add 2 roll
|
|
|
415 |
counttomark .localvmarray astore exch pop
|
|
|
416 |
3 1 roll
|
|
|
417 |
% Stack: values start step
|
|
|
418 |
2 index length 3 sub { 2 copy 2 copy get .pdfcvs put pop } for
|
|
|
419 |
} bind def
|
|
|
420 |
/.pdfcvsall { % -mark- values ... markname .pdfcvsall <<same>>
|
|
|
421 |
|
|
|
422 |
} bind def
|
|
|
423 |
/.pdfcvseven { % -mark- key value ... markname .pdfcvseven <<same>>
|
|
|
424 |
1 2 .pdfcvsloop
|
|
|
425 |
} bind def
|
|
|
426 |
/.pdfcvsnone { % -mark- values ... markname .pdfcvsnone <<same>>
|
|
|
427 |
100000 1 .pdfcvsloop
|
|
|
428 |
} bind def
|
|
|
429 |
/.pdfcvsfirst { % -mark- first values ... markname .pdfcvsfirst<<same>>
|
|
|
430 |
.pdfcvsnone
|
|
|
431 |
dup 0 2 copy get .pdfcvs put
|
|
|
432 |
} bind def
|
|
|
433 |
% The procedures in the following dictionary are called with the entire
|
|
|
434 |
% pdfmark operand list (including the pdfmark name) on the stack;
|
|
|
435 |
% they may modify this ad lib. They must call .pdfcvsxxx.
|
|
|
436 |
/.pdfmarkparams mark
|
|
|
437 |
% Unpack a dictionary for PUT, and don't convert stream data.
|
|
|
438 |
/PUT {
|
|
|
439 |
counttomark 3 eq {
|
|
|
440 |
1 index type /dicttype eq {
|
|
|
441 |
pop { } forall /.PUTDICT .pdfcvsall
|
|
|
442 |
} {
|
|
|
443 |
pop dup type /filetype eq {
|
|
|
444 |
% Read the file into a sequence of strings.
|
|
|
445 |
% This isn't great, but it's simple.
|
|
|
446 |
{
|
|
|
447 |
dup 64000 string readstring not { exch exit } if
|
|
|
448 |
exch
|
|
|
449 |
} loop closefile
|
|
|
450 |
} if
|
|
|
451 |
/.PUTSTREAM .pdfcvsfirst
|
|
|
452 |
} ifelse
|
|
|
453 |
} {
|
|
|
454 |
.pdfcvsall
|
|
|
455 |
} ifelse
|
|
|
456 |
} bind
|
|
|
457 |
% Unpack the array for PUTINTERVAL.
|
|
|
458 |
/PUTINTERVAL {
|
|
|
459 |
pop aload pop /.PUTINTERVAL .pdfcvsall
|
|
|
460 |
} bind
|
|
|
461 |
.dicttomark readonly def
|
|
|
462 |
/.pdfparamerror { % ? ? ? -mark- ... <errname> <opname> .pdfparamerror -
|
|
|
463 |
counttomark 4 add 2 roll cleartomark pop pop pop
|
|
|
464 |
.systemvar exch signalerror
|
|
|
465 |
} bind def
|
|
|
466 |
/pdfmark { % -mark- <key> <value> ... <markname> pdfmark -
|
|
|
467 |
dup /SP eq {
|
|
|
468 |
% A hack for synchronizing the clipping path.
|
|
|
469 |
gsave
|
|
|
470 |
[1 0 0 1 0 0] setmatrix 0 setlinewidth
|
|
|
471 |
newpath -3 -3 moveto closepath stroke % Paints outside the device bbox.
|
|
|
472 |
grestore
|
|
|
473 |
} if
|
|
|
474 |
dup /PS eq systemdict /PDFX .knownget not { false } if and {
|
|
|
475 |
% Execute it since PDF/X doesn't allow to embed it.
|
|
|
476 |
{ dup mark eq {
|
|
|
477 |
pop exit
|
|
|
478 |
} if
|
|
|
479 |
1 index /DataSource eq {
|
|
|
480 |
cvx exec
|
|
|
481 |
} {
|
|
|
482 |
pop pop
|
|
|
483 |
} ifelse
|
|
|
484 |
} loop
|
|
|
485 |
} {
|
|
|
486 |
counttomark 1 add copy
|
|
|
487 |
//.pdfmarkparams 1 index .knownget { exec } { .pdfcvsall } ifelse
|
|
|
488 |
mark /pdfmark 3 -1 roll .pdfputparams
|
|
|
489 |
dup type /booleantype ne {
|
|
|
490 |
/pdfmark .pdfparamerror
|
|
|
491 |
} if cleartomark
|
|
|
492 |
} ifelse
|
|
|
493 |
} odef
|
|
|
494 |
userdict /pdfmark .undef
|
|
|
495 |
currentdict /.pdfmarkparams .undef
|
|
|
496 |
|
|
|
497 |
|
|
|
498 |
% <dict> .hook_DSC_Creator -
|
|
|
499 |
/.pdf_hook_DSC_Creator
|
|
|
500 |
{
|
|
|
501 |
% If the Creator is PScript5.dll, disable the 32 /FontType resource for
|
|
|
502 |
% handling GlyphNames2Unicode. Since /FontType category can't redefine,
|
|
|
503 |
% we can do only with redefining the operator 'resourcestatus'.
|
|
|
504 |
currentdevice .devicename /pdfwrite eq {
|
|
|
505 |
/Creator .knownget {
|
|
|
506 |
(PScript5.dll) search {
|
|
|
507 |
pop pop
|
|
|
508 |
systemdict /resourcestatus dup
|
|
|
509 |
{ dup /FontType eq 2 index 32 eq and {
|
|
|
510 |
pop pop false
|
|
|
511 |
} {
|
|
|
512 |
resourcestatus
|
|
|
513 |
} ifelse
|
|
|
514 |
} bind .makeoperator .forceput
|
|
|
515 |
} if
|
|
|
516 |
pop
|
|
|
517 |
} if
|
|
|
518 |
} {
|
|
|
519 |
pop
|
|
|
520 |
} ifelse
|
|
|
521 |
}
|
|
|
522 |
bind def
|
|
|
523 |
|
|
|
524 |
% Use the DSC processing hook to pass DSC comments to the driver.
|
|
|
525 |
% We use a pseudo-parameter named DSC whose value is an array:
|
|
|
526 |
% /key1 (value1) ... /type
|
|
|
527 |
/.pdfdsc_dict 2 dict def
|
|
|
528 |
/.pdfdsc { % <file> <DSC string> <dsc dict> [<prev proc>] .pdfdsc -
|
|
|
529 |
|
|
|
530 |
% Stack: <dsc string> <dsc dict>
|
|
|
531 |
20 .localvmdict 1 index { 3 copy put pop pop } forall
|
|
|
532 |
3 -1 roll .parse_dsc_comments % <dsc dict> <dict> <type>
|
|
|
533 |
1 index //.pdf_hook_DSC_Creator exec
|
|
|
534 |
dup /NOP ne 2 index length 1 gt or { % Skip unparsed comments
|
|
|
535 |
PDFWRDEBUG { (**** DSC comment: ) print dup == 1 index === flush } if
|
|
|
536 |
exch mark 4 1 roll {
|
|
|
537 |
% mark <key1> <value1> ... <dsc dict> <type> <key> <value>
|
|
|
538 |
3 index 2 index known { % Skip the DSC_struct entry
|
|
|
539 |
pop pop
|
|
|
540 |
} {
|
|
|
541 |
.pdfcvs 4 -2 roll
|
|
|
542 |
} ifelse
|
|
|
543 |
} forall exch pop counttomark .localvmarray astore
|
|
|
544 |
mark /DSC 3 -1 roll .pdfputparams
|
|
|
545 |
dup type /booleantype ne {
|
|
|
546 |
/DSC .pdfparamerror
|
|
|
547 |
} {
|
|
|
548 |
cleartomark
|
|
|
549 |
} ifelse
|
|
|
550 |
} {
|
|
|
551 |
pop pop pop
|
|
|
552 |
} ifelse
|
|
|
553 |
} bind def
|
|
|
554 |
currentdict /.pdf_hook_DSC_Creator undef
|
|
|
555 |
/.initialize_dsc_parser where {
|
|
|
556 |
pop
|
|
|
557 |
3000 % priority
|
|
|
558 |
{
|
|
|
559 |
currentglobal true setglobal
|
|
|
560 |
2 dict dup .initialize_dsc_parser readonly
|
|
|
561 |
currentuserparams /ProcessDSCComment get
|
|
|
562 |
1 array astore % in case the value is executable
|
|
|
563 |
//.pdfdsc /exec load 4 array astore cvx readonly
|
|
|
564 |
<< /ProcessDSCComment 3 -1 roll >> setuserparams
|
|
|
565 |
setglobal
|
|
|
566 |
} bind .schedule_init
|
|
|
567 |
} if
|
|
|
568 |
|
|
|
569 |
% ---------------- {set,current}distillerparams ---------------- %
|
|
|
570 |
|
|
|
571 |
% Define setdistillerparams / currentdistillerparams.
|
|
|
572 |
% Distiller parameters are currently treated as device parameters.
|
|
|
573 |
/.distillerparamkeys mark
|
|
|
574 |
% General parameters -- all distillers
|
|
|
575 |
/ASCII85EncodePages { }
|
|
|
576 |
/AutoRotatePages { }
|
|
|
577 |
/Binding { }
|
|
|
578 |
/CompressPages { }
|
|
|
579 |
/DefaultRenderingIntent { }
|
|
|
580 |
/DetectBlends { }
|
|
|
581 |
/DoThumbnails { }
|
|
|
582 |
/ImageMemory { }
|
|
|
583 |
/LockDistillerParams { }
|
|
|
584 |
/LZWEncodePages { }
|
|
|
585 |
/OPM { }
|
|
|
586 |
/PreserveHalftoneInfo { }
|
|
|
587 |
/PreserveOPIComments { }
|
|
|
588 |
/PreserveOverprintSettings { }
|
|
|
589 |
/TransferFunctionInfo { }
|
|
|
590 |
/UCRandBGInfo { }
|
|
|
591 |
/UseFlateCompression { }
|
|
|
592 |
% General parameters -- PDF writer
|
|
|
593 |
% StartPage and EndPage are renamed because EndPage
|
|
|
594 |
% clashes with a page device parameter.
|
|
|
595 |
/CoreDistVersion { }
|
|
|
596 |
/CompatibilityLevel { }
|
|
|
597 |
% ****** NOTE: StartPage and EndPage are disabled because
|
|
|
598 |
% ****** EndPage clashes with a page device parameter.
|
|
|
599 |
% /EndPage { exch pop /PDFEndPage exch }
|
|
|
600 |
/PDFEndPage { pop pop }
|
|
|
601 |
% /StartPage { exch pop /PDFStartPage exch }
|
|
|
602 |
/PDFStartPage { pop pop }
|
|
|
603 |
/Optimize { }
|
|
|
604 |
/ParseDSCCommentsForDocInfo { }
|
|
|
605 |
/ParseDSCComments { }
|
|
|
606 |
/EmitDSCWarnings { }
|
|
|
607 |
/CreateJobTicket { }
|
|
|
608 |
/PreserveEPSInfo { }
|
|
|
609 |
/AutoPositionEPSFiles { }
|
|
|
610 |
/PreserveCopyPage { }
|
|
|
611 |
/UsePrologue { }
|
|
|
612 |
/OffOptimizations { }
|
|
|
613 |
% Color sampled image parameters
|
|
|
614 |
/ColorACSImageDict { }
|
|
|
615 |
/AntiAliasColorImages { }
|
|
|
616 |
/AutoFilterColorImages { }
|
|
|
617 |
/ColorImageDepth { }
|
|
|
618 |
/ColorImageDict { }
|
|
|
619 |
/DownsampleColorImages { }
|
|
|
620 |
/ColorImageDownsampleThreshold { }
|
|
|
621 |
/ColorImageDownsampleType { }
|
|
|
622 |
/EncodeColorImages { }
|
|
|
623 |
/ColorImageFilter { }
|
|
|
624 |
/ColorImageResolution { }
|
|
|
625 |
% Color processing parameters
|
|
|
626 |
/CalCMYKProfile { }
|
|
|
627 |
/CalGrayProfile { }
|
|
|
628 |
/CalRGBProfile { }
|
|
|
629 |
/sRGBProfile { }
|
|
|
630 |
/ColorConversionStrategy { }
|
|
|
631 |
/ConvertCMYKImagesToRGB { }
|
|
|
632 |
/ConvertImagesToIndexed { }
|
|
|
633 |
% Grayscale sampled image parameters
|
|
|
634 |
/GrayACSImageDict { }
|
|
|
635 |
/AntiAliasGrayImages { }
|
|
|
636 |
/AutoFilterGrayImages { }
|
|
|
637 |
/GrayImageDepth { }
|
|
|
638 |
/GrayImageDict { }
|
|
|
639 |
/DownsampleGrayImages { }
|
|
|
640 |
/GrayImageDownsampleThreshold { }
|
|
|
641 |
/GrayImageDownsampleType { }
|
|
|
642 |
/EncodeGrayImages { }
|
|
|
643 |
/GrayImageFilter { }
|
|
|
644 |
/GrayImageResolution { }
|
|
|
645 |
% Monochrome sampled image parameters
|
|
|
646 |
/AntiAliasMonoImages { }
|
|
|
647 |
/MonoImageDepth { }
|
|
|
648 |
/MonoImageDict { }
|
|
|
649 |
/DownsampleMonoImages { }
|
|
|
650 |
/MonoImageDownsampleThreshold { }
|
|
|
651 |
/MonoImageDownsampleType { }
|
|
|
652 |
/EncodeMonoImages { }
|
|
|
653 |
/MonoImageFilter { }
|
|
|
654 |
/MonoImageResolution { }
|
|
|
655 |
% Font embedding parameters
|
|
|
656 |
/AlwaysEmbed
|
|
|
657 |
{ dup length 0 gt
|
|
|
658 |
{ dup 0 get false eq
|
|
|
659 |
{ dup length 1 sub 1 exch getinterval exch pop /~AlwaysEmbed exch
|
|
|
660 |
} if
|
|
|
661 |
} if
|
|
|
662 |
}
|
|
|
663 |
/NeverEmbed
|
|
|
664 |
{ dup length 0 gt
|
|
|
665 |
{ dup 0 get false eq
|
|
|
666 |
{ dup length 1 sub 1 exch getinterval exch pop /~NeverEmbed exch
|
|
|
667 |
} if
|
|
|
668 |
} if
|
|
|
669 |
}
|
|
|
670 |
/CannotEmbedFontPolicy { }
|
|
|
671 |
/EmbedAllFonts { }
|
|
|
672 |
/MaxSubsetPct { }
|
|
|
673 |
/SubsetFonts { }
|
|
|
674 |
.dicttomark readonly def
|
|
|
675 |
/.distillerdevice
|
|
|
676 |
{ currentdevice .devicename dup /pdfwrite eq exch /ps2write eq or
|
|
|
677 |
{ currentdevice }
|
|
|
678 |
{ /pdfwrite finddevice }
|
|
|
679 |
ifelse
|
|
|
680 |
} bind def
|
|
|
681 |
|
|
|
682 |
% Some badly designed PostScript files only expect the current/set
|
|
|
683 |
% distillerparams operators to exist in a distiller. Since we have
|
|
|
684 |
% this as a runtime option, we enable these operators IFF the
|
|
|
685 |
% currentdevice is pdfwrite. Also, we mask their existence in
|
|
|
686 |
% systemdict so that 'where' and 'known' don't show them unless
|
|
|
687 |
% the currentdevice is pdfwrite.
|
|
|
688 |
/.setdistillerparams { % <dict> setdistillerparams -
|
|
|
689 |
.distillerdevice //null false mark 4 index {
|
|
|
690 |
//.distillerparamkeys 2 index .knownget { exec } { pop pop } ifelse
|
|
|
691 |
} forall .putdeviceparamsonly
|
|
|
692 |
dup type /booleantype ne {
|
|
|
693 |
/setdistillerparams .pdfparamerror
|
|
|
694 |
} {
|
|
|
695 |
pop pop pop
|
|
|
696 |
} ifelse
|
|
|
697 |
} odef
|
|
|
698 |
/.currentdistillerparams { % - currentdistillerparams <dict>
|
|
|
699 |
.distillerdevice //.distillerparamkeys .getdeviceparams .dicttomark
|
|
|
700 |
% Patch StartPage and EndPage
|
|
|
701 |
% ****** NOTE: StartPage and EndPage are disabled because
|
|
|
702 |
% ****** EndPage clashes with a page device parameter.
|
|
|
703 |
% begin /StartPage PDFStartPage /EndPage PDFEndPage
|
|
|
704 |
% currentdict dup /PDFStartPage undef /PDFEndPage undef
|
|
|
705 |
% def def currentdict end
|
|
|
706 |
} odef
|
|
|
707 |
/setdistillerparams {
|
|
|
708 |
currentdevice .devicename dup /pdfwrite ne exch /ps2write ne and {
|
|
|
709 |
/setdistillerparams /undefined signalerror
|
|
|
710 |
} if
|
|
|
711 |
.setdistillerparams
|
|
|
712 |
} bind odef
|
|
|
713 |
/currentdistillerparams {
|
|
|
714 |
currentdevice .devicename dup /pdfwrite ne exch /ps2write ne and {
|
|
|
715 |
/currentdistillerparams /undefined signalerror
|
|
|
716 |
} if
|
|
|
717 |
.currentdistillerparams
|
|
|
718 |
} bind odef
|
|
|
719 |
|
|
|
720 |
% Patch 'where' so that the distiller operators are only visible
|
|
|
721 |
% if the pdfwrite device is the current one.
|
|
|
722 |
{ currentdevice .devicename dup /pdfwrite eq exch /ps2write eq or{
|
|
|
723 |
.where
|
|
|
724 |
} {
|
|
|
725 |
.where pop dup //systemdict eq { pop false } { true } ifelse
|
|
|
726 |
} ifelse
|
|
|
727 |
} bind
|
|
|
728 |
{ /currentdistillerparams /setdistillerparams /pdfmark }
|
|
|
729 |
{ .wheredict exch 2 index put } forall pop
|
|
|
730 |
|
|
|
731 |
% Patch 'known' to hide the systemdict version of distiller operators
|
|
|
732 |
% unless the currentdevice is pdfwrite.
|
|
|
733 |
/known {
|
|
|
734 |
/currentdistillerparams 1 index eq /setdistillerparams 2 index eq or
|
|
|
735 |
/pdfmark 2 index eq or {
|
|
|
736 |
systemdict 2 index eq { % only mask the operator in systemdict
|
|
|
737 |
known currentdevice .devicename dup /pdfwrite ne exch /ps2write ne and { pop false } if
|
|
|
738 |
} {
|
|
|
739 |
known
|
|
|
740 |
} ifelse
|
|
|
741 |
} {
|
|
|
742 |
known
|
|
|
743 |
} ifelse
|
|
|
744 |
} .bind odef
|
|
|
745 |
|
|
|
746 |
1000 % priority
|
|
|
747 |
{
|
|
|
748 |
% Note, this may not work if the initial device is not pdfwrite
|
|
|
749 |
% and may require the use of -dProvideUnicode on the command line.
|
|
|
750 |
currentdevice .devicename /pdfwrite eq
|
|
|
751 |
systemdict /ProvideUnicode .knownget not { false } if or {
|
|
|
752 |
currentglobal true setglobal
|
|
|
753 |
systemdict /.setupUnicodeDecoder known {
|
|
|
754 |
/Unicode /Decoding resourcestatus {
|
|
|
755 |
pop pop
|
|
|
756 |
/Unicode /Decoding findresource
|
|
|
757 |
.setupUnicodeDecoder
|
|
|
758 |
} {
|
|
|
759 |
QUIET not {
|
|
|
760 |
(WARNING: /Unicode /Decoding resource is not accessible but it is useful for generating ToUnicode CMap.) =
|
|
|
761 |
} if
|
|
|
762 |
} ifelse
|
|
|
763 |
} if
|
|
|
764 |
setglobal
|
|
|
765 |
} if
|
|
|
766 |
} bind .schedule_init
|
|
|
767 |
|
|
|
768 |
1010 % priority
|
|
|
769 |
{
|
|
|
770 |
% Set a predefined configuration in the distiller device (pdfwrite)
|
|
|
771 |
/PDFSETTINGS where {
|
|
|
772 |
pop /PDFSETTINGS load
|
|
|
773 |
} {
|
|
|
774 |
currentdevice .devicename /ps2write eq { /PSL2Printer } { /default } ifelse
|
|
|
775 |
} ifelse
|
|
|
776 |
.distillersettings exch get
|
|
|
777 |
% Don't override parameters defined on the command line.
|
|
|
778 |
dup length .distillercommon length add dict begin
|
|
|
779 |
.distillercommon 2 {
|
|
|
780 |
{
|
|
|
781 |
systemdict 2 index known { pop pop } { def } ifelse
|
|
|
782 |
} forall
|
|
|
783 |
} repeat
|
|
|
784 |
currentdict end .setdistillerparams
|
|
|
785 |
.distillerdevice //null false mark .putdeviceparams
|
|
|
786 |
dup type /booleantype eq not { cleartomark pop } if pop pop
|
|
|
787 |
} bind .schedule_init
|
|
|
788 |
|
|
|
789 |
1011 % priority
|
|
|
790 |
{
|
|
|
791 |
% Set a path to library files (ps2write)
|
|
|
792 |
currentdevice .devicename /ps2write eq {
|
|
|
793 |
mark
|
|
|
794 |
systemdict /OPDFReadProcsetPath .knownget not {
|
|
|
795 |
(gs_mgl_e.ps) (gs_mro_e.ps) (gs_agl.ps) (opdfread.ps) % Reverse order !
|
|
|
796 |
() counttomark 1 sub {
|
|
|
797 |
exch
|
|
|
798 |
.libfile { .filename } { false } ifelse not {
|
|
|
799 |
(Configuration error : library file opdfread.ps not found !) =
|
|
|
800 |
(opdfread.ps) /undefinedfilename signalerror
|
|
|
801 |
} if
|
|
|
802 |
.filenamelistseparator concatstrings concatstrings
|
|
|
803 |
} repeat
|
|
|
804 |
} if
|
|
|
805 |
/OPDFReadProcsetPath exch .dicttomark setpagedevice
|
|
|
806 |
} if
|
|
|
807 |
} bind .schedule_init
|
|
|
808 |
|
|
|
809 |
2000 % priority
|
|
|
810 |
{ % Note, this may not work if the initial device is not pdfwrite
|
|
|
811 |
currentdevice .devicename dup /pdfwrite eq exch /ps2write eq or {
|
|
|
812 |
% Inform the device with initial graphic state. See gdev_pdf_fill_path.
|
|
|
813 |
newpath fill
|
|
|
814 |
} if
|
|
|
815 |
} bind .schedule_init
|