Debian Codegraph @

Resource/Init/gs_pdfwr.ps

raw
1 % Copyright (C) 2001-2026 Artifex Software, Inc.
2 % All Rights Reserved.
3 %
4 % This software is provided AS-IS with no warranty, either express or
5 % implied.
6 %
7 % This software is distributed under license and may not be copied,
8 % modified or distributed except as expressly authorized under the terms
9 % of the license contained in the file LICENSE in this distribution.
10 %
11 % Refer to licensing information at http://www.artifex.com or contact
12 % Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
13 % CA 94129, USA, for further information.
14 %
15
16 % PDF writer additions to systemdict.
17
18 % This file should be included iff the pdfwrite "device" is included
19 % in the executable.
20
21 % ---------------- Predefined configurations ---------------- %
22
23 % These correspond to the 4 predefined settings in Acrobat Distiller 5,
24 % plus a "default" setting that doesn't downsample images.
25
26 mark
27 { /pdfwrite finddevice pop } .internalstopped
28 {cleartomark (%END PDFWR) .skipeof} {cleartomark} ifelse
29
30 languagelevel 2 .setlanguagelevel
31
32 /.a2112 [2 1 1 2] readonly def
33 /.a1111 [1 1 1 1] readonly def
34 /.standardfonts [
35 /Courier /Courier-Bold /Courier-Oblique /Courier-BoldOblique
36 /Helvetica /Helvetica-Bold /Helvetica-Oblique /Helvetica-BoldOblique
37 /Times-Roman /Times-Bold /Times-Italic /Times-BoldItalic
38 /Symbol /ZapfDingbats
39 ] readonly def
40
41 % Parameters common to all non-default configurations.
42 % Note that the default configuration overrides a few of these.
43 /.defaultImageDict mark
44 /QFactor 0.9 /Blend 1
45 /HSamples .a2112 /VSamples .a2112
46 .dicttomark readonly def
47 /.distillercommon mark
48 /AlwaysEmbed []
49 /AntiAliasColorImages //false
50 /AntiAliasGrayImages //false
51 /AntiAliasMonoImages //false
52 /ASCII85EncodePages //false
53 /AutoFilterColorImages //true
54 /AutoFilterGrayImages //true
55 /AutoPositionEPSFiles //true
56 /Binding /Left
57 /CalCMYKProfile (None) % (U.S. Web Coated (SWOP) v2)
58 /CalGrayProfile (None) % (Dot Gain 20%)
59 /CalRGBProfile (None) % (sRGB IEC61966-2.1)
60 /ColorImageDepth -1
61 /ColorImageDict .defaultImageDict
62 /ColorImageDownsampleThreshold 1.5
63 /ColorImageFilter /DCTEncode
64 /CompressPages //true
65 /ConvertImagesToIndexed //true
66 /DefaultRenderingIntent /Default
67 /DetectBlends //true
68 /DownsampleColorImages //true
69 /DownsampleGrayImages //true
70 /DownsampleMonoImages //true
71 /EmitDSCWarnings //false
72 /EncodeColorImages //true
73 /EncodeGrayImages //true
74 /EncodeMonoImages //true
75 /EndPage -1
76 /GrayImageDepth -1
77 /GrayImageDict .defaultImageDict
78 /GrayImageDownsampleThreshold 1.5
79 /GrayImageFilter /DCTEncode
80 /ImageMemory 524288
81 /LockDistillerParams //false
82 /MaxSubsetPct 100
83 /MonoImageDepth -1
84 /MonoImageDict mark
85 /K -1
86 .dicttomark readonly
87 /MonoImageDownsampleThreshold 1.5
88 /MonoImageFilter /CCITTFaxEncode
89 /OffOptimizations 0
90 /OPM 0
91 /Optimize //true
92 /ParseDSCComments //true
93 /ParseDSCCommentsForDocInfo //true
94 /PDFXTrimBoxToMediaBoxOffset [0 0 0 0]
95 /PDFXSetBleedBoxToMediaBox //true
96 /PDFXBleedBoxToTrimBoxOffset [0 0 0 0]
97 /PreserveCopyPage //true
98 /PreserveHalftoneInfo //false
99 /sRGBProfile (None) % (sRGB IEC61966-2.1)
100 /StartPage 1
101 /SubsetFonts //true
102 /TransferFunctionInfo /Preserve
103 /UseFlateCompression //true
104 /UsePrologue //false
105 /PassThroughJPEGImages //true
106 /PassThroughJPXImages //true
107 /PSPageOptionsWrap //true
108 .dicttomark readonly def
109
110 /.distillersettings mark
111
112 /default mark
113 /AutoRotatePages /PageByPage
114 /CannotEmbedFontPolicy /Warning
115 /ColorACSImageDict .defaultImageDict
116 /ColorConversionStrategy /LeaveColorUnchanged
117 % /ColorImageDownsampleType
118 % /ColorImageResolution
119 % /CompatibilityLevel
120 /CreateJobTicket //false
121 /DoThumbnails //false
122 /DownsampleColorImages //false % override
123 /DownsampleGrayImages //false % override
124 /DownsampleMonoImages //false % override
125 /EmbedAllFonts //true
126 /GrayACSImageDict .defaultImageDict
127 % /GrayImageDownsampleType
128 % /GrayImageResolution
129 % /MonoImageDownsampleType
130 % /MonoImageResolution
131 /NeverEmbed .standardfonts
132 /Optimize //false % override
133 /PreserveEPSInfo //true
134 /PreserveOPIComments //true
135 /PreserveOverprintSettings //true
136 /UCRandBGInfo /Preserve
137 .dicttomark readonly
138
139 /.screenACSImageDict mark
140 /QFactor 0.76 /Blend 1 /ColorTransform 1
141 /HSamples .a2112 /VSamples .a2112
142 .dicttomark readonly def
143 /screen mark
144 /AutoRotatePages /PageByPage
145 % /CalGrayProfile (None)
146 /CannotEmbedFontPolicy /Warning
147 /ColorACSImageDict .screenACSImageDict
148 /ColorConversionStrategy /sRGB
149 /ColorImageDownsampleType /Average
150 /ColorImageResolution 72
151 /CompatibilityLevel 1.5
152 /CreateJobTicket //false
153 /DoThumbnails //false
154 /EmbedAllFonts //true
155 /GrayACSImageDict .screenACSImageDict
156 /GrayImageDownsampleType /Average
157 /GrayImageResolution 72
158 /MonoImageDownsampleType /Subsample
159 /MonoImageResolution 300
160 /NeverEmbed .standardfonts
161 /PreserveEPSInfo //false
162 /PreserveOPIComments //false
163 /PreserveOverprintSettings //false
164 /UCRandBGInfo /Remove
165 .dicttomark readonly
166
167 /ebook mark
168 /AutoRotatePages /All
169 % /CalGrayProfile (None)
170 /CannotEmbedFontPolicy /Warning
171 /ColorACSImageDict .screenACSImageDict
172 /ColorConversionStrategy /sRGB
173 /ColorImageDownsampleType /Average
174 /ColorImageResolution 150
175 /CompatibilityLevel 1.5
176 /CreateJobTicket //false
177 /DoThumbnails //false
178 /EmbedAllFonts //true
179 /GrayACSImageDict .screenACSImageDict
180 /GrayImageDownsampleType /Average
181 /GrayImageResolution 150
182 /MonoImageDownsampleType /Subsample
183 /MonoImageResolution 300
184 /NeverEmbed .standardfonts
185 /PreserveEPSInfo //false
186 /PreserveOPIComments //false
187 /PreserveOverprintSettings //false
188 /UCRandBGInfo /Remove
189 .dicttomark readonly
190
191 /.printerACSImageDict mark
192 /QFactor 0.4 /Blend 1 /ColorTransform 1
193 /HSamples .a1111 /VSamples .a1111
194 .dicttomark readonly def
195 /printer mark
196 /AutoRotatePages /None
197 % /CalGrayProfile (None)
198 /CannotEmbedFontPolicy /Warning
199 /ColorACSImageDict .printerACSImageDict
200 /ColorConversionStrategy /UseDeviceIndependentColor
201 /ColorImageDownsampleType /Average
202 /ColorImageResolution 300
203 /CompatibilityLevel 1.7
204 /CreateJobTicket //true
205 /DoThumbnails //false
206 /EmbedAllFonts //true
207 /GrayACSImageDict .printerACSImageDict
208 /GrayImageDownsampleType /Average
209 /GrayImageResolution 300
210 /MonoImageDownsampleType /Subsample
211 /MonoImageResolution 1200
212 /NeverEmbed []
213 /PreserveEPSInfo //true
214 /PreserveOPIComments //true
215 /PreserveOverprintSettings //true
216 /UCRandBGInfo /Preserve
217 .dicttomark readonly
218
219 /.prepressACSImageDict mark
220 /QFactor 0.15 /Blend 1 /ColorTransform 1
221 /HSamples .a1111 /VSamples .a1111
222 .dicttomark readonly def
223 /prepress mark
224 /AutoRotatePages /None
225 /CannotEmbedFontPolicy /Error
226 /ColorACSImageDict .prepressACSImageDict
227 /ColorConversionStrategy /LeaveColorUnchanged
228 /ColorImageDownsampleType /Bicubic
229 /ColorImageResolution 300
230 /CompatibilityLevel 1.7
231 /CreateJobTicket //true
232 /DoThumbnails //true
233 /EmbedAllFonts //true
234 /GrayACSImageDict .prepressACSImageDict
235 /GrayImageDownsampleType /Bicubic
236 /GrayImageResolution 300
237 /MonoImageDownsampleType /Subsample
238 /MonoImageResolution 1200
239 /NeverEmbed []
240 /PreserveEPSInfo //true
241 /PreserveOPIComments //true
242 /PreserveOverprintSettings //true
243 /UCRandBGInfo /Preserve
244 .dicttomark readonly
245
246 % Define distiller settings for the ps2write device and for the ps2ps2 script :
247 /PSL2Printer mark
248 /AutoRotatePages /None
249 /CannotEmbedFontPolicy /Error
250 /ColorACSImageDict .prepressACSImageDict
251 /ColorConversionStrategy /LeaveColorUnchanged
252 /ColorImageDownsampleType /Subsample
253 /ColorImageResolution 600
254 /DownsampleColorImages //false
255 /CompatibilityLevel 1.2 % Always 1.2 with ps2write.
256 % /CreateJobTicket //true % Not sure
257 /DoThumbnails //false
258 /EmbedAllFonts //true
259 /GrayACSImageDict .prepressACSImageDict
260 /GrayImageDownsampleType /Subsample
261 /GrayImageResolution 600
262 /DownsampleGrayImages //false
263 /MonoImageDownsampleType /Subsample
264 /MonoImageResolution 1200
265 /DownsampleMonoImages //false
266 /NeverEmbed []
267 /PreserveEPSInfo //true
268 /PreserveOPIComments //true
269 /PreserveOverprintSettings //true
270 /UCRandBGInfo /Preserve
271 /PreserveHalftoneInfo //true
272 /TransferFunctionInfo /Preserve
273 %% Deprecated in 9.06
274 %% /MaxViewerMemorySize 8000000
275 /CompressPages //false
276 /CompressFonts //true
277 /ASCII85EncodePages //true
278 .dicttomark readonly
279
280 .dicttomark readonly def
281
282 % ---------------- End of predefined configurations ---------------- %
283
284 % ---------------- pdfmark and DSC processing ---------------- %
285
286 /.write_small_positive_real % <file> <real> .write_small_positive_real -
287 { % The argument must be grater than 0 and must be strongly samller than 0.1.
288 % The conversion isn't simple due to the low (24 bits) precision
289 % of the floating point arithmetics in Postscript.
290 % For best result we first use the 1e8 factor since its binary
291 % representation 101111101011110000100000000 well rounds into 14 significant
292 % bits : 101111101011110000000000000 .
293 1 index (.) writestring
294 { dup 100000000 mul
295 dup 10 mul 1 ge {
296 % Will need not greater than 0.1 due to a rounding below.
297 pop exit
298 } if
299 exch pop
300 1 index (00000000) writestring
301 } loop
302 % Now it is not smaller than 1e-9, use simple digitizing.
303 { dup 10 mul
304 dup 10 mul 1 ge {
305 pop exit
306 } if
307 exch pop
308 1 index (0) writestring
309 } loop
310 % Now 0.01 <= n < 0.1, but rounding may give 0.1 .
311 % Convert to integer with 7 digits precision :
312 100000000 % precision factor 1e8 % f n r
313 dup 10 idiv 3 1 roll mul 0.5 add cvi % f r' N
314 2 copy le {
315 % The rounding overflows, suppress it.
316 % Note it carries out an additional digit,
317 % that's why we needed <0.1 above.
318 pop pop (1) writestring
319 } {
320 % Didn't cary out, put 0.
321 2 index (0) writestring
322 exch % f N r
323 % Continue the simple digitizing :
324 { 10 idiv dup % f N r' r'
325 2 index exch idiv % f N r' d
326 (0123456789) exch 1 getinterval % f N r' (d)
327 3 index exch writestring % f N r'
328 dup 3 2 roll exch mod % f r' N'
329 dup 0 eq {
330 % Don't write trailing zeros.
331 exit
332 } if
333 exch % f N' r'
334 } loop
335 pop pop pop
336 } ifelse
337 } .internalbind def
338
339 % Encode values to pass for the /pdfmark or /DSC pseudo-parameter.
340 /.pdf===dict mark
341 /arraytype
342 { dup xcheck { ({) (}) } { ([) (]) } ifelse
343 % Stack: file obj left right
344 4 1 roll 2 index exch writestring () exch
345 { exch 2 index exch writestring
346 1 index exch pdf===only ( )
347 }
348 forall pop exch writestring
349 } .internalbind
350 /packedarraytype 1 index
351 /dicttype
352 { 1 index (<<\n) writestring
353 { 2 index 3 -1 roll pdf===only 1 index ( ) writestring
354 1 index exch pdf===only dup (\n) writestring
355 }
356 forall (>>) writestring
357 } .internalbind
358 /nametype {
359 % If the name string includes any non-regular characters,
360 % write it with two preceding and one following null character(s).
361 % (Null characters in the name itself are not allowed.)
362 % This non-standard escape convention is required for passing names
363 % that include non-regular characters, because PostScript provides
364 % no way to do this. The pdf_scan_token procedure in the C code of
365 % the pdfwrite driver is currently the only place that recognizes
366 % this convention.
367 % Note that \004 may be self-delimiting in gs, but is not in standard PS.
368 dup .namestring (\000\004\011\012\014\015 %()/<>[]{}) .stringbreak //null ne {
369 dup .namestring (\000) .stringbreak //null ne {
370 1 index <000000> writestring 1 index exch write===only 1 index exch 0 write 0 write
371 }{
372 1 index <0000> writestring 1 index exch write===only 0 write
373 }ifelse
374 } {
375 write===only
376 } ifelse
377 } .internalbind
378 /realtype {
379 % Prevent using floating point format - see Bug 688167.
380 dup dup 0 lt { neg } if 0.01 lt {
381 dup 0 eq {
382 pop (0) writestring
383 } {
384 dup 0 lt {
385 1 index (-) writestring neg
386 } if
387 .write_small_positive_real
388 } ifelse
389 } {
390 write===only
391 } ifelse
392 } .internalbind
393 .dicttomark readonly def
394 /pdf===only { % <file> <obj> pdf===only -
395 .pdf===dict 1 index type .knownget { exec } { write===only } ifelse
396 } .internalbind def
397 /.pdfcvbuf 30 string def % enough for most arguments
398 userdict /.pdfcvstring () put
399 /.pdfcvs { % <obj> .pdfcvs <string>
400 currentglobal exch //false .setglobal
401 /.pdfcvstring () store
402 % We can't handle long values yet.
403 { pop dup length 0 eq { pop } {
404 /.pdfcvstring .pdfcvstring 3 -1 roll concatstrings store
405 } ifelse //.pdfcvbuf
406 } /NullEncode filter dup 3 -1 roll pdf===only
407 closefile
408 .setglobal .pdfcvstring
409 } .internalbind def
410
411 % Redefine pdfmark to pass the data to the driver.
412 % We use a pseudo-parameter named /pdfmark whose value is an array:
413 % /key1 (value1) ... (CTM) /type
414 /.pdfputparams { % -mark- <key1> <value1> ... .pdfputparams <result...>
415 currentdevice //null //false counttomark 1 add 3 roll
416 % Don't allow the page device to get cleared....
417 {.putdeviceparams} .currentpagedevice pop {.setpagedevice} 3 .execn
418 } .internalbind def
419 % Convert relevant operands to strings in an array.
420 /.pdfcvsloop { % -mark- values ... markname start step .pdfcvsloop
421 % [values ... ctm markname]
422 matrix currentmatrix .pdfcvs 4 1 roll
423 counttomark 1 add 2 roll
424 counttomark .localvmarray astore exch pop
425 3 1 roll
426 % Stack: values start step
427 2 index length 3 sub { 2 copy 2 copy get .pdfcvs put pop } for
428 } .internalbind def
429 /.pdfcvsall { % -mark- values ... markname .pdfcvsall <<same>>
430 0 1 .pdfcvsloop
431 } .internalbind def
432 /.pdfcvseven { % -mark- key value ... markname .pdfcvseven <<same>>
433 1 2 .pdfcvsloop
434 } .internalbind def
435 /.pdfcvsnone { % -mark- values ... markname .pdfcvsnone <<same>>
436 100000 1 .pdfcvsloop
437 } .internalbind def
438 /.pdfcvsfirst { % -mark- first values ... markname .pdfcvsfirst<<same>>
439 .pdfcvsnone
440 dup 0 2 copy get .pdfcvs put
441 } .internalbind def
442 % The procedures in the following dictionary are called with the entire
443 % pdfmark operand list (including the pdfmark name) on the stack;
444 % they may modify this ad lib. They must call .pdfcvsxxx.
445 /.pdfmarkparams mark
446 % Unpack a dictionary for PUT, and don't convert stream data.
447 /PUT {
448 counttomark 3 eq {
449 1 index type /dicttype eq {
450 pop { } forall /.PUTDICT .pdfcvsall
451 } {
452 pop dup type /filetype eq {
453 % Read the file into a sequence of strings.
454 % This isn't great, but it's simple.
455 {
456 dup 64000 string readstring not { exch exit } if
457 exch
458 } loop closefile
459 } if
460 /.PUTSTREAM .pdfcvsfirst
461 } ifelse
462 } {
463 .pdfcvsall
464 } ifelse
465 } .internalbind
466 % Unpack the array for PUTINTERVAL.
467 /PUTINTERVAL {
468 pop aload pop /.PUTINTERVAL .pdfcvsall
469 } .internalbind
470 .dicttomark readonly def
471 /.pdfparamerror { % ? ? ? -mark- ... <errname> <opname> .pdfparamerror -
472 counttomark 4 add 2 roll cleartomark pop pop pop
473 .systemvar exch signalerror
474 } .internalbind def
475
476
477 /pdfmark { % -mark- <key> <value> ... <markname> pdfmark -
478 counttomark 0 eq {
479 /pdfmark cvx /stackunderflow signalerror
480 } if
481 dup type /nametype eq not {
482 /pdfmark cvx /typecheck signalerror
483 } if
484 dup /SP eq {
485 % A hack for synchronizing the clipping path.
486 gsave
487 [1 0 0 1 0 0] setmatrix 0 setlinewidth
488 newpath -3 -3 moveto closepath stroke % Paints outside the device bbox.
489 grestore
490 } if
491 dup /PS eq systemdict /PDFX .knownget not { //false }{0 eq {//false}{//true} ifelse} ifelse
492 systemdict /PDFA .knownget not { //false }{0 eq {//false}{//true} ifelse} ifelse or and {
493 % Execute it since PDF/X doesn't allow to embed it.
494 pop
495 { dup mark eq {
496 pop exit
497 } if
498 1 index /DataSource eq {
499 exch pop
500 cvx exec
501 } {
502 pop pop
503 } ifelse
504 } loop
505 } {
506 counttomark 1 add copy
507 //.pdfmarkparams 1 index .knownget { exec } { .pdfcvsall } ifelse
508 mark /pdfmark 3 -1 roll .pdfputparams
509 dup type /booleantype ne {
510 /pdfmark .pdfparamerror
511 } if cleartomark
512 } ifelse
513 } odef
514 userdict /pdfmark .undef
515 currentdict /.pdfmarkparams .undef
516
517 % <dict> .hook_DSC_Creator -
518 /.pdf_hook_DSC_Creator
519 {
520 % If the Creator is PScript5.dll, disable the 32 /FontType resource for
521 % handling GlyphNames2Unicode. Since /FontType category can't redefine,
522 % we can do only with redefining the operator 'resourcestatus'.
523 systemdict /.pdf_hooked_DSC_Creator .knownget
524 {
525 {//false}{//true} ifelse
526 }
527 {
528 //true
529 } ifelse
530
531 {
532 /WantsToUnicode /GetDeviceParam .special_op {
533 exch pop
534 }{
535 //true
536 }ifelse
537 {
538 /Creator .knownget {
539 (PScript5.dll) search {
540 pop pop
541 systemdict /resourcestatus dup
542 { dup /FontType eq 2 index 32 eq and {
543 pop pop //false
544 } {
545 resourcestatus
546 } ifelse
547 } .internalbind .makeoperator .forceput
548 systemdict /.pdf_hooked_DSC_Creator //true .forceput
549 } executeonly if
550 pop
551 } executeonly if
552 } {
553 pop
554 } ifelse
555 } executeonly
556 {
557 pop
558 } ifelse
559 } .forcebind odef % must be bound and hidden for .forceput
560
561 % Use the DSC processing hook to pass DSC comments to the driver.
562 % We use a pseudo-parameter named DSC whose value is an array:
563 % /key1 (value1) ... /type
564 /.pdfdsc_dict 2 dict def
565 /.pdfdsc { % <file> <DSC string> <dsc dict> [<prev proc>] .pdfdsc -
566 0 get dup //null ne { 4 copy exch pop exec pop } { pop } ifelse 3 -1 roll pop
567 % Stack: <dsc string> <dsc dict>
568 20 .localvmdict 1 index { 3 copy put pop pop } forall
569 3 -1 roll .parse_dsc_comments % <dsc dict> <dict> <type>
570 1 index //.pdf_hook_DSC_Creator exec
571 dup /NOP ne 2 index length 1 gt or { % Skip unparsed comments
572 PDFWRDEBUG { (**** DSC comment: ) print dup //== exec 1 index === flush } if
573 exch mark 4 1 roll {
574 % mark <key1> <value1> ... <dsc dict> <type> <key> <value>
575 3 index 2 index known { % Skip the DSC_struct entry
576 pop pop
577 } {
578 .pdfcvs 4 -2 roll
579 } ifelse
580 } forall exch pop counttomark .localvmarray astore
581 mark /DSC 3 -1 roll .pdfputparams
582 dup type /booleantype ne {
583 /DSC .pdfparamerror
584 } {
585 cleartomark
586 } ifelse
587 } {
588 pop pop pop
589 } ifelse
590 } .internalbind def
591 currentdict /.pdf_hook_DSC_Creator undef
592 /.initialize_dsc_parser where {
593 pop
594 3000 % priority
595 {
596 % When running gpdl, due to the way gpdl has to do job encapsulation
597 % the scheduled initialisation procedures get run at the start of each
598 % job. Because this patches the existing procedure, it could end up
599 % patching itself, so the procedure got larger/deeper with each job.
600 % Eventually, copying the user params (see /.setuserparams2 in gs_lev2.ps)
601 % would end up overflowing the exec stack.
602 % So, as part of the patching, we push and pop a sacrificial name object
603 % at the start of the executable array and before patching, we check that
604 % first element, and if it is that name, we skip the patching
605 currentuserparams /ProcessDSCComment .knownget
606 {
607 dup type /arraytype eq
608 {
609 0 get /.pdf_hook_DSC_Creator eq
610 { //false } { //true } ifelse
611 } { //true } ifelse
612 } { //true } ifelse
613
614 {
615 currentglobal //true setglobal
616 2 dict dup .initialize_dsc_parser readonly
617 currentuserparams /ProcessDSCComment get
618 1 array astore % in case the value is executable
619 /.pdf_hook_DSC_Creator /pop load 4 2 roll //.pdfdsc /exec load 6 array astore cvx readonly
620 << /ProcessDSCComment 3 -1 roll >> setuserparams
621 setglobal
622 } if
623 } .internalbind .schedule_init
624 } if
625
626 % ---------------- {set,current}distillerparams ---------------- %
627
628 % Define setdistillerparams / currentdistillerparams.
629 % Distiller parameters are currently treated as device parameters.
630 /.distillerparamkeys mark
631 % General parameters -- all distillers
632 /ASCII85EncodePages { }
633 /AutoRotatePages { }
634 /Binding { }
635 /CompressPages { }
636 /DefaultRenderingIntent { }
637 /DetectBlends { }
638 /DoThumbnails { }
639 /ImageMemory { }
640 /LockDistillerParams { }
641 /LZWEncodePages { }
642 /OPM { }
643 /PreserveHalftoneInfo { }
644 /PreserveOPIComments { }
645 /PreserveOverprintSettings { }
646 /TransferFunctionInfo { }
647 /UCRandBGInfo { }
648 /UseFlateCompression { }
649 % General parameters -- PDF writer
650 % StartPage and EndPage are renamed because EndPage
651 % clashes with a page device parameter.
652 /CoreDistVersion { }
653 /CompatibilityLevel { }
654 % ****** NOTE: StartPage and EndPage are disabled because
655 % ****** EndPage clashes with a page device parameter.
656 % /EndPage { exch pop /PDFEndPage exch }
657 /PDFEndPage { pop pop }
658 % /StartPage { exch pop /PDFStartPage exch }
659 /PDFStartPage { pop pop }
660 /Optimize { }
661 /ParseDSCCommentsForDocInfo { }
662 /ParseDSCComments { }
663 /EmitDSCWarnings { }
664 /CreateJobTicket { }
665 /PreserveEPSInfo { }
666 /AutoPositionEPSFiles { }
667 /PreserveCopyPage { }
668 /UsePrologue { }
669 /OffOptimizations { }
670 % PDF/X parameters
671 /PDFXTrimBoxToMediaBoxOffset { }
672 /PDFXSetBleedBoxToMediaBox { }
673 /PDFXBleedBoxToTrimBoxOffset { }
674 % Color sampled image parameters
675 /ColorACSImageDict { }
676 /AntiAliasColorImages { }
677 /AutoFilterColorImages { }
678 /ColorImageDepth { }
679 /ColorImageDict { }
680 /DownsampleColorImages { }
681 /ColorImageDownsampleThreshold { }
682 /ColorImageDownsampleType { }
683 /ColorImageAutoFilterStrategy { }
684 /EncodeColorImages { }
685 /ColorImageFilter { }
686 /ColorImageResolution { }
687 % Color processing parameters
688 /CalCMYKProfile { }
689 /CalGrayProfile { }
690 /CalRGBProfile { }
691 /sRGBProfile { }
692 /ColorConversionStrategy { }
693 /ConvertCMYKImagesToRGB { }
694 /ConvertImagesToIndexed { }
695 % Grayscale sampled image parameters
696 /GrayACSImageDict { }
697 /AntiAliasGrayImages { }
698 /AutoFilterGrayImages { }
699 /GrayImageDepth { }
700 /GrayImageDict { }
701 /DownsampleGrayImages { }
702 /GrayImageDownsampleThreshold { }
703 /GrayImageDownsampleType { }
704 /GrayImageAutoFilterStrategy { }
705 /EncodeGrayImages { }
706 /GrayImageFilter { }
707 /GrayImageResolution { }
708 % Monochrome sampled image parameters
709 /AntiAliasMonoImages { }
710 /MonoImageDepth { }
711 /MonoImageDict { }
712 /DownsampleMonoImages { }
713 /MonoImageDownsampleThreshold { }
714 /MonoImageDownsampleType { }
715 /EncodeMonoImages { }
716 /MonoImageFilter { }
717 /MonoImageResolution { }
718 % Font embedding parameters
719 /AlwaysEmbed
720 { dup length 0 gt
721 { dup 0 get type /booleantype eq } { //false } ifelse
722 { dup 0 get
723 { dup length 1 sub 1 exch getinterval
724 }
725 { dup length 1 sub 1 exch getinterval exch pop /~AlwaysEmbed exch
726 } ifelse
727 }
728 { exch pop /.AlwaysEmbed exch
729 } ifelse
730 }
731 /NeverEmbed
732 { dup length 0 gt
733 { dup 0 get type /booleantype eq } { //false } ifelse
734 { dup 0 get
735 { dup length 1 sub 1 exch getinterval
736 }
737 { dup length 1 sub 1 exch getinterval exch pop /~NeverEmbed exch
738 } ifelse
739 }
740 { exch pop /.NeverEmbed exch
741 } ifelse
742 }
743 /CannotEmbedFontPolicy { }
744 /EmbedAllFonts { }
745 /MaxSubsetPct { }
746 /SubsetFonts { }
747 /DSCEncodingToUnicode { }
748 /PassThroughJPEGImages { }
749 /PassThroughJPXImages { }
750 /PSDocOptions { }
751 /PSPageOptions { }
752 /PSPageOptionsWrap { }
753 /AlwaysOutline { }
754 /NeverOutline { }
755 .dicttomark readonly def
756 /.distillerdevice
757 {
758 % Check to see if the current device is a Distiller
759 % and return it if so.
760 /IsDistiller /GetDeviceParam .special_op {
761 exch pop
762 }{
763 //false
764 }ifelse
765 { currentdevice }
766 { /pdfwrite finddevice }
767 ifelse
768 } .internalbind def
769
770 % Some badly designed PostScript files only expect the current/set
771 % distillerparams operators to exist in a distiller. Since we have
772 % this as a runtime option, we enable these operators IFF the
773 % currentdevice is pdfwrite. Also, we mask their existence in
774 % systemdict so that 'where' and 'known' don't show them unless
775 % the currentdevice is pdfwrite.
776 /.setdistillerparams { % <dict> setdistillerparams -
777 .distillerdevice //null //false mark 4 index {
778 //.distillerparamkeys 2 index .knownget { exec } { pop pop } ifelse
779 } forall .putdeviceparamsonly
780 dup type /booleantype ne {
781 /setdistillerparams .pdfparamerror
782 } {
783 pop pop pop
784 } ifelse
785 } odef
786 /.currentdistillerparams { % - currentdistillerparams <dict>
787 .distillerdevice //.distillerparamkeys .getdeviceparams .dicttomark
788 % Patch StartPage and EndPage
789 % ****** NOTE: StartPage and EndPage are disabled because
790 % ****** EndPage clashes with a page device parameter.
791 % begin /StartPage PDFStartPage /EndPage PDFEndPage
792 % currentdict dup /PDFStartPage undef /PDFEndPage undef
793 % def def currentdict end
794 } odef
795 /setdistillerparams {
796 % Check to see if the current device is a Distiller
797 /IsDistiller /GetDeviceParam .special_op {
798 exch pop not
799 }{
800 //true
801 }ifelse
802 {
803 /setdistillerparams cvx /undefined signalerror
804 } if
805 .setdistillerparams
806 } .internalbind odef
807 /currentdistillerparams {
808 % Check to see if the current device is a Distiller
809 /IsDistiller /GetDeviceParam .special_op {
810 exch pop not
811 }{
812 //true
813 }ifelse
814 {
815 /currentdistillerparams cvx /undefined signalerror
816 } if
817 .currentdistillerparams
818
819 % Ugly hackery to work around Adobe Duotone definitions and their incorrect tint transform
820 %
821 % Bug #708734 for a DeviceGray example
822 % The colorspace is defined as :
823 %
824 % /PhotoshopDuotoneColorSpace [/DeviceN [(Black)][/DeviceGray] {} bind
825 %
826 % Notice that /Black is 'upside down' wrt DeviceGray 0 Black == 1 Gray and vice versa
827 % So if we use the tint transform we'll get the wrong answer (inverted black/white)
828 % Acrobat (and presumably Photoshop) have a different definition of the space when the
829 % device doesn't support /Black (eg displays) which works correctly.
830 %
831 % Currently the PostScript code to determine which space to use calls currentdistillerparams
832 % and check ColorConversionStrategy to see if its /sRGB, if it is, then it uses the
833 % alternative space.
834 %
835 % This doesn't give us a 'correct' result, that would require a DeviceN definition with a
836 % modified (correct) tint transform, which we can't readily do because there is no bound
837 % function we can replace. This is as good as it gets.
838
839 userdict/Adobe_AGM_Core known {
840 userdict /Adobe_AGM_Core get
841 /PhotoshopDuotoneList known
842 {
843 %% We're calling currentdistillerparams in the middle of defining a PhotoshOP Duotone
844 %% this happens when Distiller produced PostScript wants to know if it should use the
845 %% (broken) Duotone definition, or use the alternate. We need it to use the alternate
846 %% because the Duotone has an incorrect tint transform.
847 %% We can do this by lying about the ColorConversionStrategy
848 dup /ColorConversionStrategy /sRGB put
849 } if
850 } if
851 } .internalbind odef
852
853 % Patch 'where' so that the distiller operators are only visible
854 % if the pdfwrite device is the current one.
855 {
856 % Check to see if the current device is a Distiller
857 /IsDistiller /GetDeviceParam .special_op {
858 exch pop
859 }{
860 //false
861 }ifelse
862 {
863 .where
864 } {
865 .where pop dup //systemdict eq { pop //false } { //true } ifelse
866 } ifelse
867 } .internalbind
868 { /currentdistillerparams /setdistillerparams /pdfmark }
869 { .wheredict exch 2 index put } forall pop
870
871 % Patch 'known' to hide the systemdict version of distiller operators
872 % unless the currentdevice is pdfwrite.
873 /known {
874 /currentdistillerparams 1 index eq /setdistillerparams 2 index eq or
875 /pdfmark 2 index eq or {
876 systemdict 2 index eq { % only mask the operator in systemdict
877 known
878 % Check to see if the current device is a Distiller
879 /IsDistiller /GetDeviceParam .special_op {
880 exch pop not
881 }{
882 //true
883 }ifelse
884 { pop //false } if
885 } {
886 known
887 } ifelse
888 } {
889 known
890 } ifelse
891 } .forcebind odef
892
893 % Create a table for translation DSC comments into Unicode UTF-16
894 /.make_DSC_translation_table { % <encoding> .make_DSC_translation_table <array>
895 dup type /stringtype eq {
896 cvn
897 } if
898 dup type /nametype eq {
899 /Encoding findresource
900 } if
901 dup length array exch % [out] [in]
902 0 1 2 index length 1 sub { % [out] [in] i
903 dup 2 index exch get % [out] [in] i n
904 dup dup //null eq exch /.notdef eq or {
905 pop -1
906 } {
907 dup //AdobeGlyphList exch .knownget { % [out] [in] i n c
908 dup type dup /arraytype eq exch /packedarraytype eq or {
909 0 get % fixme: using the 1st char
910 } if
911 exch pop % [out] [in] i c
912 } { % [out] [in] i n
913 (DSCEncoding defines a character that is not in AdobeGlyphList : )
914 exch .namestring concatstrings =
915 /.make_DSC_translation_table cvx /undefined signalerror
916 } ifelse
917 } ifelse
918 3 index % [out] [in] i c [out]
919 3 1 roll put % [out] [in]
920 } for
921 pop % [out]
922 } .internalbind def
923
924 1000 % priority
925 {
926 % Note, this may not work if the initial device is not pdfwrite
927 % and may require the use of -dProvideUnicode on the command line.
928 % Check to see if the current device wants ToUnicode info
929 /WantsToUnicode /GetDeviceParam .special_op {
930 exch pop
931 }{
932 //false
933 }ifelse
934 systemdict /ProvideUnicode .knownget not { //false } if or
935 {
936 currentglobal //true setglobal
937 /Unicode /Decoding resourcestatus {
938 pop pop
939 /Unicode /Decoding findresource
940 .setupUnicodeDecoder
941 } {
942 QUIET not {
943 (WARNING: /Unicode /Decoding resource is not accessible but it is useful for generating ToUnicode CMap.) =
944 } if
945 } ifelse
946 setglobal
947 } if
948 } .internalbind .schedule_init
949
950 1010 % priority
951 {
952 % Set a predefined configuration in the distiller device (pdfwrite)
953 /PDFSETTINGS where {
954 pop /PDFSETTINGS load
955 } {
956 % We use the presence of the OPDFRead key as a proxy for a pdfwrite-family device
957 /ForOPDFRead /GetDeviceParam .special_op {
958 % Get rid of the OPDFRead key
959 exch pop
960 % and then check the value to see if its pdfwrite or ps2write
961 { /PSL2Printer } { /default } ifelse
962 } {
963 /default
964 } ifelse
965 } ifelse
966 .distillersettings exch get
967 % Don't override parameters defined on the command line.
968 dup length .distillercommon length add dict begin
969 .distillercommon 2 {
970 {
971 systemdict 2 index known { pop pop } { def } ifelse
972 } forall
973 } repeat
974 % We use the presence of the OPDFRead key as a proxy for a pdfwrite-family device
975 /ForOPDFRead /GetDeviceParam .special_op {
976 % Get rid of the OPDFRead key
977 exch pop
978 % Then check to see if OPDFRead is true or not
979 not {
980 systemdict /PDFX known systemdict /PDFA known or {
981 /DSCEncoding where {
982 /DSCEncoding get .make_DSC_translation_table
983 /DSCEncodingToUnicode exch def
984 } if
985 } if
986 } if
987 } if
988 currentdict end .setdistillerparams
989 .distillerdevice //null //false mark .putdeviceparams
990 dup type /booleantype eq not { cleartomark pop } if pop pop
991 } .internalbind .schedule_init
992
993 2000 % priority
994 { % Note, this may not work if the initial device is not pdfwrite
995 % We use the presence of the OPDFRead key as a proxy for a pdfwrite-family device
996 /ForOPDFRead /GetDeviceParam .special_op {
997 % Get rid of the OPDFRead key and value
998 pop pop
999 % Inform the device with initial graphic state. See gdev_pdf_fill_path.
1000 newpath fill
1001 } if
1002 } .internalbind .schedule_init
1003
1004 .setlanguagelevel
1005
1006 %END PDFWR