% Copyright (C) 1996, 2000 Aladdin Enterprises. All rights reserved.% % This software is provided AS-IS with no warranty, either express or% implied.% % This software is distributed under license and may not be copied,% modified or distributed except as expressly authorized under the terms% of the license contained in the file LICENSE in this distribution.% % For more information about licensing, please refer to% http://www.ghostscript.com/licensing/. For information on% commercial licensing, go to http://www.artifex.com/licensing/ or% contact Artifex Software, Inc., 101 Lucas Valley Road #110,% San Rafael, CA 94903, U.S.A., +1(415)492-9861. % $Id: gs_pdfwr.ps,v 1.52 2005/10/20 13:04:16 leonardo Exp $% PDF writer additions to systemdict. % This file should be included iff the pdfwrite "device" is included% in the executable. % ---------------- Predefined configurations ---------------- % % These correspond to the 4 predefined settings in Acrobat Distiller 5,% plus a "default" setting that doesn't downsample images. /.a2112 [2 1 1 2] readonly def/.a1111 [1 1 1 1] readonly def/.standardfonts [ /Courier /Courier-Bold /Courier-Oblique /Courier-BoldOblique /Helvetica /Helvetica-Bold /Helvetica-Oblique /Helvetica-BoldOblique /Times-Roman /Times-Bold /Times-Italic /Times-BoldItalic /Symbol /ZapfDingbats] readonly def % Parameters common to all non-default configurations.% Note that the default configuration overrides a few of these./.defaultImageDict mark /QFactor 0.9 /Blend 1 /HSamples .a2112 /VSamples .a2112.dicttomark readonly def/.distillercommon mark /AlwaysEmbed [] /AntiAliasColorImages false /AntiAliasGrayImages false /AntiAliasMonoImages false /ASCII85EncodePages false /AutoFilterColorImages true /AutoFilterGrayImages true /AutoPositionEPSFiles true /Binding /Left /CalCMYKProfile (None) % (U.S. Web Coated (SWOP) v2) /CalGrayProfile (None) % (Dot Gain 20%) /CalRGBProfile (None) % (sRGB IEC61966-2.1) /ColorImageDepth -1 /ColorImageDict .defaultImageDict /ColorImageDownsampleThreshold 1.5 /ColorImageFilter /DCTEncode /CompressPages true /ConvertImagesToIndexed true /DefaultRenderingIntent /Default /DetectBlends true /DownsampleColorImages true /DownsampleGrayImages true /DownsampleMonoImages true /EmitDSCWarnings false /EncodeColorImages true /EncodeGrayImages true /EncodeMonoImages true /EndPage -1 /GrayImageDepth -1 /GrayImageDict .defaultImageDict /GrayImageDownsampleThreshold 1.5 /GrayImageFilter /DCTEncode /ImageMemory 524288 /LockDistillerParams false /MaxSubsetPct 100 /MonoImageDepth -1 /MonoImageDict mark /K -1 .dicttomark readonly /MonoImageDownsampleThreshold 1.5 /MonoImageFilter /CCITTFaxEncode /OffOptimizations 0 /OPM 1 /Optimize true /ParseDSCComments true /ParseDSCCommentsForDocInfo true /PreserveCopyPage true /PreserveHalftoneInfo false /sRGBProfile (None) % (sRGB IEC61966-2.1) /StartPage 1 /SubsetFonts true /TransferFunctionInfo /Preserve /UseFlateCompression true /UsePrologue false.dicttomark readonly def /.distillersettings mark /default mark /AutoRotatePages /PageByPage /CannotEmbedFontPolicy /Warning /ColorACSImageDict .defaultImageDict /ColorConversionStrategy /LeaveColorUnchanged% /ColorImageDownsampleType% /ColorImageResolution% /CompatibilityLevel /CreateJobTicket false /DoThumbnails false /DownsampleColorImages false % override /DownsampleGrayImages false % override /DownsampleMonoImages false % override /EmbedAllFonts true /GrayACSImageDict .defaultImageDict% /GrayImageDownsampleType% /GrayImageResolution% /MonoImageDownsampleType% /MonoImageResolution /NeverEmbed .standardfonts /Optimize false % override /PreserveEPSInfo true /PreserveOPIComments true /PreserveOverprintSettings true /UCRandBGInfo /Preserve.dicttomark readonly /.screenACSImageDict mark /QFactor 0.76 /Blend 1 /ColorTransform 1 /HSamples .a2112 /VSamples .a2112.dicttomark readonly def/screen mark /AutoRotatePages /PageByPage% /CalGrayProfile (None) /CannotEmbedFontPolicy /Warning /ColorACSImageDict .screenACSImageDict /ColorConversionStrategy /sRGB /ColorImageDownsampleType /Average /ColorImageResolution 72 /CompatibilityLevel 1.3 /CreateJobTicket false /DoThumbnails false /EmbedAllFonts true /GrayACSImageDict .screenACSImageDict /GrayImageDownsampleType /Average /GrayImageResolution 72 /MonoImageDownsampleType /Average /MonoImageResolution 300 /NeverEmbed .standardfonts /PreserveEPSInfo false /PreserveOPIComments false /PreserveOverprintSettings false /UCRandBGInfo /Remove.dicttomark readonly /ebook mark /AutoRotatePages /All% /CalGrayProfile (None) /CannotEmbedFontPolicy /Warning /ColorACSImageDict .screenACSImageDict /ColorConversionStrategy /sRGB /ColorImageDownsampleType /Bicubic /ColorImageResolution 150 /CompatibilityLevel 1.4 /CreateJobTicket false /DoThumbnails false /EmbedAllFonts true /GrayACSImageDict .screenACSImageDict /GrayImageDownsampleType /Bicubic /GrayImageResolution 150 /MonoImageDownsampleType /Bicubic /MonoImageResolution 300 /NeverEmbed .standardfonts /PreserveEPSInfo false /PreserveOPIComments false /PreserveOverprintSettings false /UCRandBGInfo /Remove.dicttomark readonly /.printerACSImageDict mark /QFactor 0.4 /Blend 1 /ColorTransform 1 /HSamples .a1111 /VSamples .a1111.dicttomark readonly def/printer mark /AutoRotatePages /None% /CalGrayProfile (None) /CannotEmbedFontPolicy /Warning /ColorACSImageDict .printerACSImageDict /ColorConversionStrategy /UseDeviceIndependentColor /ColorImageDownsampleType /Bicubic /ColorImageResolution 300 /CompatibilityLevel 1.4 /CreateJobTicket true /DoThumbnails false /EmbedAllFonts true /GrayACSImageDict .printerACSImageDict /GrayImageDownsampleType /Bicubic /GrayImageResolution 300 /MonoImageDownsampleType /Bicubic /MonoImageResolution 1200 /NeverEmbed [] /PreserveEPSInfo true /PreserveOPIComments true /PreserveOverprintSettings true /UCRandBGInfo /Preserve.dicttomark readonly /.prepressACSImageDict mark /QFactor 0.15 /Blend 1 /ColorTransform 1 /HSamples .a1111 /VSamples .a1111.dicttomark readonly def/prepress mark /AutoRotatePages /None /CannotEmbedFontPolicy /Error /ColorACSImageDict .prepressACSImageDict /ColorConversionStrategy /LeaveColorUnchanged /ColorImageDownsampleType /Bicubic /ColorImageResolution 300 /CompatibilityLevel 1.4 /CreateJobTicket true /DoThumbnails true /EmbedAllFonts true /GrayACSImageDict .prepressACSImageDict /GrayImageDownsampleType /Bicubic /GrayImageResolution 300 /MonoImageDownsampleType /Bicubic /MonoImageResolution 1200 /NeverEmbed [] /PreserveEPSInfo true /PreserveOPIComments true /PreserveOverprintSettings true /UCRandBGInfo /Preserve.dicttomark readonly % Define distiller settings for the ps2write device and for the ps2ps2 script :/PSL2Printer mark /AutoRotatePages /None /CannotEmbedFontPolicy /Error /ColorACSImageDict .prepressACSImageDict /ColorConversionStrategy /LeaveColorUnchanged /ColorImageDownsampleType /Bicubic /ColorImageResolution 600 /CompatibilityLevel 1.2 % Always 1.2 with ps2write. % /CreateJobTicket true % Not sure /DoThumbnails false /EmbedAllFonts true /GrayACSImageDict .prepressACSImageDict /GrayImageDownsampleType /Bicubic /GrayImageResolution 600 /MonoImageDownsampleType /Bicubic /MonoImageResolution 1200 /NeverEmbed [] /PreserveEPSInfo true /PreserveOPIComments true /PreserveOverprintSettings true /UCRandBGInfo /Preserve /PreserveHalftoneInfo true /TransferFunctionInfo /Preserve /MaxViewerMemorySize 8000000 /CompressPages false /CompressFonts false /ASCII85EncodePages true .dicttomark readonly .dicttomark readonly def % ---------------- End of predefined configurations ---------------- % % Set optimizations for converting PostScript to PDF.% The ps2pdf* scripts invoke this./.setpdfwrite { % - .setpdfwrite - % Set a large VM threshold to reduce garbage collection. currentuserparams /VMThreshold get 3000000 .max setvmthreshold} bind def % ---------------- pdfmark and DSC processing ---------------- % /.write_small_positive_real % <file> <real> .write_small_positive_real -{ % The argument must be grater than 0 and must be strongly samller than 0.1. % The conversion isn't simple due to the low (24 bits) precision % of the floating point arithmetics in Postscript. % For best result we first use the 1e8 factor since its binary % representation 101111101011110000100000000 well rounds into 14 significant % bits : 101111101011110000000000000 . 1 index (.) writestring { dup 100000000 mul dup 10 mul 1 ge { % Will need not greater than 0.1 due to a rounding below. pop exit } if exch pop 1 index (00000000) writestring } loop % Now it is not smaller than 1e-9, use simple digitizing. { dup 10 mul dup 10 mul 1 ge { pop exit } if exch pop 1 index (0) writestring } loop % Now 0.01 <= n < 0.1, but rounding may give 0.1 . % Convert to integer with 7 digits precision : 100000000 % precision factor 1e8 % f n r dup 10 idiv 3 1 roll mul 0.5 add cvi % f r' N 2 copy le { % The rounding overflows, suppress it. % Note it carries out an additional digit, % that's why we needed <0.1 above. pop pop (1) writestring } { % Didn't cary out, put 0. 2 index (0) writestring exch % f N r % Continue the simple digitizing : { 10 idiv dup % f N r' r' 2 index exch idiv % f N r' d (0123456789) exch 1 getinterval % f N r' (d) 3 index exch writestring % f N r' dup 3 2 roll exch mod % f r' N' dup 0 eq { % Don't write trailing zeros. exit } if exch % f N' r' } loop pop pop pop } ifelse} bind def % Encode values to pass for the /pdfmark or /DSC pseudo-parameter./.pdf===dict mark /arraytype { dup xcheck { ({) (}) } { ([) (]) } ifelse % Stack: file obj left right 4 1 roll 2 index exch writestring () exch { exch 2 index exch writestring 1 index exch pdf===only ( ) } forall pop exch writestring } bind /packedarraytype 1 index /dicttype { 1 index (<<\n) writestring { 2 index 3 -1 roll pdf===only 1 index ( ) writestring 1 index exch pdf===only dup (\n) writestring } forall (>>) writestring } bind /nametype { % If the name string includes any non-regular characters, % write it with two preceding and one following null character(s). % (Null characters in the name itself are not allowed.) % This non-standard escape convention is required for passing names % that include non-regular characters, because PostScript provides % no way to do this. The pdf_scan_token procedure in the C code of % the pdfwrite driver is currently the only place that recognizes % this convention. dup .namestring (\000\011\012\014\015 %()/<>[]{}) .stringbreak null ne { dup .namestring (\000) .stringbreak null ne { /rangecheck signalerror } if 1 index <0000> writestring 1 index exch write===only 0 write } { write===only } ifelse } bind /realtype { % Prevent using floating point format - see Bug 688167. dup dup 0 lt { neg } if 0.01 lt { dup 0 eq { pop (0) writestring } { dup 0 lt { 1 index (-) writestring neg } if .write_small_positive_real } ifelse } { write===only } ifelse } bind.dicttomark readonly def/pdf===only { % <file> <obj> pdf===only - .pdf===dict 1 index type .knownget { exec } { write===only } ifelse} bind def/.pdfcvbuf 30 string def % enough for most argumentsuserdict /.pdfcvstring () put/.pdfcvs { % <obj> .pdfcvs <string> currentglobal exch false .setglobal /.pdfcvstring () store % We can't handle long values yet. { pop dup length 0 eq { pop } { /.pdfcvstring .pdfcvstring 3 -1 roll concatstrings store } ifelse //.pdfcvbuf } /NullEncode filter dup 3 -1 roll pdf===only closefile .setglobal .pdfcvstring} bind def % Redefine pdfmark to pass the data to the driver.% We use a pseudo-parameter named /pdfmark whose value is an array:% /key1 (value1) ... (CTM) /type/.pdfputparams { % -mark- <key1> <value1> ... .pdfputparams <result...> currentdevice null false counttomark 1 add 3 roll % Don't allow the page device to get cleared.... {.putdeviceparams} .currentpagedevice pop {.setpagedevice} 3 .execn} bind def% Convert relevant operands to strings in an array./.pdfcvsloop { % -mark- values ... markname start step .pdfcvsloop % [values ... ctm markname] matrix currentmatrix .pdfcvs 4 1 roll counttomark 1 add 2 roll counttomark .localvmarray astore exch pop 3 1 roll % Stack: values start step 2 index length 3 sub { 2 copy 2 copy get .pdfcvs put pop } for} bind def/.pdfcvsall { % -mark- values ... markname .pdfcvsall <<same>> 0 1 .pdfcvsloop} bind def/.pdfcvseven { % -mark- key value ... markname .pdfcvseven <<same>> 1 2 .pdfcvsloop} bind def/.pdfcvsnone { % -mark- values ... markname .pdfcvsnone <<same>> 100000 1 .pdfcvsloop} bind def/.pdfcvsfirst { % -mark- first values ... markname .pdfcvsfirst<<same>> .pdfcvsnone dup 0 2 copy get .pdfcvs put} bind def% The procedures in the following dictionary are called with the entire% pdfmark operand list (including the pdfmark name) on the stack;% they may modify this ad lib. They must call .pdfcvsxxx./.pdfmarkparams mark % Unpack a dictionary for PUT, and don't convert stream data. /PUT { counttomark 3 eq { 1 index type /dicttype eq { pop { } forall /.PUTDICT .pdfcvsall } { pop dup type /filetype eq { % Read the file into a sequence of strings. % This isn't great, but it's simple. { dup 64000 string readstring not { exch exit } if exch } loop closefile } if /.PUTSTREAM .pdfcvsfirst } ifelse } { .pdfcvsall } ifelse } bind % Unpack the array for PUTINTERVAL. /PUTINTERVAL { pop aload pop /.PUTINTERVAL .pdfcvsall } bind.dicttomark readonly def/.pdfparamerror { % ? ? ? -mark- ... <errname> <opname> .pdfparamerror - counttomark 4 add 2 roll cleartomark pop pop pop .systemvar exch signalerror} bind def/pdfmark { % -mark- <key> <value> ... <markname> pdfmark - dup /SP eq { % A hack for synchronizing the clipping path. gsave [1 0 0 1 0 0] setmatrix 0 setlinewidth newpath -3 -3 moveto closepath stroke % Paints outside the device bbox. grestore } if dup /PS eq systemdict /PDFX .knownget not { false } if and { % Execute it since PDF/X doesn't allow to embed it. { dup mark eq { pop exit } if 1 index /DataSource eq { cvx exec } { pop pop } ifelse } loop } { counttomark 1 add copy //.pdfmarkparams 1 index .knownget { exec } { .pdfcvsall } ifelse mark /pdfmark 3 -1 roll .pdfputparams dup type /booleantype ne { /pdfmark .pdfparamerror } if cleartomark } ifelse} odefuserdict /pdfmark .undefcurrentdict /.pdfmarkparams .undef % <dict> .hook_DSC_Creator -/.pdf_hook_DSC_Creator{Lines 1–500 of 815. Load more
% Copyright (C) 1996, 2000 Aladdin Enterprises. All rights reserved. % % This software is provided AS-IS with no warranty, either express or % implied. % % This software is distributed under license and may not be copied, % modified or distributed except as expressly authorized under the terms % of the license contained in the file LICENSE in this distribution. % % For more information about licensing, please refer to % http://www.ghostscript.com/licensing/. For information on % commercial licensing, go to http://www.artifex.com/licensing/ or % contact Artifex Software, Inc., 101 Lucas Valley Road #110, % San Rafael, CA 94903, U.S.A., +1(415)492-9861. % $Id: gs_pdfwr.ps,v 1.52 2005/10/20 13:04:16 leonardo Exp $ % PDF writer additions to systemdict. % This file should be included iff the pdfwrite "device" is included % in the executable. % ---------------- Predefined configurations ---------------- % % These correspond to the 4 predefined settings in Acrobat Distiller 5, % plus a "default" setting that doesn't downsample images. /.a2112 [2 1 1 2] readonly def /.a1111 [1 1 1 1] readonly def /.standardfonts [ /Courier /Courier-Bold /Courier-Oblique /Courier-BoldOblique /Helvetica /Helvetica-Bold /Helvetica-Oblique /Helvetica-BoldOblique /Times-Roman /Times-Bold /Times-Italic /Times-BoldItalic /Symbol /ZapfDingbats ] readonly def % Parameters common to all non-default configurations. % Note that the default configuration overrides a few of these. /.defaultImageDict mark /QFactor 0.9 /Blend 1 /HSamples .a2112 /VSamples .a2112 .dicttomark readonly def /.distillercommon mark /AlwaysEmbed [] /AntiAliasColorImages false /AntiAliasGrayImages false /AntiAliasMonoImages false /ASCII85EncodePages false /AutoFilterColorImages true /AutoFilterGrayImages true /AutoPositionEPSFiles true /Binding /Left /CalCMYKProfile (None) % (U.S. Web Coated (SWOP) v2) /CalGrayProfile (None) % (Dot Gain 20%) /CalRGBProfile (None) % (sRGB IEC61966-2.1) /ColorImageDepth -1 /ColorImageDict .defaultImageDict /ColorImageDownsampleThreshold 1.5 /ColorImageFilter /DCTEncode /CompressPages true /ConvertImagesToIndexed true /DefaultRenderingIntent /Default /DetectBlends true /DownsampleColorImages true /DownsampleGrayImages true /DownsampleMonoImages true /EmitDSCWarnings false /EncodeColorImages true /EncodeGrayImages true /EncodeMonoImages true /EndPage -1 /GrayImageDepth -1 /GrayImageDict .defaultImageDict /GrayImageDownsampleThreshold 1.5 /GrayImageFilter /DCTEncode /ImageMemory 524288 /LockDistillerParams false /MaxSubsetPct 100 /MonoImageDepth -1 /MonoImageDict mark /K -1 .dicttomark readonly /MonoImageDownsampleThreshold 1.5 /MonoImageFilter /CCITTFaxEncode /OffOptimizations 0 /OPM 1 /Optimize true /ParseDSCComments true /ParseDSCCommentsForDocInfo true /PreserveCopyPage true /PreserveHalftoneInfo false /sRGBProfile (None) % (sRGB IEC61966-2.1) /StartPage 1 /SubsetFonts true /TransferFunctionInfo /Preserve /UseFlateCompression true /UsePrologue false .dicttomark readonly def /.distillersettings mark /default mark /AutoRotatePages /PageByPage /CannotEmbedFontPolicy /Warning /ColorACSImageDict .defaultImageDict /ColorConversionStrategy /LeaveColorUnchanged % /ColorImageDownsampleType % /ColorImageResolution % /CompatibilityLevel /CreateJobTicket false /DoThumbnails false /DownsampleColorImages false % override /DownsampleGrayImages false % override /DownsampleMonoImages false % override /EmbedAllFonts true /GrayACSImageDict .defaultImageDict % /GrayImageDownsampleType % /GrayImageResolution % /MonoImageDownsampleType % /MonoImageResolution /NeverEmbed .standardfonts /Optimize false % override /PreserveEPSInfo true /PreserveOPIComments true /PreserveOverprintSettings true /UCRandBGInfo /Preserve .dicttomark readonly /.screenACSImageDict mark /QFactor 0.76 /Blend 1 /ColorTransform 1 /HSamples .a2112 /VSamples .a2112 .dicttomark readonly def /screen mark /AutoRotatePages /PageByPage % /CalGrayProfile (None) /CannotEmbedFontPolicy /Warning /ColorACSImageDict .screenACSImageDict /ColorConversionStrategy /sRGB /ColorImageDownsampleType /Average /ColorImageResolution 72 /CompatibilityLevel 1.3 /CreateJobTicket false /DoThumbnails false /EmbedAllFonts true /GrayACSImageDict .screenACSImageDict /GrayImageDownsampleType /Average /GrayImageResolution 72 /MonoImageDownsampleType /Average /MonoImageResolution 300 /NeverEmbed .standardfonts /PreserveEPSInfo false /PreserveOPIComments false /PreserveOverprintSettings false /UCRandBGInfo /Remove .dicttomark readonly /ebook mark /AutoRotatePages /All % /CalGrayProfile (None) /CannotEmbedFontPolicy /Warning /ColorACSImageDict .screenACSImageDict /ColorConversionStrategy /sRGB /ColorImageDownsampleType /Bicubic /ColorImageResolution 150 /CompatibilityLevel 1.4 /CreateJobTicket false /DoThumbnails false /EmbedAllFonts true /GrayACSImageDict .screenACSImageDict /GrayImageDownsampleType /Bicubic /GrayImageResolution 150 /MonoImageDownsampleType /Bicubic /MonoImageResolution 300 /NeverEmbed .standardfonts /PreserveEPSInfo false /PreserveOPIComments false /PreserveOverprintSettings false /UCRandBGInfo /Remove .dicttomark readonly /.printerACSImageDict mark /QFactor 0.4 /Blend 1 /ColorTransform 1 /HSamples .a1111 /VSamples .a1111 .dicttomark readonly def /printer mark /AutoRotatePages /None % /CalGrayProfile (None) /CannotEmbedFontPolicy /Warning /ColorACSImageDict .printerACSImageDict /ColorConversionStrategy /UseDeviceIndependentColor /ColorImageDownsampleType /Bicubic /ColorImageResolution 300 /CompatibilityLevel 1.4 /CreateJobTicket true /DoThumbnails false /EmbedAllFonts true /GrayACSImageDict .printerACSImageDict /GrayImageDownsampleType /Bicubic /GrayImageResolution 300 /MonoImageDownsampleType /Bicubic /MonoImageResolution 1200 /NeverEmbed [] /PreserveEPSInfo true /PreserveOPIComments true /PreserveOverprintSettings true /UCRandBGInfo /Preserve .dicttomark readonly /.prepressACSImageDict mark /QFactor 0.15 /Blend 1 /ColorTransform 1 /HSamples .a1111 /VSamples .a1111 .dicttomark readonly def /prepress mark /AutoRotatePages /None /CannotEmbedFontPolicy /Error /ColorACSImageDict .prepressACSImageDict /ColorConversionStrategy /LeaveColorUnchanged /ColorImageDownsampleType /Bicubic /ColorImageResolution 300 /CompatibilityLevel 1.4 /CreateJobTicket true /DoThumbnails true /EmbedAllFonts true /GrayACSImageDict .prepressACSImageDict /GrayImageDownsampleType /Bicubic /GrayImageResolution 300 /MonoImageDownsampleType /Bicubic /MonoImageResolution 1200 /NeverEmbed [] /PreserveEPSInfo true /PreserveOPIComments true /PreserveOverprintSettings true /UCRandBGInfo /Preserve .dicttomark readonly % Define distiller settings for the ps2write device and for the ps2ps2 script : /PSL2Printer mark /AutoRotatePages /None /CannotEmbedFontPolicy /Error /ColorACSImageDict .prepressACSImageDict /ColorConversionStrategy /LeaveColorUnchanged /ColorImageDownsampleType /Bicubic /ColorImageResolution 600 /CompatibilityLevel 1.2 % Always 1.2 with ps2write. % /CreateJobTicket true % Not sure /DoThumbnails false /EmbedAllFonts true /GrayACSImageDict .prepressACSImageDict /GrayImageDownsampleType /Bicubic /GrayImageResolution 600 /MonoImageDownsampleType /Bicubic /MonoImageResolution 1200 /NeverEmbed [] /PreserveEPSInfo true /PreserveOPIComments true /PreserveOverprintSettings true /UCRandBGInfo /Preserve /PreserveHalftoneInfo true /TransferFunctionInfo /Preserve /MaxViewerMemorySize 8000000 /CompressPages false /CompressFonts false /ASCII85EncodePages true .dicttomark readonly .dicttomark readonly def % ---------------- End of predefined configurations ---------------- % % Set optimizations for converting PostScript to PDF. % The ps2pdf* scripts invoke this. /.setpdfwrite { % - .setpdfwrite - % Set a large VM threshold to reduce garbage collection. currentuserparams /VMThreshold get 3000000 .max setvmthreshold } bind def % ---------------- pdfmark and DSC processing ---------------- % /.write_small_positive_real % <file> <real> .write_small_positive_real - { % The argument must be grater than 0 and must be strongly samller than 0.1. % The conversion isn't simple due to the low (24 bits) precision % of the floating point arithmetics in Postscript. % For best result we first use the 1e8 factor since its binary % representation 101111101011110000100000000 well rounds into 14 significant % bits : 101111101011110000000000000 . 1 index (.) writestring { dup 100000000 mul dup 10 mul 1 ge { % Will need not greater than 0.1 due to a rounding below. pop exit } if exch pop 1 index (00000000) writestring } loop % Now it is not smaller than 1e-9, use simple digitizing. { dup 10 mul dup 10 mul 1 ge { pop exit } if exch pop 1 index (0) writestring } loop % Now 0.01 <= n < 0.1, but rounding may give 0.1 . % Convert to integer with 7 digits precision : 100000000 % precision factor 1e8 % f n r dup 10 idiv 3 1 roll mul 0.5 add cvi % f r' N 2 copy le { % The rounding overflows, suppress it. % Note it carries out an additional digit, % that's why we needed <0.1 above. pop pop (1) writestring } { % Didn't cary out, put 0. 2 index (0) writestring exch % f N r % Continue the simple digitizing : { 10 idiv dup % f N r' r' 2 index exch idiv % f N r' d (0123456789) exch 1 getinterval % f N r' (d) 3 index exch writestring % f N r' dup 3 2 roll exch mod % f r' N' dup 0 eq { % Don't write trailing zeros. exit } if exch % f N' r' } loop pop pop pop } ifelse } bind def % Encode values to pass for the /pdfmark or /DSC pseudo-parameter. /.pdf===dict mark /arraytype { dup xcheck { ({) (}) } { ([) (]) } ifelse % Stack: file obj left right 4 1 roll 2 index exch writestring () exch { exch 2 index exch writestring 1 index exch pdf===only ( ) } forall pop exch writestring } bind /packedarraytype 1 index /dicttype { 1 index (<<\n) writestring { 2 index 3 -1 roll pdf===only 1 index ( ) writestring 1 index exch pdf===only dup (\n) writestring } forall (>>) writestring } bind /nametype { % If the name string includes any non-regular characters, % write it with two preceding and one following null character(s). % (Null characters in the name itself are not allowed.) % This non-standard escape convention is required for passing names % that include non-regular characters, because PostScript provides % no way to do this. The pdf_scan_token procedure in the C code of % the pdfwrite driver is currently the only place that recognizes % this convention. dup .namestring (\000\011\012\014\015 %()/<>[]{}) .stringbreak null ne { dup .namestring (\000) .stringbreak null ne { /rangecheck signalerror } if 1 index <0000> writestring 1 index exch write===only 0 write } { write===only } ifelse } bind /realtype { % Prevent using floating point format - see Bug 688167. dup dup 0 lt { neg } if 0.01 lt { dup 0 eq { pop (0) writestring } { dup 0 lt { 1 index (-) writestring neg } if .write_small_positive_real } ifelse } { write===only } ifelse } bind .dicttomark readonly def /pdf===only { % <file> <obj> pdf===only - .pdf===dict 1 index type .knownget { exec } { write===only } ifelse } bind def /.pdfcvbuf 30 string def % enough for most arguments userdict /.pdfcvstring () put /.pdfcvs { % <obj> .pdfcvs <string> currentglobal exch false .setglobal /.pdfcvstring () store % We can't handle long values yet. { pop dup length 0 eq { pop } { /.pdfcvstring .pdfcvstring 3 -1 roll concatstrings store } ifelse //.pdfcvbuf } /NullEncode filter dup 3 -1 roll pdf===only closefile .setglobal .pdfcvstring } bind def % Redefine pdfmark to pass the data to the driver. % We use a pseudo-parameter named /pdfmark whose value is an array: % /key1 (value1) ... (CTM) /type /.pdfputparams { % -mark- <key1> <value1> ... .pdfputparams <result...> currentdevice null false counttomark 1 add 3 roll % Don't allow the page device to get cleared.... {.putdeviceparams} .currentpagedevice pop {.setpagedevice} 3 .execn } bind def % Convert relevant operands to strings in an array. /.pdfcvsloop { % -mark- values ... markname start step .pdfcvsloop % [values ... ctm markname] matrix currentmatrix .pdfcvs 4 1 roll counttomark 1 add 2 roll counttomark .localvmarray astore exch pop 3 1 roll % Stack: values start step 2 index length 3 sub { 2 copy 2 copy get .pdfcvs put pop } for } bind def /.pdfcvsall { % -mark- values ... markname .pdfcvsall <<same>> 0 1 .pdfcvsloop } bind def /.pdfcvseven { % -mark- key value ... markname .pdfcvseven <<same>> 1 2 .pdfcvsloop } bind def /.pdfcvsnone { % -mark- values ... markname .pdfcvsnone <<same>> 100000 1 .pdfcvsloop } bind def /.pdfcvsfirst { % -mark- first values ... markname .pdfcvsfirst<<same>> .pdfcvsnone dup 0 2 copy get .pdfcvs put } bind def % The procedures in the following dictionary are called with the entire % pdfmark operand list (including the pdfmark name) on the stack; % they may modify this ad lib. They must call .pdfcvsxxx. /.pdfmarkparams mark % Unpack a dictionary for PUT, and don't convert stream data. /PUT { counttomark 3 eq { 1 index type /dicttype eq { pop { } forall /.PUTDICT .pdfcvsall } { pop dup type /filetype eq { % Read the file into a sequence of strings. % This isn't great, but it's simple. { dup 64000 string readstring not { exch exit } if exch } loop closefile } if /.PUTSTREAM .pdfcvsfirst } ifelse } { .pdfcvsall } ifelse } bind % Unpack the array for PUTINTERVAL. /PUTINTERVAL { pop aload pop /.PUTINTERVAL .pdfcvsall } bind .dicttomark readonly def /.pdfparamerror { % ? ? ? -mark- ... <errname> <opname> .pdfparamerror - counttomark 4 add 2 roll cleartomark pop pop pop .systemvar exch signalerror } bind def /pdfmark { % -mark- <key> <value> ... <markname> pdfmark - dup /SP eq { % A hack for synchronizing the clipping path. gsave [1 0 0 1 0 0] setmatrix 0 setlinewidth newpath -3 -3 moveto closepath stroke % Paints outside the device bbox. grestore } if dup /PS eq systemdict /PDFX .knownget not { false } if and { % Execute it since PDF/X doesn't allow to embed it. { dup mark eq { pop exit } if 1 index /DataSource eq { cvx exec } { pop pop } ifelse } loop } { counttomark 1 add copy //.pdfmarkparams 1 index .knownget { exec } { .pdfcvsall } ifelse mark /pdfmark 3 -1 roll .pdfputparams dup type /booleantype ne { /pdfmark .pdfparamerror } if cleartomark } ifelse } odef userdict /pdfmark .undef currentdict /.pdfmarkparams .undef % <dict> .hook_DSC_Creator - /.pdf_hook_DSC_Creator {