summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2023-09-13 23:30:15 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2023-09-13 23:30:15 +0000
commit9262fc101afe7733e74817d5d3e5917cf0143503 (patch)
treed53e8cfa6d589a695ef5554bfb69f5c0bf6c6b8e
parentc167e0a5bb767292da0aeef68f0bc336fc06ec0f (diff)
tlgs (gs-10.02.0)
git-svn-id: svn://tug.org/texlive/trunk@68272 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/tlpkg/tlgs/README.TEXLIVE2
-rw-r--r--Master/tlpkg/tlgs/Resource/CIDFont/ArtifexBulletbin2664 -> 2587 bytes
-rw-r--r--Master/tlpkg/tlgs/Resource/CMap/Identity-UTF16-H11
-rw-r--r--Master/tlpkg/tlgs/Resource/ColorSpace/DefaultCMYK6
-rw-r--r--Master/tlpkg/tlgs/Resource/ColorSpace/DefaultGray6
-rw-r--r--Master/tlpkg/tlgs/Resource/ColorSpace/DefaultRGB6
-rw-r--r--Master/tlpkg/tlgs/Resource/ColorSpace/TrivialCMYK6
-rw-r--r--Master/tlpkg/tlgs/Resource/ColorSpace/sGray6
-rw-r--r--Master/tlpkg/tlgs/Resource/ColorSpace/sRGB6
-rw-r--r--Master/tlpkg/tlgs/Resource/Decoding/FCO_Dingbats6
-rw-r--r--Master/tlpkg/tlgs/Resource/Decoding/FCO_Symbol6
-rw-r--r--Master/tlpkg/tlgs/Resource/Decoding/FCO_Unicode6
-rw-r--r--Master/tlpkg/tlgs/Resource/Decoding/FCO_Wingdings6
-rw-r--r--Master/tlpkg/tlgs/Resource/Decoding/Latin16
-rw-r--r--Master/tlpkg/tlgs/Resource/Decoding/StandardEncoding6
-rw-r--r--Master/tlpkg/tlgs/Resource/Decoding/Unicode6
-rw-r--r--Master/tlpkg/tlgs/Resource/Encoding/CEEncoding6
-rw-r--r--Master/tlpkg/tlgs/Resource/Encoding/ExpertEncoding6
-rw-r--r--Master/tlpkg/tlgs/Resource/Encoding/ExpertSubsetEncoding6
-rw-r--r--Master/tlpkg/tlgs/Resource/Encoding/NotDefEncoding6
-rw-r--r--Master/tlpkg/tlgs/Resource/Encoding/Wingdings6
-rw-r--r--Master/tlpkg/tlgs/Resource/IdiomSet/PPI_CUtils2
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_agl.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_btokn.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_cff.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_cidcm.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_ciddc.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_cidfm.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_cidfn.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_cidtt.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_cmap.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_cspace.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_dbt_e.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_diskn.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_dps1.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_dps2.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_dscp.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_epsf.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_fapi.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_fntem.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps4
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_frsd.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_icc.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_il1_e.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_img.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_init.ps37
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_lev2.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_ll3.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_mex_e.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_mgl_e.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_mro_e.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_pdf_e.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_pdfwr.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_res.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_resmp.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_setpd.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_statd.ps19
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_std_e.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_sym_e.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_trap.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_typ32.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_typ42.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_type1.ps15
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_wan_e.ps6
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/pdf_base.ps1474
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps5896
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/pdf_font.ps2809
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/pdf_main.ps3971
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps2129
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/pdf_rbld.ps476
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/pdf_sec.ps829
-rw-r--r--Master/tlpkg/tlgs/Resource/SubstCID/CNS1-WMode6
-rw-r--r--Master/tlpkg/tlgs/Resource/SubstCID/GB1-WMode6
-rw-r--r--Master/tlpkg/tlgs/Resource/SubstCID/Japan1-WMode6
-rw-r--r--Master/tlpkg/tlgs/Resource/SubstCID/Korea1-WMode6
-rwxr-xr-xMaster/tlpkg/tlgs/bin/gsdll64.dllbin16559104 -> 16622592 bytes
-rwxr-xr-xMaster/tlpkg/tlgs/bin/gswin64.exebin241664 -> 241664 bytes
-rwxr-xr-xMaster/tlpkg/tlgs/bin/gswin64c.exebin232960 -> 232960 bytes
-rw-r--r--Master/tlpkg/tlgs/lib/PDFA_def.ps2
-rw-r--r--Master/tlpkg/tlgs/lib/align.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/caption.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/cat.ps74
-rw-r--r--Master/tlpkg/tlgs/lib/cid2code.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/docie.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/font2pcl.ps604
-rw-r--r--Master/tlpkg/tlgs/lib/gs_ce_e.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/gs_il2_e.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/gs_kanji.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/gs_ksb_e.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/gs_lgo_e.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/gs_lgx_e.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/gs_wl1_e.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/gs_wl2_e.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/gs_wl5_e.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/gslp.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/gsnup.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/image-qa.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/jispaper.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/jobseparator.ps3
-rw-r--r--Master/tlpkg/tlgs/lib/lines.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/mkcidfm.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/pdf2dsc.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/pdf_info.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/pfbtopfa.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/ppath.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/pphs.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/prfont.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/ps2ai.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/ps2epsi.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/rollconv.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/stcinfo.ps794
-rw-r--r--Master/tlpkg/tlgs/lib/stcolor.ps169
-rw-r--r--Master/tlpkg/tlgs/lib/stocht.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/traceimg.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/traceop.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/uninfo.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/viewcmyk.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/viewgif.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/viewjpeg.ps4
-rw-r--r--Master/tlpkg/tlgs/lib/viewmiff.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/viewpbm.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/viewpcx.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/viewps2a.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/viewpwg.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/viewraw.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/viewrgb.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/winmaps.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/zeroline.ps6
-rw-r--r--Master/tlpkg/tlgs/lib/zugferd.ps6
130 files changed, 2116 insertions, 17838 deletions
diff --git a/Master/tlpkg/tlgs/README.TEXLIVE b/Master/tlpkg/tlgs/README.TEXLIVE
index abcf1cb4a8f..879c5a0568c 100644
--- a/Master/tlpkg/tlgs/README.TEXLIVE
+++ b/Master/tlpkg/tlgs/README.TEXLIVE
@@ -1,5 +1,5 @@
-This directory contains a subset of the Ghostscript 10.01.1 distribution
+This directory contains a subset of the Ghostscript 10.02.0 distribution
for Windows. The only purpose of this package is to support programs
shipped with TeX Live. It's not intended for general use.
diff --git a/Master/tlpkg/tlgs/Resource/CIDFont/ArtifexBullet b/Master/tlpkg/tlgs/Resource/CIDFont/ArtifexBullet
index 268d518f248..9e50e38fe3b 100644
--- a/Master/tlpkg/tlgs/Resource/CIDFont/ArtifexBullet
+++ b/Master/tlpkg/tlgs/Resource/CIDFont/ArtifexBullet
Binary files differ
diff --git a/Master/tlpkg/tlgs/Resource/CMap/Identity-UTF16-H b/Master/tlpkg/tlgs/Resource/CMap/Identity-UTF16-H
index 5c1c3eac92b..2d4cde6b4da 100644
--- a/Master/tlpkg/tlgs/Resource/CMap/Identity-UTF16-H
+++ b/Master/tlpkg/tlgs/Resource/CMap/Identity-UTF16-H
@@ -1,4 +1,5 @@
-% Copyright (C) 2003-2021 Artifex Software. All rights reserved.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
+% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
% implied.
@@ -7,11 +8,9 @@
% 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., 1305 Grant Avenue - Suite 200,
-% Novato, CA 94945, U.S.A., +1(415)492-9861.
+% Refer to licensing information at http://www.artifex.com or contact
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Identity-UTF16-H CMap
% An identity mapping of UTF16 codes to CIDs.
diff --git a/Master/tlpkg/tlgs/Resource/ColorSpace/DefaultCMYK b/Master/tlpkg/tlgs/Resource/ColorSpace/DefaultCMYK
index f3d7182350a..5b94dfcbd80 100644
--- a/Master/tlpkg/tlgs/Resource/ColorSpace/DefaultCMYK
+++ b/Master/tlpkg/tlgs/Resource/ColorSpace/DefaultCMYK
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% DefaultCMYK color space resource.
diff --git a/Master/tlpkg/tlgs/Resource/ColorSpace/DefaultGray b/Master/tlpkg/tlgs/Resource/ColorSpace/DefaultGray
index 21a72fd634e..351484d1446 100644
--- a/Master/tlpkg/tlgs/Resource/ColorSpace/DefaultGray
+++ b/Master/tlpkg/tlgs/Resource/ColorSpace/DefaultGray
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% DefaultGray color space resource.
diff --git a/Master/tlpkg/tlgs/Resource/ColorSpace/DefaultRGB b/Master/tlpkg/tlgs/Resource/ColorSpace/DefaultRGB
index d715587b994..8ac56224106 100644
--- a/Master/tlpkg/tlgs/Resource/ColorSpace/DefaultRGB
+++ b/Master/tlpkg/tlgs/Resource/ColorSpace/DefaultRGB
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% DefaultRGB color space resource.
diff --git a/Master/tlpkg/tlgs/Resource/ColorSpace/TrivialCMYK b/Master/tlpkg/tlgs/Resource/ColorSpace/TrivialCMYK
index 66776bcde96..7778b6cf52b 100644
--- a/Master/tlpkg/tlgs/Resource/ColorSpace/TrivialCMYK
+++ b/Master/tlpkg/tlgs/Resource/ColorSpace/TrivialCMYK
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Color space that simulates appearance of the standard CMYK to RGB conversion.
diff --git a/Master/tlpkg/tlgs/Resource/ColorSpace/sGray b/Master/tlpkg/tlgs/Resource/ColorSpace/sGray
index 501ed376b44..7db5596d98a 100644
--- a/Master/tlpkg/tlgs/Resource/ColorSpace/sGray
+++ b/Master/tlpkg/tlgs/Resource/ColorSpace/sGray
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% One-component color space similar to sRGB color space.
diff --git a/Master/tlpkg/tlgs/Resource/ColorSpace/sRGB b/Master/tlpkg/tlgs/Resource/ColorSpace/sRGB
index 0aadbc01a51..8cab40a480c 100644
--- a/Master/tlpkg/tlgs/Resource/ColorSpace/sRGB
+++ b/Master/tlpkg/tlgs/Resource/ColorSpace/sRGB
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% sRGB color space derived from the public domain HP sample.
diff --git a/Master/tlpkg/tlgs/Resource/Decoding/FCO_Dingbats b/Master/tlpkg/tlgs/Resource/Decoding/FCO_Dingbats
index 76cd6d1a435..ff57146fca7 100644
--- a/Master/tlpkg/tlgs/Resource/Decoding/FCO_Dingbats
+++ b/Master/tlpkg/tlgs/Resource/Decoding/FCO_Dingbats
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
%
% FCO_Symbol Decoding
diff --git a/Master/tlpkg/tlgs/Resource/Decoding/FCO_Symbol b/Master/tlpkg/tlgs/Resource/Decoding/FCO_Symbol
index 4c2dcecb645..3c979ae05bf 100644
--- a/Master/tlpkg/tlgs/Resource/Decoding/FCO_Symbol
+++ b/Master/tlpkg/tlgs/Resource/Decoding/FCO_Symbol
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
%
% FCO_Symbol Decoding
diff --git a/Master/tlpkg/tlgs/Resource/Decoding/FCO_Unicode b/Master/tlpkg/tlgs/Resource/Decoding/FCO_Unicode
index acc8e0229c6..8d33dceea58 100644
--- a/Master/tlpkg/tlgs/Resource/Decoding/FCO_Unicode
+++ b/Master/tlpkg/tlgs/Resource/Decoding/FCO_Unicode
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
%
% Unicode Decoding
diff --git a/Master/tlpkg/tlgs/Resource/Decoding/FCO_Wingdings b/Master/tlpkg/tlgs/Resource/Decoding/FCO_Wingdings
index 2eaca0df36e..cac1c8357e9 100644
--- a/Master/tlpkg/tlgs/Resource/Decoding/FCO_Wingdings
+++ b/Master/tlpkg/tlgs/Resource/Decoding/FCO_Wingdings
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
%
% FCO_Wingdings Decoding
diff --git a/Master/tlpkg/tlgs/Resource/Decoding/Latin1 b/Master/tlpkg/tlgs/Resource/Decoding/Latin1
index b9dff0f3d76..2441653d5e1 100644
--- a/Master/tlpkg/tlgs/Resource/Decoding/Latin1
+++ b/Master/tlpkg/tlgs/Resource/Decoding/Latin1
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Decoding for mapping PS names to codes for renderers which cannot
diff --git a/Master/tlpkg/tlgs/Resource/Decoding/StandardEncoding b/Master/tlpkg/tlgs/Resource/Decoding/StandardEncoding
index 5ac6d63c09a..0ea305bc52c 100644
--- a/Master/tlpkg/tlgs/Resource/Decoding/StandardEncoding
+++ b/Master/tlpkg/tlgs/Resource/Decoding/StandardEncoding
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Decoding for StandardEncoding
diff --git a/Master/tlpkg/tlgs/Resource/Decoding/Unicode b/Master/tlpkg/tlgs/Resource/Decoding/Unicode
index dfc137d9272..5843c32486c 100644
--- a/Master/tlpkg/tlgs/Resource/Decoding/Unicode
+++ b/Master/tlpkg/tlgs/Resource/Decoding/Unicode
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
%
% Unicode Decoding
diff --git a/Master/tlpkg/tlgs/Resource/Encoding/CEEncoding b/Master/tlpkg/tlgs/Resource/Encoding/CEEncoding
index b2d7e574eed..32f8d77fb39 100644
--- a/Master/tlpkg/tlgs/Resource/Encoding/CEEncoding
+++ b/Master/tlpkg/tlgs/Resource/Encoding/CEEncoding
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
/CEEncoding [
diff --git a/Master/tlpkg/tlgs/Resource/Encoding/ExpertEncoding b/Master/tlpkg/tlgs/Resource/Encoding/ExpertEncoding
index 97b33213e9e..ff2336d9891 100644
--- a/Master/tlpkg/tlgs/Resource/Encoding/ExpertEncoding
+++ b/Master/tlpkg/tlgs/Resource/Encoding/ExpertEncoding
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
/ExpertEncoding [
diff --git a/Master/tlpkg/tlgs/Resource/Encoding/ExpertSubsetEncoding b/Master/tlpkg/tlgs/Resource/Encoding/ExpertSubsetEncoding
index 6177adb0328..678e8d5bb4b 100644
--- a/Master/tlpkg/tlgs/Resource/Encoding/ExpertSubsetEncoding
+++ b/Master/tlpkg/tlgs/Resource/Encoding/ExpertSubsetEncoding
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
/ExpertSubsetEncoding [
diff --git a/Master/tlpkg/tlgs/Resource/Encoding/NotDefEncoding b/Master/tlpkg/tlgs/Resource/Encoding/NotDefEncoding
index 0c810e48c46..d18a4b2580c 100644
--- a/Master/tlpkg/tlgs/Resource/Encoding/NotDefEncoding
+++ b/Master/tlpkg/tlgs/Resource/Encoding/NotDefEncoding
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define the Notdef encoding vector.
diff --git a/Master/tlpkg/tlgs/Resource/Encoding/Wingdings b/Master/tlpkg/tlgs/Resource/Encoding/Wingdings
index efb7d3fa500..fbe7a111a6c 100644
--- a/Master/tlpkg/tlgs/Resource/Encoding/Wingdings
+++ b/Master/tlpkg/tlgs/Resource/Encoding/Wingdings
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define the Wingdings encoding vector.
diff --git a/Master/tlpkg/tlgs/Resource/IdiomSet/PPI_CUtils b/Master/tlpkg/tlgs/Resource/IdiomSet/PPI_CUtils
index 7e6ecb23ea2..12dbd96a825 100644
--- a/Master/tlpkg/tlgs/Resource/IdiomSet/PPI_CUtils
+++ b/Master/tlpkg/tlgs/Resource/IdiomSet/PPI_CUtils
@@ -15,7 +15,7 @@ currentuserparams /IdiomRecognition get
<<
/cuForceGray [
{/_cuForceGray exch cuPut} bind
-{dup //true eq {currentdevice //null //false mark /PassThroughJPEGImages //false .putdeviceparamsonly}if /_cuForceGray exch cuPut} bind
+{dup //true eq {currentdevice //null //false mark /PassThroughJPEGImages //false .putdeviceparamsonly}if pop pop /_cuForceGray exch cuPut} bind
]
>>
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_agl.ps b/Master/tlpkg/tlgs/Resource/Init/gs_agl.ps
index ce5ea1ce06a..fb1f8a067e5 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_agl.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_agl.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% $Id: gs_agl.ps 10822 2010-02-27 20:24:13Z alexcher $
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_btokn.ps b/Master/tlpkg/tlgs/Resource/Init/gs_btokn.ps
index 1f63fb5c4e0..59478d94102 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_btokn.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_btokn.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Initialization file for binary tokens.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_cff.ps b/Master/tlpkg/tlgs/Resource/Init/gs_cff.ps
index 43cf7d0193f..212ace8bf31 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_cff.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_cff.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Loader for CFF (compressed) fonts, including OpenType CFFs.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_cidcm.ps b/Master/tlpkg/tlgs/Resource/Init/gs_cidcm.ps
index 1ec03b3632a..197a0d3c5cf 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_cidcm.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_cidcm.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Extending Font resource category with CIDFont-CMap fonts.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_ciddc.ps b/Master/tlpkg/tlgs/Resource/Init/gs_ciddc.ps
index 9e2ea1ead74..1ebf7640886 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_ciddc.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_ciddc.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define SubstCID, Decoding and CIDDecoding resource categories and related procsets.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_cidfm.ps b/Master/tlpkg/tlgs/Resource/Init/gs_cidfm.ps
index 1a456ab1dfc..2cc2ecd8e9a 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_cidfm.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_cidfm.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Redefine CIDFont category with cidfmap .
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_cidfn.ps b/Master/tlpkg/tlgs/Resource/Init/gs_cidfn.ps
index fa050ed7acf..5c5c706aec2 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_cidfn.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_cidfn.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2022 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% ProcSet for implementing CIDFont and CIDMap resources.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_cidtt.ps b/Master/tlpkg/tlgs/Resource/Init/gs_cidtt.ps
index b856ba65b26..d7135e50a0e 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_cidtt.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_cidtt.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Redefine CIDFont category with an emulation with True Type fonts.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_cmap.ps b/Master/tlpkg/tlgs/Resource/Init/gs_cmap.ps
index b836c6384f5..0e1c6fc1466 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_cmap.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_cmap.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% ProcSet for implementing CMap resources.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_cspace.ps b/Master/tlpkg/tlgs/Resource/Init/gs_cspace.ps
index c005cef4282..8d38a2eb6ce 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_cspace.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_cspace.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% basic colorspace mechanism
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_dbt_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_dbt_e.ps
index 89e24131bad..1373fafc87e 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_dbt_e.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_dbt_e.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define the Dingbats encoding vector.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_diskn.ps b/Master/tlpkg/tlgs/Resource/Init/gs_diskn.ps
index 825ff8d959c..383b91d74bc 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_diskn.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_diskn.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Initialization file for %disk device modifications
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_dps1.ps b/Master/tlpkg/tlgs/Resource/Init/gs_dps1.ps
index 50d9bfb75f6..e65b4de263b 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_dps1.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_dps1.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Initialization file for most of the Display PostScript functions
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_dps2.ps b/Master/tlpkg/tlgs/Resource/Init/gs_dps2.ps
index 0320644667e..4b54f2fba5e 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_dps2.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_dps2.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Initialization file for basic Display PostScript functions
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_dscp.ps b/Master/tlpkg/tlgs/Resource/Init/gs_dscp.ps
index 4ea3d4540f1..f2c66d912d2 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_dscp.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_dscp.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Postscript interface routines to DSC parser
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_epsf.ps b/Master/tlpkg/tlgs/Resource/Init/gs_epsf.ps
index fce2e2363bb..fbfe1107dad 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_epsf.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_epsf.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2022 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Allow the interpreter to encapsulate EPS files, to recognize MS-DOS
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_fapi.ps b/Master/tlpkg/tlgs/Resource/Init/gs_fapi.ps
index b0f748209d6..73d2fe8b751 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_fapi.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_fapi.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Redefine Font and CIDFont categories with FAPI-handeled fonts.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_fntem.ps b/Master/tlpkg/tlgs/Resource/Init/gs_fntem.ps
index 8904352deb2..a10a63d534a 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_fntem.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_fntem.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% A procset for Postscript font emulation
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps b/Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps
index b1206c46872..60782724c7b 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Font initialization and management code.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_frsd.ps b/Master/tlpkg/tlgs/Resource/Init/gs_frsd.ps
index 80d399101b7..22eb00d62ad 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_frsd.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_frsd.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Implementation of ReusableStreamDecode filter.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_icc.ps b/Master/tlpkg/tlgs/Resource/Init/gs_icc.ps
index 0bf8313fdc4..b6f04cc9fab 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_icc.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_icc.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% We need LanguageLevel 2 or higher in order to have setuserparams and
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_il1_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_il1_e.ps
index 35250233701..62728bf8cd3 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_il1_e.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_il1_e.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define the ISO Latin-1 encoding vector.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_img.ps b/Master/tlpkg/tlgs/Resource/Init/gs_img.ps
index 3750ad30285..70262a92ed1 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_img.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_img.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2002-2021 Artifex, Inc. All rights reserved.
+% Copyright (C) 2002-2023 Artifex, Inc. All rights reserved.
%
% This software is provided AS-IS with no warranty, either express or
% implied.
@@ -10,8 +10,8 @@
% 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., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861.
+% contact Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA.
% image, colorimage, and imagemask implementation
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_init.ps b/Master/tlpkg/tlgs/Resource/Init/gs_init.ps
index ffb36e734e5..43452132677 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_init.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_init.ps
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Initialization file for the interpreter.
@@ -34,7 +34,7 @@
% Interpreter library version number
% NOTE: the interpreter code requires that the first non-comment token
% in this file be an integer, and that it match the compiled-in version!
-10012
+10020
% Check the interpreter revision.
dup revision ne
@@ -892,7 +892,7 @@ currentdict /.makeinternaldict .undef
/write= {
1 index exch write=only (\n) writestring
} bind def
-/=only { (%stdout) (w) file exch write=only } bind def
+/=only { (%stdout) (w) file exch write=only } bind odef
/= { =only (\n) print } bind def
/=print /=only load def
% Temporarily define == as = for the sake of runlibfile0.
@@ -1012,12 +1012,13 @@ currentdict /runlibfile0 .undef
(; OffendingCommand: ) print =only ( ]%%) =
}
{ (Unrecoverable error: ) print =only flush
- ( in ) print = flush
+ ( in ) print =only flush
count 2 gt
{ (Operand stack:\n ) print
count 1 sub -1 2 { ( ) print index =only flush } for
- () = flush
+ () =only
} if
+ (\n) =only flush
}
ifelse
-1 0 1 //ErrorNames length 1 sub
@@ -1089,7 +1090,7 @@ currentdict /.unstoppederrorhandler .undef
}
{
exch print exch % print heading. stack <==flag> <stack>
- 1 index not { () = } if
+ 1 index not { () =only } if
{ 1 index { (\n ) } { ( ) } ifelse print
dup type /dicttype eq
{
@@ -1128,7 +1129,7 @@ currentdict /.unstoppederrorhandler .undef
errorname /VMerror eq
{ (VM status:) print mark vmstatus
counttomark { ( ) print counttomark -1 roll dup =only } repeat
- cleartomark () =
+ cleartomark () =only
} if
.languagelevel 2 ge
@@ -1139,8 +1140,8 @@ currentdict /.unstoppederrorhandler .undef
.oserrno dup 0 ne
{ (Last OS error: ) print
errorname /VMerror ne
- { dup .oserrorstring { = pop } { = } ifelse }
- { = }
+ { dup .oserrorstring { =only pop } { =only } ifelse }
+ { =only }
ifelse
}
{ pop
@@ -2407,6 +2408,15 @@ currentdict /.locksafeglobal .undef
%% ---------------- SAFER stuff END -------------------%%
+/UndefinePostScriptFilters {
+ [
+ /BCPEncode /TBCPEncode /PNGPredictorEncode /PNGPredictorDecode /PixelDifferenceDecode /PixelDifferenceEncode
+ /zlibEncode /zlibDecode /PWGDecode /eexecEncode /ArcfourEncode /PSStringEncode /BCPDecode
+ /OLDPDF where {/OLDPDF get not {/SHA256Encode /MD5Encode /AESDecode /JPXDecode /JBIG2Decode /ArcfourDecode /.EOFDecode} if} if
+ ]
+ {filterdict exch undef} forall
+} .bind executeonly def
+
/UndefinePostScriptOperators {
% This list is of operators which no longer appear to be used, and which we do not believe
% to have any real use. For now we will undefine the operstors so they cannot easily be used
@@ -2444,10 +2454,10 @@ currentdict /.locksafeglobal .undef
/.getshowoperator /.getnativefonts /.beginform /.endform /.get_form_id /.repeatform /.reusablestream /.rsdparams
/.buildfunction /.sethpglpathmode /.currenthpglpathmode
/.currenthalftone /.sethalftone5 /.image1 /.imagemask1 /.image3 /.image4
- /.getiodevice /.getdevparms /.putdevparams /.bbox_transform /.matchmedia /.matchpagesize /.defaultpapersize
+ /.getiodevice /.getdevparms /.putdevparams
+ /.matchmedia /.matchpagesize /.defaultpapersize
/.oserrno /.setoserrno /.oserrorstring /.getCPSImode
/.getscanconverter /.setscanconverter /.type1encrypt /.type1decrypt/.languagelevel /.setlanguagelevel /.eqproc /.fillpage
- /.saslprep
/.shfill /.argindex /.bytestring /.namestring /.stringbreak /.stringmatch /.globalvmarray /.globalvmdict /.globalvmpackedarray /.globalvmstring
/.localvmarray /.localvmdict /.localvmpackedarray /.localvmstring /.systemvmarray /.systemvmdict /.systemvmpackedarray /.systemvmstring /.systemvmfile /.systemvmlibfile
/.systemvmSFD /.settrapparams /.currentsystemparams /.currentuserparams /.getsystemparam /.getuserparam /.setsystemparams /.setuserparams
@@ -2545,6 +2555,7 @@ currentdict /.locksafeglobal .undef
]
{statusdict exch .forceundef} forall
+ //systemdict /UndefinePostScriptFilters .forceundef
//systemdict /UndefinePostScriptOperators .forceundef
} .bind executeonly def % must be bound and hidden for .forceundef
@@ -2565,6 +2576,7 @@ currentdict /.locksafeglobal .undef
SAFER {
//systemdict /SAFERUndefinePostScriptOperators get exec
} if
+ //systemdict /UndefinePostScriptFilters get exec
//systemdict /UndefinePostScriptOperators get exec
//systemdict /.forcecopynew .forceundef % remove temptation
//systemdict /.forceput .forceundef % ditto
@@ -2652,6 +2664,7 @@ FontDirectory readonly pop
% If we are using DELAYBIND we have to defer the undefinition
% until .bindnow.
DELAYBIND not {
+ //systemdict /UndefinePostScriptFilters get exec
//systemdict /UndefinePostScriptOperators get exec
} if
end
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_lev2.ps b/Master/tlpkg/tlgs/Resource/Init/gs_lev2.ps
index ecd49370f1c..287202250b8 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_lev2.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_lev2.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Initialization file for Level 2 functions.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_ll3.ps b/Master/tlpkg/tlgs/Resource/Init/gs_ll3.ps
index 00ec8bca24f..8da9d41501c 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_ll3.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_ll3.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Initialization file for PostScript LanguageLevel 3 functions.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_mex_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_mex_e.ps
index cced43b3d11..255e9d01ace 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_mex_e.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_mex_e.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define the MacExpert encoding vector.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_mgl_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_mgl_e.ps
index b437285b7d9..e154586e855 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_mgl_e.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_mgl_e.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% $Id: gs_mgl_e.ps 8954 2008-08-08 04:22:38Z ray $
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_mro_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_mro_e.ps
index e476322ba39..d683952d7da 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_mro_e.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_mro_e.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% $Id: gs_mro_e.ps 8954 2008-08-08 04:22:38Z ray $
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_pdf_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_pdf_e.ps
index 2d3ec9ffc05..a84740690c3 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_pdf_e.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_pdf_e.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define the PDFDoc encoding vector.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_pdfwr.ps b/Master/tlpkg/tlgs/Resource/Init/gs_pdfwr.ps
index a04d9e35053..9a165719fe3 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_pdfwr.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_pdfwr.ps
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% PDF writer additions to systemdict.
@@ -103,6 +103,7 @@ languagelevel 2 .setlanguagelevel
/UsePrologue //false
/PassThroughJPEGImages //true
/PassThroughJPXImages //true
+ /PSPageOptionsWrap //true
.dicttomark readonly def
/.distillersettings mark
@@ -847,6 +848,7 @@ currentdict /.pdf_hook_DSC_Creator undef
/PassThroughJPXImages { }
/PSDocOptions { }
/PSPageOptions { }
+ /PSPageOptionsWrap { }
/AlwaysOutline { }
/NeverOutline { }
.dicttomark readonly def
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_res.ps b/Master/tlpkg/tlgs/Resource/Init/gs_res.ps
index 7316e32ed32..4fa65c386ab 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_res.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_res.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Initialization file for Level 2 resource machinery.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_resmp.ps b/Master/tlpkg/tlgs/Resource/Init/gs_resmp.ps
index a7eb70fcafe..f5c5b091b56 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_resmp.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_resmp.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% A procset to redefine a resource category with a resource map.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_setpd.ps b/Master/tlpkg/tlgs/Resource/Init/gs_setpd.ps
index 8d00da5f198..782f9b23ee4 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_setpd.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_setpd.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% The current implementation of setpagedevice has the following limitations:
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_statd.ps b/Master/tlpkg/tlgs/Resource/Init/gs_statd.ps
index 6751c032908..35a512aadfd 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_statd.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_statd.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% This file provides statusdict, serverdict, and assorted LaserWriter
@@ -42,7 +42,7 @@ statusdict begin
% Keep the table of named paper sizes as procedures. Reuse them later
% as compatibility operators.
-/.pagetypeprocs 70 dict begin
+/.pagetypeprocs 81 dict begin
% Define various paper formats. The Adobe documentation defines only these:
% 11x17, a3, a4, a4small, b5, ledger, legal, letter, lettersmall, note.
@@ -116,6 +116,11 @@ statusdict begin
/archC {1296 1728 //.setpagesize stopped { pop pop /archC $error /errorname get signalerror } if } bind def
/archB {864 1296 //.setpagesize stopped { pop pop /archB $error /errorname get signalerror } if } bind def
/archA {648 864 //.setpagesize stopped { pop pop /archA $error /errorname get signalerror } if } bind def
+ /archa /archA load def
+ /archb /archB load def
+ /archc /archC load def
+ /archd /archD load def
+ /arche /archE load def
% Other paper sizes
/flsa {612 936 //.setpagesize stopped { pop pop /flsa $error /errorname get signalerror } if } bind def % U.S. foolscap
/flse {612 936 //.setpagesize stopped { pop pop /flse $error /errorname get signalerror } if } bind def % European foolscap
@@ -132,6 +137,12 @@ statusdict begin
/ANSI_D {1585 2448 //.setpagesize stopped { pop pop /ANSI_D $error /errorname get signalerror } if } bind def
/ANSI_E {2448 3168 //.setpagesize stopped { pop pop /ANSI_E $error /errorname get signalerror } if } bind def
/ANSI_F {2016 2880 //.setpagesize stopped { pop pop /ANSI_F $error /errorname get signalerror } if } bind def
+ /ansi_a /ANSI_A load def
+ /ansi_b /ANSI_B load def
+ /ansi_c /ANSI_C load def
+ /ansi_d /ANSI_D load def
+ /ansi_e /ANSI_E load def
+ /ansi_f /ANSI_F load def
%END SIZES
currentdict end
userdict begin dup { def } forall end % reuse!
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_std_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_std_e.ps
index c696b714fc7..89f8b88a93a 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_std_e.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_std_e.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define the standard encoding vector.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_sym_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_sym_e.ps
index e6c58f6fa5c..bc76d4bd41d 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_sym_e.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_sym_e.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define the Symbol encoding vector.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_trap.ps b/Master/tlpkg/tlgs/Resource/Init/gs_trap.ps
index 9a089eef737..ea8f72a73b8 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_trap.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_trap.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% PostScript LanguageLevel 3 in-RIP trapping support.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps b/Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps
index 4fcbd69c28e..8666d787395 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_ttf.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Support code for direct use of TrueType fonts.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_typ32.ps b/Master/tlpkg/tlgs/Resource/Init/gs_typ32.ps
index 4c2035c70ad..1263f4ef904 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_typ32.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_typ32.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Initialization file for Type 32 fonts.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_typ42.ps b/Master/tlpkg/tlgs/Resource/Init/gs_typ42.ps
index a3bb97952c7..e689f3def1e 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_typ42.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_typ42.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Type 42 font support code.
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_type1.ps b/Master/tlpkg/tlgs/Resource/Init/gs_type1.ps
index ef36509377f..f17a3f11b6e 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_type1.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_type1.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2022 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Type 1 font support code.
@@ -75,9 +75,10 @@
% 16 bytes is arbitrary, but should be large enough to hold any "uniXXXX" style name
//ReverseAdobeGlyphList //AdobeGlyphList 3 -1 roll
% scratch(string) RAGL(dict) AGL(dict) CharStrings(dict)
- dup
- { % scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) gname cstring
- exch dup % scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) cstring gname gname
+ [ 1 index {pop} forall ] % scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) [ glyph names ]
+ { % scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) gname
+ 1 index 1 index get % scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) cstring gname
+ exch dup
4 index exch .knownget
{ //true}
{ % scratch(string) RAGL(dict) AGL(dict) CharStrings(dict) cstring gname
@@ -86,7 +87,7 @@
{
% if we couldn't derive the code point from the AGL, we might derive it
% from a formatted "uniXXXX" name.
- dup <00000000000000000000000000000000> cvs dup flush (uni) anchorsearch
+ dup (0000000000000000) cvs dup (uni) anchorsearch
{
% as luck would have it, we can just replace the "uni" with "16#"
% to get something we can convert to a number
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_wan_e.ps b/Master/tlpkg/tlgs/Resource/Init/gs_wan_e.ps
index fe821352936..add20edcc74 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_wan_e.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_wan_e.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define the WinAnsi encoding vector.
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_base.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_base.ps
deleted file mode 100644
index 87b9650d8c1..00000000000
--- a/Master/tlpkg/tlgs/Resource/Init/pdf_base.ps
+++ /dev/null
@@ -1,1474 +0,0 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
-% 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.
-%
-% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
-%
-
-% pdf_base.ps
-% Basic parser for PDF reader.
-
-% This handles basic parsing of the file (including the trailer
-% and cross-reference table), as well as objects, object references,
-% streams, and name/number trees; it doesn't include any facilities for
-% making marks on the page.
-
-/.setlanguagelevel where { pop 2 .setlanguagelevel } if
-.currentglobal //true .setglobal
-pdfdict begin
-
-% Define the name interpretation dictionary for reading values.
-/valueopdict mark
- (<<) cvn { mark } bind executeonly % don't push an actual mark!
- (>>) cvn { { .dicttomark } stopped {
- ( **** Error: File has an unbalanced >> \(close dictionary\).\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } if
- } bind executeonly
- ([) cvn { mark } bind executeonly % ditto
- (]) cvn dup load
-% /true true % see .pdfexectoken below
-% /false false % ibid.
-% /null null % ibid.
- /F dup cvx % see Objects section below
- /R dup cvx % see Objects section below
- /stream dup cvx % see Streams section below
-.dicttomark readonly def
-
-% ------ Utilities ------ %
-
-% Define a scratch string. The PDF language definition says that
-% no line in a PDF file can exceed 255 characters, but this string
-% is also used to search for %PDF-, which needs 1024 characters.
-/pdfstring 1024 string def
-
-% Handle the PDF 1.2 #nn escape convention when reading from a file.
-% This should eventually be done in C.
-/.pdffixname { % <execname> .pdffixname <execname'>
- PDFversion 1.2 ge {
- dup .namestring (#) search {
- name#escape cvn exch pop
- } {
- pop
- } ifelse
- } if
-} bind executeonly def
-/name#escape % <post> <(#)> <pre> name#escape <string>
-{ exch pop
- 1 index 2 () /SubFileDecode filter dup (x) readhexstring
- % Stack: post pre stream char t/f
- not { % tolerate, but complain about bad syntax
- pop closefile (#) concatstrings exch
- ( **** Error: Invalid hex following '#' name escape, using literal '#' in name.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } {
- exch closefile concatstrings
- exch 2 1 index length 2 sub getinterval
- } ifelse
- (#) search { name#escape } if concatstrings
-} bind executeonly def
-
-/num-chars-dict mark (0123456789-.) {dup} forall .dicttomark readonly def
-
-% Execute a file, interpreting its executable names in a given
-% dictionary. The name procedures may do whatever they want
-% to the operand stack.
-/.pdftokenerror { % <count> <opdict> <errtoken> .pdftokenerror -
- % if we're called prior to actually drawing the page contents
- % (i.e. for pageusestransparency) BXlevel may not be defined, yet.
- /BXlevel where {/BXlevel get 0 le}{//true} ifelse
- {
- ( **** Error: Unknown operator: ') pdfformaterror
- dup =string cvs pdfformaterror
- (') pdfformaterror
- % Attempt a retry scan of the element after changing to PDFScanInvNum
- << /PDFScanInvNum //true >> setuserparams
- =string cvs
- token pop exch pop dup type
- dup /integertype eq exch /realtype eq or {
- exch pop exch pop
- (, processed as number, value: ) pdfformaterror
- dup =string cvs pdfformaterror (\n) pdfformaterror
- << /PDFScanInvNum //null >> setuserparams % reset to default scanning rules
- //false % suppress any stack cleanup
- } {
- % error was non-recoverable with modified scanning rules, continue.
- dup type /nametype eq {
- //true 1 index .namestring {
- //num-chars-dict exch known and
- } forall { % perhaps, it's a malformed number.
- PDFSTOPONERROR {//true}{
- pop pop pop 0 //false
- ( looks like a malformed number, replacing with 0.) pdfformaterror
- } ifelse
- } {
- //true % punt
- } ifelse
- } {
- //true % punt
- } ifelse
- (\n) pdfformaterror
- } ifelse
- } {
- //true
- } ifelse
- { % clean up the operand stack if this was non-recoverable
- pop pop count exch sub { pop } repeat % pop all the operands
- } if
- ( Output may be incorrect.\n) pdfformaterror
-} bind executeonly def
-
-currentdict /num-chars-dict .undef
-
-/.pdfexectoken { % <count> <opdict> <exectoken> .pdfexectoken ?
- PDFDEBUG {
- //pdfdict /PDFSTEPcount known not { //pdfdict /PDFSTEPcount 1 .forceput } executeonly if
- PDFSTEP {
- //pdfdict /PDFtokencount 2 copy .knownget { 1 add } { 1 } ifelse .forceput
- PDFSTEPcount 1 gt {
- //pdfdict /PDFSTEPcount PDFSTEPcount 1 sub .forceput
- } executeonly
- {
- dup ==only
- ( step # ) print PDFtokencount =only
- ( ? ) print flush 1 //false .outputpage
- (%stdin) (r) file 255 string readline {
- token {
- exch pop //pdfdict /PDFSTEPcount 3 -1 roll .forceput
- } executeonly
- {
- //pdfdict /PDFSTEPcount 1 .forceput
- } executeonly ifelse % token
- } {
- pop /PDFSTEP //false def % EOF on stdin
- } ifelse % readline
- } ifelse % PDFSTEPcount > 1
- } executeonly
- {
- dup ==only () = flush
- } ifelse % PDFSTEP
- } executeonly if % PDFDEBUG
- 2 copy .knownget {
- exch pop exch pop exch pop exec
- } {
- % Normally, true, false, and null would appear in opdict
- % and be treated as "operators". However, there is a
- % special fast case in the PostScript interpreter for names
- % that are defined in, and only in, systemdict and/or
- % userdict: putting these three names in the PDF dictionaries
- % destroys this property for them, slowing down their
- % interpretation in all PostScript code. Therefore, we
- % check for them explicitly here instead.
- dup dup dup /true eq exch /false eq or exch /null eq or {
- exch pop exch pop //systemdict exch get
- } {
- % Hackish fix to detect missing whitespace after "endobj". Yet another
- % problem that (you guessed it!) Adobe Acrobat ignores silently
- dup .namestring (endobj) anchorsearch {
- ( **** Error: Missing whitespace after 'endobj'.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop pop pop exch pop /endobj get exec
- } {
- %% First, lets try and see if this 'might' be a broken number
- %% we look for 0-9 as well as '.' ',' and '-' to permit those
- %% locales in which the separator is a comma, as well as negative
- %% numbers. We've seena t least one tool replace '0' with '-' *sometimes*
- //true exch
- dup length 1 sub 0 1 3 -1 roll {
- 1 index exch get
- dup 44 lt {
- pop exch pop //false exch exit
- }{
- dup 57 gt {
- pop exch pop //false exch exit
- }{
- dup 47 eq {
- pop exch pop //false exch exit
- }{
- pop
- } ifelse
- } ifelse
- } ifelse
- } for
- pop
- {
- %% If it looks like a number, try to deal with it as such
- PDFSTOPONERROR {
- dup .pdftokenerror
- }{
- dup {.pdftokenerror} stopped
- } ifelse
- { pop
- %% But if it fails, fall back to converting into a anem.
- %% This will propagate through and cause different
- %% fallback code to try and take care ot if.
- cvlit exch pop exch pop
- }{
- exch pop
- } ifelse
- }{
- %% Doesn't look like a number, convert it into a name
- cvlit exch pop exch pop
- } ifelse
- } ifelse
- } ifelse
- } ifelse
-} bind executeonly def
-/PDFScanRules_true << /PDFScanRules //true >> def
-/PDFScanRules_null << /PDFScanRules //null >> def
-/.pdfrun { % <file> <opdict> .pdfrun -
- % Construct a procedure with the stack depth, file and opdict
- % bound into it.
- 1 index cvlit % file <<>> file
- count 2 sub % file <<>> file cnt
- 3 1 roll mark % file cnt <<>> file [
- /PDFScanRules .getuserparam //null eq {
- //PDFScanRules_true { setuserparams } 0 get % force PDF scanning mode
- mark 7 4 roll
- } {
- mark 5 2 roll % file [ [ cnt <<>> file
- } ifelse
- { % Stack: ..operands.. count opdict file
- { token } stopped {
- dup type /filetype eq { pop } if
- pop pop stop
- } if {
- dup type /nametype eq {
- dup xcheck {
- .pdfexectoken
- } {
- .pdffixname
- exch pop exch pop PDFDEBUG {
- PDFSTEPcount 1 le {
- dup ==only ( ) print flush
- } if
- } if
- } ifelse
- } {
- exch pop exch pop PDFDEBUG {
- PDFSTEPcount 1 le {
- dup ==only ( ) print flush
- } if
- } if
- } ifelse
- } {
- pop pop exit
- } ifelse
- }
- aload pop //.packtomark exec cvx % file [ {cnt <<>> file ... }
- { loop } 0 get 2 packedarray cvx % file [ { {cnt <<>> file ... } loop }
- PDFSTOPONERROR { {exec //false} } { {stopped} } ifelse
- aload pop % file [ { {cnt <<>> file ... } loop } stopped
- /PDFScanRules .getuserparam //null eq {
- //PDFScanRules_null { setuserparams } 0 get % reset PDF scannig mode if it was off
- } if
- /PDFsource PDFsource % file [ { {cnt <<>> file ... } loop } stopped /PDFsource PDFsource
- { store {
- /StreamRunAborted //true store
- ( **** Error reading a content stream. The page may be incomplete.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } if
- } aload pop % file [ { {cnt <<>> file ... } loop } stopped /PDFsource PDFsource store {...} if
- //.packtomark exec cvx % file { { {cnt <<>> file ... } loop } stopped /PDFsource PDFsource store {...} if}
- /PDFsource 3 -1 roll store % {...}
- exec
-} bind executeonly def
-
-% Execute a file, like .pdfrun, for a marking context.
-% This temporarily rebinds LocalResources and DefaultQstate.
-/.pdfruncontext { % <resdict> <file> <opdict> .pdfruncontext -
- /.pdfrun load LocalResources DefaultQstate % res file op .pdfrun Loc Qst
- /LocalResources 7 -1 roll % file op .pdfrun Loc Qst /Loc res
- dup 4 index ne { % Ensure Loc != res to avoid self-referencing /ParentResources
- dup /ParentResources 5 index put % save the parent LocalResources
- } if
- store % store new LocalResources
- /DefaultQstate qstate store
- 3 .execn
- /DefaultQstate exch store
- /LocalResources exch store
-} bind executeonly def
-
-% Get the depth of the PDF operand stack. The caller sets pdfemptycount
-% before calling .pdfrun or .pdfruncontext. It is initially set by
-% pdf_main, and is also set by any routine which changes the operand
-% stack depth (currently .pdfpaintproc, although there are other callers
-% of .pdfrun{context} which have not been checked for opstack depth.
-/.pdfcount { % - .pdfcount <count>
- count pdfemptycount sub
-} bind executeonly def
-
-% Read a token, but simply return false (no token read) in the case of an
-% error. This is messy because 'token' either may or may not pop its operand
-% if an error occurs, and because the return values are different depending
-% on whether the source is a file or a string. To avoid closing the file
-% check for '{' before trying 'token'.
-/token_nofail_dict mark
- ( ) { dup ( ) readstring pop pop } bind executeonly
- (\t) 1 index
- (\r) 1 index
- (\n) 1 index
- (\000) 1 index
- ({) { //null //true exit } bind executeonly
-.dicttomark def
-
-/token_nofail { % <file|string> token_nofail false
- % <file> token_nofail <token> true
- % <string> token_nofail <post> <token> true
- dup type /filetype eq {
- { dup ( ) .peekstring not { ({) } if
- //token_nofail_dict exch .knownget not {
- //null 1 index { token } //.internalstopped exec exit
- } if
- exec
- } loop
- { % stack: source null [source]
- //null ne { pop } if pop //false
- } { % stack: source null ([post] token true | false)
- { 3 1 roll pop pop //true }
- { pop pop //false }
- ifelse
- } ifelse
- } {
- //null 1 index % stack: source null source
- { token } //.internalstopped exec { % stack: source null [source]
- //null ne { pop } if pop //false
- } { % stack: source null ([post] token true | false)
- { 4 2 roll pop pop //true }
- { pop pop //false }
- ifelse
- } ifelse
- } ifelse
-} bind executeonly def
-
-currentdict /token_nofail_dict .undef
-
-% ================================ Objects ================================ %
-
-% We keep track of PDF objects using the following PostScript variables:
-%
-% Generations (string): Generations[N] holds 1+ the current
-% generation number for object number N. (As far as we can tell,
-% this is needed only for error checking.) For free objects,
-% Generations[N] is 0.
-%
-% Objects (array): If object N is loaded, Objects[N] is the actual
-% object; otherwise, Objects[N] is an executable integer giving
-% the file offset of the object's location in the file. If
-% ObjectStream[N] is non-zero then Objects[N] contains the index
-% into the object stream instead of the file offset of the object.
-%
-% ObjectStream (array): If object N is in an object stream then
-% ObjectStream[N] holds the object number of the object stream.
-% Otherwise ObjectStream[N] contains 0. If ObjectStream[N]
-% is non-zero then Objects[N] contains the index into the object
-% stream.
-%
-% GlobalObjects (dictionary): If object N has been resolved in
-% global VM, GlobalObjects[N] is the same as Objects[N]
-% (except that GlobalObjects itself is stored in global VM,
-% so the entry will not be deleted at the end of the page).
-%
-% IsGlobal (string): IsGlobal[N] = 1 iff object N was resolved in
-% global VM. This is an accelerator to avoid having to do a
-% dictionary lookup in GlobalObjects when resolving every object.
-
-% Initialize the PDF object tables.
-/initPDFobjects { % - initPDFobjects -
- /ObjectStream 0 array def
- /Objects 0 array def
- /Generations 0 string def
- .currentglobal //true .setglobal
- /GlobalObjects 20 dict def
- .setglobal
- /IsGlobal 0 string def
-} bind executeonly def
-
-% Grow the tables to a specified size.
-/growPDFobjects { % <minsize> growPDFobjects -
- dup ObjectStream length gt {
- dup ObjectStream exch array dup 3 1 roll copy pop /ObjectStream exch def
- } if
- dup Objects length gt {
- dup Objects exch array dup 3 1 roll copy pop /Objects exch def
- } if
- dup Generations length gt {
- %% Initiallly Generations is a string, but the xref rebuilding code
- %% can convert it to an array (/setxrefentry in pdf_rbld.ps). So we
- %% need to be able to deal with either case.
- Generations type /stringtype eq {
- dup Generations exch string dup 3 1 roll copy pop /Generations exch def
- } {
- dup Generations exch array dup 3 1 roll copy pop /Generations exch def
- } ifelse
- } if
- dup IsGlobal length gt {
- dup IsGlobal exch string dup 3 1 roll copy pop /IsGlobal exch def
- } if
- pop
-} bind executeonly def
-
-% We represent an unresolved object reference by a procedure of the form
-% {obj# gen# resolveR}. This is not a possible PDF object, because PDF has
-% no way to represent procedures. Since PDF in fact has no way to represent
-% any PostScript object that doesn't evaluate to itself, we can 'force'
-% a possibly indirect object painlessly with 'exec'.
-% Note that since we represent streams by executable dictionaries
-% (see below), we need both an xcheck and a type check to determine
-% whether an object has been resolved.
-/resolved? { % <object#> resolved? <value> true
- % <object#> resolved? false
- Objects 1 index get dup xcheck { % Check if executable
- dup type /integertype eq { % Check if an integer
- % Check whether the object is in GlobalObjects.
- pop IsGlobal 1 index get 0 eq { % 0 --> Not in GlabalObjects
- pop //false % The object is not resolved
- } { % The object is in GlobalObjects
- % Update Objects from GlobalObjects
- PDFDEBUG { (%Global=>local: ) print dup //== exec } if
- GlobalObjects 1 index get dup Objects 4 1 roll put //true
- } ifelse
- } { % Else object is executable but not integer
- exch pop //true % Therefore must be executable dict. (stream)
- } ifelse
- } { % Else object is not executable.
- exch pop //true % Therefore it must have been resolved.
- } ifelse
-} bind executeonly def
-/oforce /exec load def
-/oget { % <array> <index> oget <object>
- % <dict> <key> oget <object>
- % Before release 6.20, this procedure stored the resolved
- % object back into the referring slot. In order to support
- % PDF linearization, we no longer do this.
- get oforce
-} bind executeonly def
-
-/oforce_array { % <array> oforce_array <array>
- [ exch { oforce } forall ]
-} bind executeonly def
-
-/oforce_elems { % <array> oforce_elems <first> ... <last>
- { oforce } forall
-} bind executeonly def
-
-%% Safe recursion maintain a dicitonary in which we record all the object numbers
-%% of objects which we resolve. Whenever it resolves a new one, it checks all the
-%% existing ones to see if its already present, in which case we assume recursion
-%% has taken place. Whenever this procedure calls itself it copies the existing
-%% dictionary, and throws it away afterwards. This means that we won't falsely
-%% detect recursion if two elements at the same level indirect to the same
-%% object.
-/safe_recursive { % <<recursion dict>> <any> oforce_recursive <recursion dict> <any>
- dup type dup /arraytype eq exch /packedarraytype eq or {
- dup rcheck { % protect tint transform functions, etc.
- dup length 3 eq {
- dup 2 get /resolveR eq {
- dup 0 get % <recursion dict> {x y resolveR} x
- dup % <recursion dict> {x y resolveR} x x
- 3 index exch known {
- ( **** Error: detected circular reference in object number ) pdfformaterror pdfstring cvs pdfformaterror
- (\n) pdfformaterror
- pop //null
- } {
- dup 3 index % <recursion dict> {x y resolveR} x x <recursion dict>
- 3 1 roll put % <recursion dict> {x y resolveR}
- } ifelse
- } if
- } if
- oforce % but dereference {1 0 R}
- dup type dup /arraytype eq exch /packedarraytype eq or {
- [ exch {
- counttomark 1 add index <<>> copy % create a copy for the recursion
- exch safe_recursive exch
- pop % pop the dictionary created for this level
- } forall
- ]
- } {
- dup type /dicttype eq {
- << exch 2 index <<>> copy exch { 3 -1 roll exch safe_recursive 3 -1 roll oforce 3 1 roll exch } forall pop>>
- } if
- } ifelse
- } if
- } {
- dup type /dicttype eq {
- << exch 2 index <<>> copy exch { 3 -1 roll exch safe_recursive 3 -1 roll oforce 3 1 roll exch } forall pop>>
- } if
- } ifelse
-} bind executeonly def
-
-/oforce_recursive {
- << >> exch safe_recursive exch pop
-} bind executeonly def
-
-% A null value in a dictionary is equivalent to an omitted key;
-% we must check for this specially.
-/knownoget { % <dict> <key> knownoget <value> true
- % <dict> <key> knownoget false
- % See oget above regarding this procedure.
- .knownget {
- oforce dup //null eq { pop //false } { //true } ifelse
- } {
- //false
- } ifelse
-} bind executeonly def
-
-% See /knownoget above.
-/oknown { % <dict> <key> oknown <bool>
- .knownget { oforce //null ne } { //false } ifelse
-} bind executeonly def
-
-/knownogetdict { % <dict> <key> knownogetdict <dict> true
- % <dict> <key> knownogetdict false
- //knownoget exec dup {
- 1 index type /dicttype ne { pop pop //false } if
- } if
-} bind executeonly def
-
-% PDF 1.1 defines a 'foreign file reference', but not its meaning.
-% Per the specification, we convert these to nulls.
-/F { % <file#> <object#> <generation#> F <object>
- % Some PDF 1.1 files use F as a synonym for f!
- .pdfcount 3 lt { f } { pop pop pop //null } ifelse
-} bind executeonly def
-
-% Verify the generation number for a specified object
-% Note: The values in Generations is the generation number plus 1.
-% If the value in Generations is zero then the object is free.
-/checkgeneration { % <object#> <generation#> checkgeneration <object#> <OK>
- Generations 2 index get 1 sub 1 index eq { % If generation # match ...
- pop //true % Then return true
- } { % Else not a match ...
- QUIET not { % Create warning message if not QUIET
- Generations 2 index get 0 eq { % Check if object is free ...
- ( **** Warning: reference to free object: )
- 2 index =string cvs concatstrings ( ) concatstrings % put obj #
- exch =string cvs concatstrings ( R\n) concatstrings % put gen #
- } {
- ( **** Warning: wrong generation: )
- 2 index =string cvs concatstrings ( ) concatstrings % put obj #
- exch =string cvs concatstrings % put gen #
- (, xref gen#: ) concatstrings 1 index Generations % put xref gen #
- exch get 1 sub =string cvs concatstrings (\n) concatstrings
- } ifelse
- pdfformatwarning % Output warning message
- } { % Else QUIET ...
- pop % Pop generation number
- } ifelse
- % We should return false for an incorrect generation number, however
- % we are simply printing a warning and then returning true. This makes
- % Ghostscript tolerant of of bad generation numbers.
- //true
- } ifelse
-} bind executeonly def
-/R { % <object#> <generation#> R <object>
- %% Parameter validation; this should not be required but we have found files
- %% (Bug 697351) which are corrupted in ways that mean we see a 'R' in a stream
- %% even though it is not an indirect object reference. Because a stream
- %% may reference objetcs which have not been resolved, we cannot simply
- %% 'undef' teh R operator, the only solution is to have it chekc the
- %% types of its operands. This is poterntially slow of course, we may
- %% need to remove this in future if the performance penalty is too great.
- %% We cannot slow down all files significantly purely to work-around
- %% files which are invalid.
- 1 index type /integertype eq 1 index type /integertype eq and {
- /resolveR cvx 3 packedarray cvx
- } {
- ( **** Error: indirect object reference \(R\) encountered with invalid arguments.) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
-} bind executeonly def
-
-% If we encounter an object definition while reading sequentially,
-% we just store it away and keep going.
-/objopdict mark
- valueopdict { } forall
- /endobj dup cvx
-.dicttomark readonly def
-
-/obj { % <object#> <generation#> obj <object>
- PDFfile objopdict .pdfrun
-} bind executeonly def
-
-/endobj { % <object#> <generation#> <object> endobj <object>
-
- %% If we have a stream wioth a broken endstream we can get here without
- %% an object definition on nthe stack. If we simply pop the 'extraneous'
- %% data we will break the stream definition and throw an error. So we look
- %% to see if this appears to be this specific case.
- 2 index type /marktype eq 2 index type /marktype eq or {
- {
- dup type /marktype eq {
- exit
- }{
- pop
- }if
- }loop
- }{
- {
- 2 index type /integertype ne 2 index type /integertype ne or {
- count 3 gt {
- ( **** Error: obj definition followed by multiple tokens, attempting to recover.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop
- } {
- //null
- ( **** Error: ignoring obj followed by multiple tokens.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- exit
- } ifelse
- } {
- exit
- } ifelse
- } loop
-
- 3 1 roll
- % Read the xref entry if we haven't yet done so.
- % This is only needed for generation # checking.
- 1 index resolved? {
- pop
- } if
- checkgeneration {
- % The only global objects we bother to save are
- % (resource) dictionaries.
- 1 index dup gcheck exch type /dicttype eq and {
- PDFDEBUG { (%Local=>global: ) print dup //== exec } if
- GlobalObjects 1 index 3 index put
- IsGlobal 1 index 1 put
- } if
- Objects exch 2 index put
- } {
- pop pop //null
- } ifelse
- }ifelse
-} bind executeonly def
-
-% When resolving an object reference in an object stream, we stop at
-% the end of file. Note: Objects in an object stream do not have either
-% a starting 'obj' or and ending 'endobj'.
-/resolveobjstreamopdict mark
- valueopdict { } forall
- (%%EOF) cvn { exit } bind executeonly
- /endobj { % bug 689795
- ( **** Error: Objects in an object stream should not have 'endobj'.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } bind executeonly
-.dicttomark readonly def
-
-% Note: This version of this function is not currently being used.
-% Resolve all objects in an object stream
-/resolveobjectstream { % <object stream #> resolveobjectstream -
- PDFDEBUG { (%Resolving object stream: ) print } if
- 0 resolveR % Get the objectstream dict, all objstrms use 0 as the gen #
- dup /First get % Save location of first object onto the stack
- 1 index /N get % Save number of objects onto the stack
- 2 index //false resolvestream % Convert stream dict into a stream
- /ReusableStreamDecode filter % We need to be able to position stream
- % Objectstreams begin with list of object numbers and locations
- % Create two arrays to hold object numbers and stream location
- 1 index array % Array for holding object number
- 2 index array % Array for holding stream object location
- % Get the object numbers and locations.
- 0 1 5 index 1 sub { % Loop and collect obj # and locations
- % Stack: objstreamdict First N objectstream [obj#] [loc] index
- 2 index 1 index % Setup to put obj# into object number array
- 5 index token pop put % Get stream, then get obj# and put into array
- 1 index 1 index % Setup to put object loc into location array
- 5 index token pop put % Get stream, get obj loc and put into array
- pop % Remove loop index
- } for
- % Create a bytestring big enough for reading any object data
- % Scan for the size of the largest object
- 0 0 % Init max object size and previous location
- 2 index { % Loop through all object locations
- % Stack: ... maxsize prevloc currentloc
- dup 4 1 roll % Save copy of object location into stack
- exch sub % Object size = currentloc - prevloc
- .max % Determine maximum object size
- exch % Put max size under previous location
- } forall
- pop % Remove previous location
- .bigstring % Create bytestring based upon max obj size
- % Move to the start of the object data
- 3 index 6 index % Get objectstream and start of first object
- setfileposition % Move to the start of the data
- % Read the data for all objects except the last. We do
- % not know the size of the last object so we need to treat
- % it as a special case.
- 0 1 6 index 2 sub {
- dup 4 index exch get % Get our current object number
- % Stack: objstreamdict First N objectstream [obj#] [loc]
- % bytestring loopindex object#
- dup resolved? { % If we already have this object
- pop pop % Remove object and object number
- 1 add 2 index exch get % Get location of next object
- 6 index add 6 index exch % Form location of next object and get stream
- setfileposition % Move to the start of the next object data
- } { % Else this is a new object ...
- % We are going to create a string for reading the object
- 2 index 0 % use our working string
- % Determine the size of the object
- 5 index 4 index 1 add get % Get location of the next object
- 6 index 5 index get % Get location of this object
- sub % Size of object = next loc - this loc
- getinterval % Create string for reading object
- 6 index exch readstring pop % Read object
- /ReusableStreamDecode filter % Convert string into a stream
- resolveobjstreamopdict .pdfrun % Get PDF object
- Objects exch 2 index exch put % Put object into Objects array
- pop pop % Remove object # and loop index
- } ifelse
- } for
- pop pop % Remove our working string and loc array
- % Now read the last object in the object stream. Since it
- % is the last object, we can use the original stream and
- % terminate when we hit the end of the stream
- % Stack: objstreamdict First N objectstream [obj#]
- 2 index 1 sub get % Get our current object number
- dup resolved? not { % If we do not already have this object
- exch % Get our object stream
- resolveobjstreamopdict .pdfrun % Get PDF object
- Objects exch 2 index exch put % Put object into Objects array
- } if
- pop pop pop pop % Clear stack
-} bind executeonly def
-
-/no_debug_dict <<
- /PDFDEBUG //false
->> readonly def
-
-% Resolve all objects in an object stream
-/resolveobjectstream { % <object stream #> resolveobjectstream -
- PDFDEBUG { (%Resolving object stream: ) print } if
- dup 0 resolveR % Get the objectstream dict, all objstrms use 0 as the gen #
- dup /Type get /ObjStm ne { % Verify type is object stream
- ( **** Error: Incorrect Type in object stream dictionary.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- /resolveobjectstream cvx /typecheck signalerror
- } if
- dup /N get % Save number of objects onto the stack
- 1 index //false resolvestream % Convert stream dict into a stream
- /ReusableStreamDecode filter % We need to be able to position stream
- % Objectstreams begin with list of object numbers and locations
- 1 index array % Create array for holding object number
- % Get the object numbers
- 0 1 4 index 1 sub { % Loop and collect obj numbers
- % Stack: strm# objstreamdict N PDFDEBUG objectstream [obj#] loopindex
- 1 index 1 index % Setup to put obj# into object number array
- 4 index token pop put % Get stream, then get obj# and put into array
- 2 index token pop pop pop % Get stream, get obj loc and clear stack
- } for
- % Move to the start of the object data
- 1 index 4 index /First get % Get objectstream and start of first object
- setfileposition % Move to the start of the data
- % We disable PDFDEBUG while reading the data stream. We will
- % print the data later
- PDFDEBUG { //no_debug_dict begin } if
- % Read the data for all objects. We check to see if we get
- % the number of objects that we expect.
- % Stack: strm# objstreamdict N objectstream [obj#] PDFDEBUG
- /ResolveObjectStreamMark 3 -1 roll
- count 4 index add % Determine stack depth with objects
- 3 1 roll
- resolveobjstreamopdict .pdfrun % Get PDF objects
- count /ResolveObjectStreamMark CountToKey not {0} if
- 1 add index
- ne
- {
- count /ResolveObjectStreamMark CountToKey not {0} if
- 1 add index gt {
- ( **** Error: Incorrect object count in object stream (too many objects).\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } if
- % Its possible for us to end up here with a valid file. The way we work is to read the
- % stream and tokenise all the objects, but that assumes there will be delimiters or
- % whitespace between each object in the stream. We can easily think of cases where
- % that is not true; eg two consecutive numbers 123 456 would be tokenised as a
- % single number with the value 123456.
- % In this case we can use the approach below to read each object individually and
- % that will define the correct number of objects. After we've collected all the
- % objects we'll check the number of objects recovered again, and see if there
- % are still too few. We should probably raise an error in that case, but lets wait
- % until we see a case.
-
- % Having too many objects in an ObjStm is not illegal, dumb but not illegal. We can
- % recover from this, but its complicated. The extra object could be any of the ones
- % from the stream, the only way to find out is to process each object individually.
- % Unfortunately, my attempts to come up with a version of .pdfrun which only tokenised
- % one object got rapidly bogged down. So a new approach was needed.
- %
- % The idea is simple; turn the underlying file into a ReusableStream, then we can
- % reposition it. Build an array of the object offsets, reposition the file to the
- % start of each object in turn. For all except the last object, create a sub file
- % using SubFileDeocde with an empty string, and an EODCount which is the difference
- % between the offset of this object and the offset of the next.
- % For the last object we just read from the offset to the end of the stream.
- %
- % Then call .pdfrun on that sub file, or the main stream, which will tokenise all the
- % objects from that point onwards. Then discard all but the first object read.
- %
- % The complications arise from the fact that we need to end up with the objects on
- % the stack, in the right order, preceded by a mark, a count, and an array containing
- % all the object numbers.
-
- % First, discard everything we read up to now; we can reuse the 'mark' which was placed
- % by the preceding code to do this, as long as we remember to replace that 'mark'.
- % Handily this will leave the count and the array which contains the object numbers in place.
- /ResolveObjectStreamMark ClearToKey
-
- % Replace the 'mark' consumed by conttomark above, so that we match what the code following this error handling expects.
- /ResolveObjectStreamMark
-
- % copy the ObjStm dictionary and then copy the count of objects expected
- 4 index 4 index
-
- % Copy the ObjStm dictionary, and create a file from it
- 1 index //false resolvestream % Convert stream dict into a stream
-
- /ReusableStreamDecode filter % We need to be able to re-position the stream
-
- 1 index array % Create array for holding offsets
-
- % Get the object offsets, these are stored at teh start of the stream, interleaved
- % between the object numbers. We know reading these can't fail, because we've already
- % done this to create the array of object numbers, above.
- 0 1 % starting index (0), increment (1) for loop
- 4 index 1 sub % limit of loop is object count-1 (because we start at 0)
- {
- 1 index 1 index % copy array and index
- 4 index % copy the file object
- token pop pop % read a token (object number) and discard it
- 4 index token % read another token (offset)
- pop put pop % put the offset into the array at the new index
- } for
-
- % We now have an array with all the object offsets in it
- % So we need to reposition the file to the start of each object and read
- % from that point. We use the difference between two offsets to setup
- % a SubFileDecode filter to only read as many bytes as there are
- % between the objects. Normally this should result in us reading one object,
- % if there are extra objects then we'll discard the extras. By doing this
- % we avoid tokenising the same data multiple times.
-
- % Set the loop to be from 0 to the number of objects minus 1 (starts from 0), step 1.
- 2 index 1 sub 0 1 3 -1 roll
- {
- dup % copy the loop index
- 2 index length 2 sub lt % Check if index + 1 exceeds array size (it will on last iteration)
-
- { % Not the last iteration
- dup % copy the loop index
- 2 index exch get 5 index /First get add % get the object offset, and add the value of First from the dictionary.
- exch 1 add % add one to the loop index
- 2 index exch get 5 index /First get add % and get the offset to the start of the next object
-
- 1 index sub % copy the first offset and subtract from the second to get the length
- exch
- 3 index dup 3 -1 roll setfileposition % copy the file and position it to the offset of the object
- exch
- << /EODCount 3 -1 roll /EODString () >> % Set up a dictionary for the filter
- /SubFileDecode filter % and apply it to limit the number of bytes read.
- }
- { % On the last iteration, simly read from the file, we don't need another SubFileDecode.
- 1 index exch get 4 index /First get add % get the offset, and add the value of First from the dictionary.
- 2 index dup 3 -1 roll setfileposition % copy the stream, and position it at that point
- }ifelse
-
- mark exch resolveobjstreamopdict .pdfrun % make a mark and then tokenise all the objects from there to the end of stream (or sub file)
- counttomark 2 sub % Find out how many objects we created (less two, one for the count and one for the first object)
- 0 1 3 -1 roll {pop pop} for % pop that many objects off the stack
- 6 1 roll pop % roll the new object to be behind our working objects on the stack and pop the mark
- } for
-
- % pop most of the working objects (array, file, and ObjStrm dictionary)
- % but leave count of objects. Check that aginst the number of objects
- % retrieved. If we got too few then issue a warning.
-
- pop pop exch pop /ResolveObjectStreamMark CountToKey not {1} if
- 1 sub lt {
- ( **** Error: Incorrect object count in object stream (too few objects).\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } if
- } if
-
- % We have the object data
- /ResolveObjectStreamMark CountToKey not {0} if array astore
- exch pop exch pop % Remove mark and count
- currentdict //no_debug_dict eq { end } if % Restore debug context
- % Save the objects into Objects
- 0 1 2 index length 1 sub { % Loop through all objects
- % Stack: strm# objstreamdict N [obj#] [objects] loopindex
- dup 3 index exch get % Get our current object number
- % Stack: strm# objstreamdict N [obj#] [objects] loopindex obj#
- dup ObjectStream exch get 7 index eq {
- dup resolved? { % If we already have this object
- pop pop % Remove object and object number
- } { % Else if we do not have this object
- PDFDEBUG { (%Resolving compressed object: [) print dup =only ( 0]) = } if
- Objects exch 3 index % Put the object into Objects
- 3 index get
- PDFDEBUG { dup === flush } if
- put
- } ifelse
- } {
- pop % Ignore old object; remove object number.
- } ifelse
- pop % Remove loop index
- } for
- pop pop pop pop pop % Remove strm# objstream, N, (obj#], and [objects]
-} bind executeonly def
-
-currentdict /no_debug_dict undef
-
-% When resolving an object reference, we stop at the endobj or endstream.
-/resolveopdict mark
- valueopdict { } forall
- /xref { % Bug 697761
- ( **** Error: Encountered 'xref' while expecting 'endobj'.\n) pdfformaterror
- ( Treating this as a missing 'endobj', output may be incorrect.\n) pdfformaterror
- endobj exit
- } bind executeonly
- /endstream { endobj exit } bind
- /endobj { endobj exit } bind
- /endjobj { % Bug 689876.
- ( **** Error: Operator 'endobj' is misspelled as 'endjobj'.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- endobj exit
- } bind executeonly
- /enbobj { % Bug 690397.
- ( **** Error: Operator 'endobj' is misspelled as 'enbobj'.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- endobj exit
- } bind executeonly
- /obj {
- % OmniForm generates PDF file with endobj missing in some
- % objects. AR ignores this. So we have to do it too.
- ( **** Error: Encountered 'obj' while expecting 'endobj'.\n) pdfformaterror
- ( Treating this as a missing 'endobj', output may be incorrect.\n) pdfformaterror
- pop pop endobj exit
- } bind executeonly
-.dicttomark readonly def
-
-/resolveR { % <object#> <generation#> resolveR <object>
- 1 index 3 1 roll % copy the object for the code after pdf_run_resolve (may store it)
- PDFDEBUG {
- PDFSTEPcount 1 le {
- (%Resolving: ) print 2 copy 2 array astore //== exec
- } if
- } if
- 1 index dup 0 le exch NumObjects ge or {
- ( **** Error: Considering object with an invalid number )
- 2 index 20 string cvs concatstrings
- ( as null.\n) concatstrings pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop pop //null
- } {
- 1 index resolved? { % If object has already been resolved ...
- exch pop exch pop % then clear stack and return object
- } { % Else if not resolved ...
- PDFfile fileposition 3 1 roll % Save current file position
- 1 index Objects exch get % Get location of object from xref
- 3 1 roll checkgeneration { % Verify the generation number
- % Stack: savepos objpos obj#
- ObjectStream 1 index get dup 0 eq { % Check if obj in not an objstream
- pop exch PDFoffset add PDFfile exch setfileposition
- PDFfile token pop 2 copy ne
- { ( **** Error: Unrecoverable error in xref!\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- /resolveR cvx /rangecheck signalerror
- }
- if pop PDFfile token pop
- PDFfile token pop /obj ne
- { ( **** Error: Unrecoverable error in xref!\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- /resolveR cvx /rangecheck signalerror
- }
- if
- pdf_run_resolve % PDFfile resolveopdict .pdfrun
- } { % Else the object is in an ObjectStream
- % Process an objectstream object. We are going to resolve all
- % of the objects in sthe stream and place them into the Objects
- % array.
- % Stack: savepos objpos obj# objectstream#
- resolveobjectstream
- resolved? { % If object has already been resolved ...
- exch pop % Remove object pos from stack.
- } {
- pop pop //null % Pop objpos and obj#, put null for object
- } ifelse
- } ifelse
- } { % Else the generation number is wrong
- % Don't cache if the generation # is wrong.
- pop pop //null % Pop objpos and obj#, put null for object
- } ifelse % ifelse generation number is correct
- exch PDFfile exch setfileposition % Return to original file position
- } ifelse
- } ifelse
-
- dup type /dicttype eq % For dictionaries only
- {
- dup /Type known % make sure the dictionary has a type
- {
- %% We must not add to *all* dictionaries, because some of them are handled by
- %% executing all the key/value pairs, and adding a integer causes problems
- %% Since we only use this number for font identification, or checking self-references,
- %% we only need it for dictionaries with a Type, and these are always handled more carefully.
- dup 3 -1 roll /.gs.pdfobj# exch put
- }
- {exch pop}
- ifelse
- }
- {exch pop}
- ifelse
-} bind executeonly def
-
-% ================================ Streams ================================ %
-
-% We represent a stream by an executable dictionary that contains,
-% in addition to the contents of the original stream dictionary:
-% /File - the file or string where the stream contents are stored,
-% if the stream is not an external one.
-% /FilePosition - iff File is a file, the position in the file
-% where the contents start.
-% /StreamKey - the key used to decrypt this stream, if any.
-% We do the real work of constructing the data stream only when the
-% contents are needed.
-
-% Construct a stream. The length is not reliable in the face of
-% different end-of-line conventions, but it's all we've got.
-%
-% PDF files are inconsistent about what may fall between the 'stream' keyword
-% and the actual stream data, and it appears that no one algorithm can
-% detect this reliably. We used to try to guess whether the file included
-% extraneous \r and/or \n characters, but we no longer attempt to do so,
-% especially since the PDF 1.2 specification states flatly that the only
-% legal terminators following the 'stream' keyword are \n or \r\n, both of
-% which are properly skipped and discarded by the token operator.
-% Unfortunately, this doesn't account for other whitespace characters that
-% may have preceded the EOL, such as spaces or tabs. Thus we back up one
-% character and scan until we find the \n terminator.
-/stream { % <dict> stream <modified_dict>
- dup /F known dup PDFsource PDFfile eq or {
- not {
- dup /File PDFfile put
- % make sure that we are just past the EOL \n character
- PDFfile dup fileposition 1 sub setfileposition % back up one
- % Skip spaces till \n or a non-space character is found.
- //false
- {
- PDFfile read pop
- dup 32 eq { pop //true or } { exit } ifelse
- } loop
- dup 13 eq {
- pop
- PDFfile read pop
- } if
- 10 ne {
- PDFfile dup fileposition 1 sub setfileposition
- //true or
- } if {
- ( **** Error: stream operator isn't terminated by valid EOL.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } if
-
- dup /FilePosition PDFfile fileposition put
- PDFDEBUG {
- PDFSTEPcount 1 le {
- (%FilePosition: ) print dup /FilePosition get //== exec
- } if
- } if
- } if
- % Some (bad) PDf files have invalid stream lengths. This causes problems
- % if we reposition beyond the end of the file. So we compare the given
- % length to number of bytes left in the file.
- dup mark exch /Length {knownoget} stopped {
- % Bug 703372 is a PDF file where the XRef stream dictionary has a Length which is an
- % indirect object. Clearly we cannot look that up in an xref which we haevn't yet
- % read! We catch the error from knownoget and do not reposition the steam. After
- % that the normal recovery code kicks in and we will eventually manage to read
- % the compressed xref.
- cleartomark
- }
- {
- {
- dup type /realtype eq {
- ( **** Warning: stream length is a real number; converting to integer.\n) pdfformatwarning
- cvi 2 copy /Length exch put
- } if
- dup PDFfile bytesavailable lt { % compare to to bytes left in file
- PDFfile fileposition % reposition to the end of stream
- add PDFfile exch setfileposition
- } {
- pop % bad stream length - do not reposition.
- % This will force a length warning below
- } ifelse
- } if
- pop % the mark from the Length dereference guard above.
- } ifelse
- } {
- pop
- % We're already reading from a stream, which we can't reposition.
- % Capture the sub-stream contents in a string.
- dup /Length oget string PDFsource exch readstring
- not {
- ( **** Error: Unexpected EOF in stream!\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- /stream cvx /rangecheck signalerror
- } if
- 1 index exch /File exch put
- } ifelse
- PDFsource token_nofail not { //null } if
- dup /endobj eq {
- % Another case that Acrobat Reader handles -- 'endobj' without 'endstream'.
- ( **** Error: stream missing 'endstream'.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop /endstream % fake a valid endstream
- } if
- /endstream ne {
- ( **** Error: stream Length incorrect.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- dup /Length undef % prevent the use of the incorrect length.
-
- %% Bug #696560 If we get a stream whose length is incorrect we cannot
- %% safely *assume* it has an object definition as we can get here when
- %% reading an XRef stream, and in that case we will not have the object
- %% and generation numbers on the stack!
- %% So before we call endobj and exit pdfrun, try and see if ths looks like
- %% a regular object or not. If it isn't then don't try and ahndle it as
- %% one, just return the object.
- count 3 ge {
- 1 index type /integertype eq 2 index type /integertype eq and {
- cvx endobj exit % exit from .pdfrun now.
- } if
- } if
- } {
- PDFsource (??) .peekstring pop (>>) eq { % Bug 690161, sample #1
- ( **** Error: Spurious '>>' after 'endstream' ignored.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- PDFsource (12) readstring pop pop
- } if
- } ifelse
- cvx
-} bind executeonly def
-
-/endstream {
- exit
-} bind executeonly def
-
-% Contrary to the published PDF (1.3) specification, Acrobat Reader
-% accepts abbreviated filter names everywhere, not just for in-line images,
-% and some applications (notably htmldoc) rely on this.
-/unabbrevfilterdict mark
- /AHx /ASCIIHexDecode /A85 /ASCII85Decode /CCF /CCITTFaxDecode
- /DCT /DCTDecode /Fl /FlateDecode /LZW /LZWDecode /RL /RunLengthDecode
-.dicttomark readonly def
-
-% Extract and apply filters.
-/filterparms { % <dict> <DPkey> <Fkey> filterparms
- % <dict> <parms> <filternames>
- 2 index exch knownoget {
- oforce_recursive
- exch 2 index exch knownoget {
- dup length 0 eq {
- pop //false
- } {
- //true
- } ifelse
- } {
- //false
- } ifelse {
- % Both filters and parameters.
- oforce_recursive
- exch dup type /nametype eq {
- 1 array astore exch
- dup type /arraytype ne { 1 array astore } if exch
- } if
- } {
- % Filters, but no parameters.
- //null exch
- dup type /nametype eq { 1 array astore } if
- } ifelse
- } {
- % No filters: ignore parameters, if any.
- pop //null { }
- } ifelse
-} bind executeonly def
-/filtername { % <filtername> filtername <filtername'>
- //unabbrevfilterdict 1 index .knownget { exch pop } if
- dup /Filter resourcestatus { pop pop } {
- Repaired exch % this error is not the creator's fault
- RepairedAnError exch
- ( **** ERROR: Unable to process ) pdfformaterror
- 64 string cvs pdfformaterror
- ( data. Page will be missing data.\n) pdfformaterror
- /RepairedAnError exch store
- /Repaired exch store % restore the previous "Repaired" state
- % provide a filter that returns EOF (no data)
- /.EOFDecode
- } ifelse
-} bind executeonly def
-
-/pdf_rules_dict << /PDFRules //true >> readonly def
-
-% Add PDF option to ASCII85Decode filter
-% <source> <name> add_A85_param <source> <dict'> <name>
-% <source> <dict> <name> add_A85_param <source> <dict'> <name>
-/add_A85_param {
- dup /ASCII85Decode eq {
- 1 index type /dicttype eq {
- exch dup length 1 add dict copy
- dup /PDFRules //true put
- exch
- } {
- //pdf_rules_dict exch
- } ifelse
- } if
-} bind executeonly def
-
-currentdict /pdf_rules_dict undef
-
-/applyfilters { % <parms> <source> <filternames> applyfilters <stream>
- 2 index //null eq
- {
- { filtername add_A85_param filter }
- }
- {
- dup length 3 index length ne %% compare lengths of DecodeParmas and Filter arrays
- { %% if they aren't the same, ignore the decode params
- ( **** Error: ignoring stream /DecodeParams array as its length is different to the Filters array.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- 3 -1 roll pop //null 3 1 roll
- { filtername add_A85_param filter }
- }
- {
- { % Stack: parms source filtername
- 2 index 0 oget dup type /dicttype ne
- { pop }
- {
- exch filtername dup /JBIG2Decode eq { exch jbig2cachectx exch } if
- } ifelse
- add_A85_param filter
- exch dup length 1 sub 1 exch getinterval exch
- }
- } ifelse
- } ifelse
- forall exch pop
-} bind executeonly def
-
-% JBIG2 streams have an optional 'globals' stream obj for
-% sharing redundant data between page images. Here we resolve
-% that stream reference (if any) and run it through the decoder,
-% creating a special -jbig2globalctx- postscript object our
-% JBIG2Decode filter implementation looks for in the parm dict.
-/jbig2cachectx { % <parmdict> jbig2cachectx <parmdict>
- dup /JBIG2Globals knownoget {
- % make global ctx
- PDFfile fileposition exch % resolvestream is not reentrant
- mark exch
- //true resolvestream % stack after: PDFfileposition -file-
- % Read the data in a loop until EOF to so we can move the strings into a bytestring
- [ { counttomark 1 add index 60000 string readstring not { exit } if } loop ]
- exch pop 0 1 index { length add } forall % compute the total length
- % now copy the data from the array of strings into a bytestring
- .bytestring exch 0 exch { 3 copy putinterval length add } forall pop
- % If this fails we don't want to abort totally, there may be more content
- % in the PDF file that we can render. So just run in a stopped context.
- {.jbig2makeglobalctx} stopped
- {
- cleartomark
- PDFfile exch setfileposition
- }
- {
- exch pop
- PDFfile 3 -1 roll setfileposition
- 1 index exch
- /.jbig2globalctx exch put
- } ifelse
- } if
-} bind executeonly def
-
-% Resolve a stream dictionary to a PostScript stream.
-% Streams with no filters require special handling:
-% - Whether we are going to interpret the stream, or If we are just
-% going to read data from them, we impose a SubFileDecode filter
-% that reads just the requisite amount of data.
-% Note that, in general, resolving a stream repositions PDFfile.
-% Clients must save and restore the position of PDFfile themselves.
-/resolvestream { % <streamdict> <readdata?> resolvestream <stream>
- 1 index /F knownoget {
- % This stream is stored on an external file.
- (r) file 3 -1 roll
- /FDecodeParms /FFilter filterparms
- % Stack: readdata? file dict parms filternames
- 4 -1 roll exch
- pdf_decrypt_stream
- applyfilters
- } {
- exch
- dup /Length knownoget { 0 eq } { //false } ifelse {
- () 0 () /SubFileDecode filter
- } {
- dup /FilePosition .knownget {
- 1 index /File get exch setfileposition
- } if
- % Stack: readdata? dict
- /DecodeParms /Filter filterparms
- % Stack: readdata? dict parms filternames
- 2 index /File .knownget not {
- ( **** Error: Stream object is missing the stream data.\n)
- ( Output may be incorrect.\n) pdfformaterror
- pdfformaterror
- ()
- } if exch
- % Stack: readdata? dict parms file/string filternames
- dup length 0 eq {
- % All the PDF filters have EOD markers, but in this case
- % there is no specified filter.
- exch dup type /filetype eq 5 index or {
- % Use length for any files or reading data from any source.
- 3 index /Length knownoget not { 0 } if
- } {
- 0 % Otherwise length of 0 for whole string
- } ifelse
- 4 index /IDFlag known { pop } { () /SubFileDecode filter } ifelse
- exch
- pdf_decrypt_stream % add decryption if needed
- pop exch pop
- } {
- % Stack: readdata? dict parms source filternames
- exch 3 index /Length knownoget {
- () /SubFileDecode filter
- } if exch
- pdf_decrypt_stream % add decryption if needed
- applyfilters
- } ifelse
- } ifelse
- } ifelse
- % Stack: readdata? dict file
- exch pop exch pop
-} bind executeonly def
-
-% ============================ Name/number trees ============================ %
-
-/nameoget { % <nametree> <key> nameoget <obj|null>
- exch /Names exch .treeget
-} bind executeonly def
-
-/numoget { % <numtree> <key> numoget <obj|null>
- exch /Nums exch .treeget
-} bind executeonly def
-
-/.treeget { % <key> <leafkey> <tree> .treeget <obj|null>
- dup /Kids knownoget {
- exch pop .branchget
- } {
- exch oget .leafget
- } ifelse
-} bind executeonly def
-
-/.branchget { % <key> <leafkey> <kids> .branchget <obj|null>
- dup length 0 eq {
- pop pop pop //null
- } {
- dup length -1 bitshift 2 copy oget
- % Stack: key leafkey kids mid kids[mid]
- dup /Limits oget aload pop
- % Stack: key leafkey kids mid kids[mid] min max
- 6 index lt {
- pop pop
- 1 add 1 index length 1 index sub getinterval .branchget
- } {
- 5 index gt {
- pop
- 0 exch getinterval .branchget
- } {
- exch pop exch pop .treeget
- } ifelse
- } ifelse
- } ifelse
-} bind executeonly def
-
-/.leafget { % <key> <pairs> .leafget <obj|null>
- null % <key> [pairs] null
- 0 2 3 index length 1 sub % <key> [pairs] null 0 2 length([pairs])
- { % <key> [pairs] null index
- 2 index % <key> [pairs] null index [pairs]
- exch % <key> [pairs] null [pairs] index
- 2 getinterval % <key> [pairs] null [<key1> <value>]
- dup 0 get % <key> [pairs] null [<key1> <value>] <key1>
- 4 index % <key> [pairs] null [<key1> <value>] <key1> <key>
- eq
- { % <key> [pairs] null [<key1> <value>]
- exch pop 1 oget exit % <key> [pairs] <obj>
- } {
- pop % <key> [pairs] null
- }ifelse
- } for
- % <key> [pairs] <obj|null>
- 3 1 roll pop pop % <obj|null>
-} bind executeonly def
-
-% The following variants return tree entry whose key is closest but
-% less or equal to the given key.
-
-/numogetle { % <numtree> <key> numogetle <key obj true|false>
- exch /Nums exch .treegetle
-} bind executeonly def
-
-/.treegetle { % <key> <leafkey> <tree> .treegetle <key obj true|false>
- dup /Kids knownoget {
- exch pop .branchgetle
- } {
- exch oget .leafgetle
- } ifelse
-} bind executeonly def
-
-/.branchgetle { % <key> <leafkey> <kids> .branchgetle <key obj true|false>
- dup length 0 eq {
- pop pop pop //false
- } {
- dup length -1 bitshift 2 copy oget
- dup /Limits oget aload pop
- % Stack: key leafkeyb kids mid kids[mid] min max
- 6 index ge {
- 5 index le {
- exch pop exch pop .treegetle
- } {
- pop 0 exch getinterval .branchgetle
- } ifelse
- } {
- pop 2 index length 2 index sub 1 gt {
- pop 1 index length 1 index sub getinterval .branchgetle
- } {
- exch pop exch pop .treegetle
- } ifelse
- } ifelse
- } ifelse
-} bind executeonly def
-
-/.leafgetle { % <key> <pairs> .leafget <obj|null>
- dup length 2 eq {
- dup 0 get
- 2 index le { exch pop aload pop //true } { pop pop //false } ifelse
- } {
- dup length -1 bitshift -2 and 2 copy oget
- % Stack: key pairs mid pairs[mid]
- 3 index gt { 0 exch } { 1 index length 1 index sub } ifelse
- getinterval .leafgetle
- } ifelse
-} bind executeonly def
-
-end % pdfdict
-.setglobal
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps
deleted file mode 100644
index 117b362cfb9..00000000000
--- a/Master/tlpkg/tlgs/Resource/Init/pdf_draw.ps
+++ /dev/null
@@ -1,5896 +0,0 @@
-% Copyright (C) 2001-2022 Artifex Software, Inc.
-% 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.
-%
-% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
-%
-
-% pdf_draw.ps
-% PDF drawing operations (graphics, text, and images).
-
-/.setlanguagelevel where { pop 2 .setlanguagelevel } if
-.currentglobal //true .setglobal
-/GS_PDF_ProcSet load begin
-pdfdict begin
-
-% For simplicity, we use a single interpretation dictionary for all
-% PDF graphics operations, even though this is too liberal.
-/drawopdict 100 dict def
-
-% ================================ Graphics ================================ %
-
-% ---------------- Functions ---------------- %
-
-% Note that resolvefunction converts a PDF Function to a PostScript Function;
-% resolve*fnproc converts a PDF function to a PostScript procedure.
-% We need to process all required and optional parameters to resolve any
-% use of indirect references.
-
-/fnrdict mark
- 0 { .resolvefn0 }
- 2 { .resolvefn2 }
- 3 { .resolvefn3 }
- 4 { .resolvefn4 }
-.dicttomark readonly def
-
-/.resolvefn0 {
- dup length 1 add dict .copydict % make room for DataSource
- % now resolve any indirect references
- dup /Size 2 copy knownoget { put } { pop pop } ifelse
- dup /BitsPerSample 2 copy knownoget { put } { pop pop } ifelse
- dup /Order 2 copy knownoget { put } { pop pop } ifelse
- dup /Encode 2 copy knownoget { put } { pop pop } ifelse
- dup /Decode 2 copy knownoget { put } { pop pop } ifelse
-
- % Don't lose our place in PDFfile.
- PDFfile fileposition exch
- dup //true resolvestream
- % The stream isn't positionable, so read all the data now.
- % Stack: filepos fndict stream
- 1 index /Range get length 2 idiv 2 index /BitsPerSample get mul
- 2 index /Size get { mul } forall
- 7 add 8 idiv
- dup 65535 le {
- string 1 index exch readstring pop
- } {
- 1 index exch () /SubFileDecode filter /ReusableStreamDecode filter
- } ifelse
- exch closefile
- % Stack: filepos fndict data
- exch dup /DataSource 4 -1 roll put
- exch PDFfile exch setfileposition
-} bind executeonly def
-
-/.resolvefn2 {
- dup length dict .copydict
- dup /C0 2 copy knownoget { put } { pop pop } ifelse
- dup /C1 2 copy knownoget { put } { pop pop } ifelse
- dup /N 2 copy knownoget { put } { pop pop } ifelse
-} bind executeonly def
-
-/.resolvefn3 {
- dup length dict .copydict
- dup /Bounds 2 copy knownoget { put } { pop pop } ifelse
- dup /Encode 2 copy knownoget { put } { pop pop } ifelse
- dup /Functions 2 copy oget mark exch dup {
- oforce .resolvefn
- } forall
- counttomark -1 roll astore exch pop put
-} bind executeonly def
-
-/.resolvefn4 {
- PDFfile fileposition exch % filepos fndict
- dup //true resolvestream % filepos fndict stream
- exch dup length dict copy % filepos stream fndict2
- dup /Function undef % filepos stream fndict2
- exch dup token not {
- () /rangecheck signalerror
- } if
- exch token {
- /rangecheck signalerror
- } if
- % Use .bind to avoid idiom recognition.
- .bind
- 1 index /Function 3 -1 roll put
- exch PDFfile exch setfileposition
-} bind executeonly def
-
-/.resolvefn { % <fndict> .resolvefn <fndict'>
- dup length dict .copydict
- dup /Domain 2 copy knownoget { put } { pop pop } ifelse
- dup /Range 2 copy knownoget { put } { pop pop } ifelse
- dup /FunctionType oget //fnrdict exch get exec
-} bind executeonly def
-
-/resolvefunction { % <fndict> resolvefunction <function>
- .resolvefn
- PDFDEBUG { //pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Function: ) print dup === flush } if } if
-} bind executeonly def
-
-/resolvefnproc { % <fndict> resolvefnproc <proc>
- resolvefunction .buildfunction
-} bind executeonly def
-
-/resolveidfnproc { % <fndict> resolveidfnproc <proc>
- dup /Identity eq { pop { } } { resolvefnproc } ifelse
-} bind executeonly def
-
-/resolvedefaultfnproc { % <fndict> <default> resolved'fnproc <proc>
- 1 index /Default eq { exch pop } { pop resolveidfnproc } ifelse
-} bind executeonly def
-
-%% A BBox where width or height (or both) is 0 should still paint one pixel
-%% See the ISO 32000-2:2017 spec, section 8.7.4.3, p228 'BBox' and 8.7.3.1
-/FixPatternBBox
-{
- dup aload pop
- 3 index 2 index sub 0 eq {
- 3 index 0.000001 add 3 -1 roll pop exch
- } if
- 2 index 1 index sub 0 eq {
- 2 index 0.000001 add exch pop
- }if
- 5 -1 roll astore
-}bind executeonly def
-
-% ---------------- Shadings ---------------- %
-
-/shrdict mark
- /Coords {
- aload
- 5 1 roll
- 4 { % Bug 694542
- dup type dup /integertype ne exch /realtype ne and {
- ( **** Error: replacing malformed number ') pdfformaterror pdfstring cvs pdfformaterror
- (' with 0.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- 0
- } if
- 4 1 roll
- } repeat
- 5 -1 roll
- astore
- } bind executeonly
- /BBox {
- dup dup dup aload pop normrect_elems
- 5 -1 roll astore
- FixPatternBBox
- } bind executeonly
- /ColorSpace {
- resolvecolorspace
- } bind executeonly
- /Function {
- dup type /dicttype eq {
- resolvefunction
- } {
- [ exch { oforce resolvefunction } forall ]
- } ifelse
- } bind executeonly
- /Extend {
- mark exch {oforce} forall ]
- } bind executeonly
-.dicttomark readonly def
-
-/resolveshading { % <shadingstream> resolveshading <shading>
- dup /.shading_dict .knownget {
- exch pop
- dup /ShadingType get 4 ge {
- dup /DataSource get 0 setfileposition
- } if
- } {
- dup
- PDFfile fileposition exch
- mark exch {
- oforce //shrdict 2 index .knownget { exec } if
- } forall .dicttomark
- dup /ShadingType get 4 ge {
- dup dup //true resolvestream
- % Make a reusable stream so that the shading doesn't
- % reposition PDFfile at unexpected times.
- /ReusableStreamDecode filter /DataSource exch put
- } if
- exch PDFfile exch setfileposition
- dup 3 1 roll /.shading_dict exch put
- } ifelse
-} bind executeonly def
-/resolvesh { % <shname> resolvesh <shading>
- % <shname> resolvesh <null>
- Page /Shading rget {
- %% Horrible hacky fix, see /DoImage later in ths file for more information
- %%
- dup /ColorSpace known {
- dup /ColorSpace get dup type /arraytype eq {
- exch dup length dict copy exch
- dup length array copy /ColorSpace exch 2 index 3 1 roll put
- } {pop} ifelse
- } if
-
- resolveshading
- } {
- //null
- }ifelse
-} bind executeonly def
-
-% ---------------- Halftones ---------------- %
-
-/spotfunctions mark
- /Round {
- abs exch abs 2 copy add 1 le {
- dup mul exch dup mul add 1 exch sub
- } {
- 1 sub dup mul exch 1 sub dup mul add 1 sub
- } ifelse
- } bind executeonly
- /Diamond {
- abs exch abs 2 copy add .75 le {
- dup mul exch dup mul add 1 exch sub
- } {
- 2 copy add 1.23 le {
- .85 mul add 1 exch sub
- } {
- 1 sub dup mul exch 1 sub dup mul add 1 sub
- } ifelse
- } ifelse
- } bind executeonly
- /Ellipse {
- abs exch abs 2 copy 3 mul exch 4 mul add 3 sub dup 0 lt {
- pop dup mul exch .75 div dup mul add 4 div 1 exch sub
- } {
- dup 1 gt {
- pop 1 exch sub dup mul exch 1 exch sub
- .75 div dup mul add 4 div 1 sub
- } {
- .5 exch sub exch pop exch pop
- } ifelse
- } ifelse
- } bind executeonly
- /EllipseA { dup mul .9 mul exch dup mul add 1 exch sub } bind executeonly
- /InvertedEllipseA { dup mul .9 mul exch dup mul add 1 sub } bind executeonly
- /EllipseB { dup 5 mul 8 div mul exch dup mul exch add sqrt 1 exch sub } bind executeonly
- /EllipseC { dup mul .9 mul exch dup mul add 1 exch sub } bind executeonly
- /InvertedEllipseC { dup mul .9 mul exch dup mul add 1 sub } bind executeonly
- /Line { exch pop abs neg } bind executeonly
- /LineX { pop } bind executeonly
- /LineY { exch pop } bind executeonly
- /Square { abs exch abs 2 copy lt { exch } if pop neg } bind executeonly
- /Cross { abs exch abs 2 copy gt { exch } if pop neg } bind executeonly
- /Rhomboid { abs exch abs 0.9 mul add 2 div } bind executeonly
- /DoubleDot { 2 {360 mul sin 2 div exch } repeat add } bind executeonly
- /InvertedDoubleDot { 2 {360 mul sin 2 div exch } repeat add neg } bind executeonly
- /SimpleDot { dup mul exch dup mul add 1 exch sub } bind executeonly
- /InvertedSimpleDot { dup mul exch dup mul add 1 sub } bind executeonly
- /CosineDot { 180 mul cos exch 180 mul cos add 2 div } bind executeonly
- /Double { exch 2 div exch 2 { 360 mul sin 2 div exch } repeat add } bind executeonly
- /InvertedDouble {
- exch 2 div exch 2 { 360 mul sin 2 div exch } repeat add neg
- } bind executeonly
-.dicttomark readonly def
-
-/.resolveht1 {
- mark exch {
- oforce
- 1 index /SpotFunction eq {
- dup type /arraytype eq {
- %% check all the names in the array in turn, stop when we find
- %% the first one we recognise.
- {
- //spotfunctions exch .knownget {
- exit
- } if
- } forall
- dup type /nametype eq {
- %% If we didn't find any that we recognise, then use
- %% the default halftone's spot function
- .setdefaulthalftone currenthalftone dup /SpotFunction .knownget {
- exch pop
- }{
- /GraySpotFunction .knownget not {
- //spotfunctions /Round get
- } if
- }ifelse
- } if
- }{
- dup type /nametype eq
- { //spotfunctions exch get } { resolvefnproc }
- ifelse
- } ifelse
- } {
- 1 index /TransferFunction eq {
- resolveidfnproc
- } if
- } ifelse
- } forall .dicttomark
-} bind executeonly def
-
-/.resolveht5 {
- mark exch {
- oforce dup type /dicttype eq { resolvehalftone } if
- } forall .dicttomark
-} bind executeonly def
-
-/.resolveht6 {
- %% resolvestream will reposition PDFfile. If we are in the middle
- %% of reading a content stream from PDFfile when we execute this,
- %% then reading the next buffer will read from the wrong place. We
- %% must save and restore the position of PDFfile. See the definition
- %% of resolvestream. Bug #695886
- PDFfile fileposition exch
- mark exch { oforce } forall .dicttomark
- dup dup //false resolvestream /ReusableStreamDecode filter
- /Thresholds exch put
- dup /TransferFunction .knownget {
- resolveidfnproc
- 1 index exch /TransferFunction exch put
- } if
- exch PDFfile exch setfileposition
-} bind executeonly def
-
-/htrdict mark
- 1 //.resolveht1
- 5 //.resolveht5
- 6 //.resolveht6
- 10 //.resolveht6
- 16 //.resolveht6
-.dicttomark readonly def
-
-currentdict /.resolveht1 undef
-currentdict /.resolveht5 undef
-currentdict /.resolveht6 undef
-
-/resolvehalftone { % <dict> resolvehalftone <halftone>
- dup /HalftoneType oget
- dup //htrdict exch .knownget {
- exch pop exec
- } {
- =string cvs
- ( **** Error: Incorrect halftone type ) exch concatstrings
- (. Using defailt.\n) concatstrings pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- gsave .setdefaulthalftone currenthalftone grestore
- } ifelse
-} bind executeonly def
-
-% ---------------- Graphics state management ---------------- %
-
-/cmmatrix matrix def
-drawopdict begin
- % Graphics state stack
- /q { q } executeonly def
- /Q { Q } executeonly def
- % Graphics state setting
- /cm {
- //cmmatrix astore
- % If inside a BT/ET block, we need to undo the text matrix, then apply
- % the cm, then re-apply the text matrix :-( Of course the spec says
- % this isn't even legal.
- currentdict /TextSaveMatrix .knownget {
- pop
- unsettextmatrix
- } if
- .getpath
- exch concat
- newpath { exec } forall
- % If inside a BT/ET block, we need to update the TextSaveMatrix
- currentdict /TextSaveMatrix .knownget {
- settextmatrix
- //cmmatrix exch dup concatmatrix pop
- } if
- % And if we ha\ve done a gsave inside a text block, we need to update
- % that matrix instead.
- currentdict /qTextSaveMatrix .knownget {
- //cmmatrix exch dup concatmatrix pop
- } if
- } bind executeonly def
-
- /i { 1 .min setflat } bind executeonly def
- /J { setlinecap } bind 0 get def
- /d { setdash } bind 0 get def
- /j { setlinejoin } bind 0 get def
- /w { setlinewidth } bind 0 get def
- /M { 1 .max setmiterlimit } bind executeonly def
- /gs { gs } executeonly def
-end
-
-% Each entry in this dictionary is
-% <gsres> <value> -proc- <gsres>
-/gsbg {
- /BGDefault load resolvedefaultfnproc setblackgeneration
-} bind executeonly def
-/gsucr {
- /UCRDefault load resolvedefaultfnproc setundercolorremoval
-} bind executeonly def
-/gstr {
- dup type /arraytype eq {
- { oforce /TRDefault load resolvedefaultfnproc } forall
- setcolortransfer
- } {
- /TRDefault load resolvedefaultfnproc settransfer
- } ifelse
-} bind executeonly def
-/gsparamdict mark
- /SA { setstrokeadjust } executeonly
- /OP { 1 index /op known not { dup op } if OP } executeonly
- % The PDF 1.3 specification says that the name /Default is only
- % recognized for {BG,UCR,TR}2. However, PDF 1.3 files produced
- % by Adobe Acrobat Distiller 4.0 for Windows use the name /Default
- % with the older keys, so we have to implement this.
- /BG { 1 index /BG2 known { pop } { gsbg } ifelse } executeonly
- /UCR { 1 index /UCR2 known { pop } { gsucr } ifelse } executeonly
- /TR { 1 index /TR2 known { pop } { gstr } ifelse } executeonly
-
- % Some functions used to implement phases of HT and HTP
- /sethalftones {
- % As is so often the case, if we get an error we need to clean up the stack, but we can't
- % use mark/cleartomark, because the action which caused the error may have left a mark
- % on the stack. So we need to define our own mark. On an error we'll clean up the stack
- % until we reach this unique key on the stack
- /SethalftonesMark exch
-
- dup /Default eq {
- pop .setdefaulthalftone pop
- }
- {
- {resolvehalftone} stopped
- {
- (\n **** Error resolving halftone. Ignoring the halftone, output may be incorrect.\n)
- pdfformaterror
- % Clean up the stack by checking every entry until we find our unique key
- {/SethalftonesMark eq {exit} if} loop
- }
- {
- {sethalftone} stopped
- {
- (\n **** Error setting halftone. Ignoring the halftone, output may be incorrect.\n)
- pdfformaterror
- % Clean up the stack by checking every entry until we find our unique key
- {/SethalftonesMark eq {exit} if} loop
- }
- {
- pop
- }ifelse
- }ifelse
- } ifelse
- } bind executeonly def
- /sethalftonephases {
- {aload pop -1 2 index 2 index .setscreenphase pop pop} stopped
- {
- (\n **** Error setting halftone phase. Ignoring the phase, output may be incorrect.\n)
- pdfformaterror
- } if
- } bind executeonly def
-
- /HT {
- dup sethalftones .swapcolors sethalftones .swapcolors
- % the transfer function may dependent on the halftone, so make sure
- % it is set if included in the graphic state (otherwise this is
- % subject to order of a dictionary forall, which is unpredictable)
- dup /TR2 .knownget {
- dup /Default eq { oforce gsparamdict /TR2 get exec } { pop } ifelse
- } {
- dup /TR .knownget {
- /dup /Default eq { oforce gsparamdict /TR get exec } { pop } ifelse
- } if
- } ifelse
- } executeonly
- /HTP {
- % HTP may be present even if this isn't a DPS interpreter.
- dup sethalftonephases .swapcolors sethalftonephases .swapcolors
- } executeonly
- % PDF 1.3
- % The font is an indirect reference, not a resource name
- /Font { aload pop exch oforce resourcefont exch Tf }
- /LW { setlinewidth } executeonly
- /LC { setlinecap } executeonly
- /LJ { setlinejoin } executeonly
- /ML { 1 .max setmiterlimit } executeonly
- /D { aload pop setdash } executeonly
- /RI { ri } executeonly
- /op { op } executeonly
- /OPM { OPM } executeonly
- /BG2 { gsbg } executeonly
- /UCR2 { gsucr } executeonly
- /TR2 { gstr } executeonly
- /FL { 1 .min setflat } executeonly
- /SM {
- % SM may be present even if this is only a Level 2 interpreter.
- /setsmoothness where { pop setsmoothness } { pop } ifelse
- } executeonly
- % PDF 1.4
- % All of these require the "transparency" feature in the interpreter.
- /ca { ca } executeonly
- /CA { CA } executeonly
- /SMask {
- {gssmask} PDFSTOPONERROR { exec //false } { stopped } ifelse
- {
- pop (\n **** Error in SMask during ExtGState. Ignoring the mask, output may be incorrect.\n)
- pdfformaterror
- } if
- } executeonly
- /AIS { AIS } executeonly
- /BM { BM } executeonly
- /TK { TK } executeonly
- /UseBlackPtComp { UseBlackPtComp } executeonly
- /HTO {
- % PDF 2.0, supposed to be 'similar' to halftone phase but using a different
- % co-ordiate system. Treat the same for now and fix if anyone ever complains.
- aload pop transform cvi exch cvi exch 2 array astore
- dup sethalftonephases .swapcolors sethalftonephases .swapcolors
- } executeonly
-.dicttomark readonly def
-/gs { % <gsres> gs -
- Page /ExtGState rget {
- % We keep the dictionary on the stack during the forall so that
- % keys that interact with each other have access to it.
- dup {
- oforce exch gsparamdict exch .knownget { exec } { pop } ifelse
- } forall pop
- } {
- //pdfdict /.gs_warning_issued known not {
- (\n **** Error 'gs' ignored -- ExtGState missing from Resources.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- //pdfdict /.gs_warning_issued //true .forceput
- PDFSTOPONERROR { /gs cvx /undefined signalerror } if
- } executeonly if
- } executeonly
- ifelse
-} bind executeonly def
-
-% ------ Transparency support ------ %
-
-/gssmask {
- {
- dup type /dicttype eq
- {
- dup /G knownogetdict
- {pop}
- {
- ( **** Error: Ignoring invalid transparency SMask group\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- % replace the invalid SMask object
- pop /None
- } ifelse
- } if
-
- dup /None eq 1 index //null eq or PDFusingtransparency not or {
- pop //null
-
- .currentSMask //null ne {
- % get rid of the current SMask (Bug 695471)
- //false % colorspace not set
- << /Subtype /None >> % Special type for this purpose
- 0 0 0 0 % fake BBox
- .begintransparencymaskgroup
- } if
- exit
- } if
- % Preprocess the SMask value into a parameter dictionary for
- % .begintransparencymaskgroup, with added /BBox and /Draw keys.
- mark exch % Stack: mark smaskdict
- dup /S oget /Subtype exch 3 2 roll
- % Stack: mark ... smaskdict
- dup /BC knownoget {
- dup /Background exch 4 2 roll
- 1 index /G oget /Group knownoget not {
- ( **** Error: Ignoring a transparency group XObject without /Group attribute.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- cleartomark //null exit
- } if
- gsave //nodict begin
- dup /CS knownoget {
- exch pop
- resolvecolorspace dup setgcolorspace csput
- }
- {
- % Group attributes dictionaries are supposed to contain a /CS
- % entry, but Acrobat apparently also handles a /ColorSpace....
- /ColorSpace knownoget {
- ( **** Error: A transparency group XObject has a /ColorSpace instead of /CS attribute.\n)
- pdfformaterror
- resolvecolorspace dup setgcolorspace csput
- }
- {
- ( **** Error: Ignoring a transparency group XObject without /CS attribute.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- cleartomark //null exit
- }ifelse
- } ifelse
- aload pop setcolor [ currentgray ]
- end grestore
- /GrayBackground exch 3 2 roll
- } if
- dup /TR knownoget {
- dup /Identity eq {
- pop
- } {
- resolvefnproc /TransferFunction exch 3 2 roll
- } ifelse
- } if
- dup /G oget
- dup /BBox oget oforce_array
- 1 index /Matrix knownoget {
- oforce_array .bbox_transform 4 array astore
- } if
- /BBox exch 4 2 roll
- % Because we don't execute the group form stream until we find
- % out whether we're actually going to draw through it, we need
- % to save the current gstate with the other parameters, so
- % we can subsequently execute it in the correct graphics state.
- % We need to concatenate the Matrix in this gstate as per the PDF
- % spec 7.5.4 (p. 552 in the PDF 1.7 Ref) (bug 694455).
- gsave
- dup /Matrix knownoget {
- matrix currentmatrix matrix concatmatrix setmatrix
- } if
- /GroupGState gstate currentgstate 6 2 roll
- grestore
- /GroupMat matrix currentmatrix 8 2 roll
-% /GroupExtGState 1 dict
-% 10 2 roll
-
- /.execmaskgroup cvx 2 packedarray cvx /Draw exch 3 2 roll
- pop
- .dicttomark
- exit
- } loop
- SMask
-} bind executeonly def
-
-% Functions specific to the Device* colorspaces to force the switch to
-% the Device* colorspace so that the SMask will not get a CIEBased* colorspace
-% in the case when UseCIEColor changes the Device* colorspace to something else.
-% Also see the logic in pdf_main.ps:pdfopen that similarly defines these resources.
-/forceDefaultCS <<
- {
- currentcolorspace setcolorspace % this will switch to Device colorspace
- } bind executeonly
- /DeviceGray exch
- /DeviceRGB 1 index
- /DeviceCMYK 1 index
->>
-def
-
-% This procedure is called to actually render the soft mask.
-/.execmaskgroup { % <masknum> <paramdict> <formdict> .execmaskgroup -
- % Save our place in PDFfile. Do not use gsave-grestore when creating
- % a soft mask with .begintransparencygroup because high level devices
- % need to modify the graphic state by storing the soft mask ID.
- % Save the ExtGState (//nodict begin) BEFORE changing the colorspace
- //nodict begin
- matrix currentmatrix 4 1 roll
- mark currentcolor counttomark dup 4 add exch roll pop
- currentcolorspace 4 1 roll .getuseciecolor 4 1 roll
- .swapcolors mark currentcolor counttomark dup 4 add exch roll pop currentcolorspace 4 1 roll .swapcolors
- currentuserparams /OverrideICC get 4 1 roll
- mark /OverrideICC //true .dicttomark setuserparams
-
- % We can't simply set the group's gstate here because
- % we can't use gsave/grestore. So we actually set it
- % in .execgroup. But the matrix needs set here for
- % .begintransparencymaskgroup to correctly work.
- % It might seem we should also set the colorspace
- % in case the group doesn't have one, *but* empirical
- % suggests that is not the case - fts_26_2600.pdf and
- % fts_26_2603.pdf render incorrectly if we set the
- % colrospace
- 1 index /GroupMat .knownget { setmatrix } if
-
- PDFfile fileposition 4 1 roll
- % We have to select the group's color space so that the
- % background color will be interpreted correctly.
- % [save/restore]DefaultCS make sure that the SMask logic sees
- % the Device* spaces, not CIEBased* that UseCIEColor may have
- % established.
- //false .setuseciecolor % SMask gets processed without UseCIEColor
- dup /Group oget /CS knownoget {
- resolvecolorspace dup setgcolorspace csput
- //true % use currentcolorspace
- } {
- % Group attributes dictionaries are supposed to contain a /CS
- % entry, but Acrobat apparently also handles a /ColorSpace....
- dup /Group oget /ColorSpace knownoget {
- ( **** Error: A transparency group attribute dictionary has a /ColorSpace instead of /CS attribute.\n)
- pdfformaterror
- resolvecolorspace dup setgcolorspace csput
- //true % use currentcolorspace
- }
- {
- % inheriting the colorspace -- make sure Device* spaces are not CIEBased
- forceDefaultCS currentcolorspace 0 get .knownget { exec } if
- //false % no defined colorspace
- } ifelse
- } ifelse
- 3 -1 roll dup
- dup 4 1 roll /BBox get aload pop .begintransparencymaskgroup
- exch dup /Resources knownoget { oforce } { 2 dict } ifelse
- 3 -1 roll /GroupGState .knownget { 1 index /GroupGState 3 -1 roll put} if
- exch //false resolvestream
- 1 index exch
-
- %% Get the current colour space and colour values (as an array), we need to pass these to .execgroup
- %% as well, so that it can restore them, in case the colour space gets changed by transparency
- %% graphics state stuff.
- mark currentcolor counttomark array astore exch pop
- currentcolorspace 4 2 roll
-
- .execgroup
- % We have to remove these in case the Form XObject is subsequently used as
- % a form rather than a group - they remain in the paramdict for the SMask
- % so this will all still work if the SMask is re-evaluated.
- /GroupGState undef
-
- .endtransparencymask
- PDFfile exch setfileposition
- mark exch /OverrideICC exch .dicttomark setuserparams
- .swapcolors setcolorspace setcolor .swapcolors
- .setuseciecolor setcolorspace setcolor
- setmatrix
- end % restore colorspace, color and ExtGState (end)
- .currentSMask /Processed //true put % special setting to tell us it has been rendered
-} bind executeonly def
-
-% Paint a Form+Group XObject, either for a transparency mask or for a Do.
-/.execgroup { % [colour values] <colour space> <resdict> <stream> .execgroup -
- pdfemptycount 3 1 roll
- /pdfemptycount count 5 sub store
- gsave //nodict begin
-
- % We have to set the gstate correctly for lazy evaluation of a softmask group.
- % we also must restore the color(space) as setup in .execmaskgroup or paintformgroup.
- % This stuff must be done here, as .execmaskgroup can't use gsave/grestore to
- % manipulate the gstates, due to the requirements of .begintransparencymaskgroup.
- % We also must set the ExtGState values.
- % It may seem redundant to do the color(space) twice (once here and once in
- % .execmaskgroup) but we have to set it in .execmaskgroup for the background
- % color and set it here once in the correct gstate.
- 1 index
- /GroupGState .knownget { setgstate } if
-
- newpath //null SMask
- 1 CA 1 ca
- /Compatible .setblendmode
- % Execute the body of the Form, similar to DoForm.
- pdfopdict
-
- %% Restore the colour space (passed in on the stack) and current colour
- %%
- 6 -2 roll
- setcolorspace
- aload pop setcolor
-
- .pdfruncontext
- end grestore
-
- % check for extra garbage on the operand stack and clean it up
- count pdfemptycount sub dup 0 ne {
- ( **** Error: Transparency Group, Form XObject execution corrupted the stack.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- PDFSTOPONERROR {
- /.execgroup cvx /rangecheck signalerror
- } {
- dup 0 gt {
- { pop } repeat
- }{
- pop
- } ifelse
- } ifelse
- } {
- pop
- } ifelse
-
- /pdfemptycount exch store
-} bind executeonly def
-
-/.beginformgroup { % groupdict bbox .beginformgroup -
- exch mark exch % bbox mark groupdict
- dup /CS knownoget { resolvecolorspace dup setgcolorspace /CS exch 3 2 roll} if
- dup /I knownoget { /Isolated exch 3 2 roll } if
- dup /K knownoget { /Knockout exch 3 2 roll } if
- pop .dicttomark
- % Stack: bbox paramdict
- exch aload pop
- .begintransparencygroup
-} bind executeonly def
-
-/.beginpagegroup { % groupdict bbox .beginformgroup -
- currentcolorspace 3 1 roll
- exch mark exch % bbox mark groupdict
- dup /CS knownoget { resolvecolorspace dup setgcolorspace /CS exch 3 2 roll} if
- dup /I knownoget { /Isolated exch 3 2 roll } if
- dup /K knownoget { /Knockout exch 3 2 roll } if
- pop .dicttomark
- % Stack: bbox paramdict
- exch aload pop
- .begintransparencypagegroup
- setcolorspace
-} bind executeonly def
-
-% .paintgroupform implements the Form PaintProc in the case where the
-% Form XObject dictionary includes a Group key. See .paintform below.
-/.paintgroupform { % <resdict> <stream> <formdict> .paintgroupform -
- %% Pass the current color space, and an array with the current color vales
- %% as arguments to .execgroup
- mark currentcolor counttomark array astore exch pop
- currentcolorspace 5 2 roll
- dup /Group oget dup type /dicttype eq {
- exch /BBox oget dup type /arraytype eq {
- % Stack: resdict stream groupdict bbox
- .beginformgroup
- .execgroup
- .endtransparencygroup
- }{
- ( **** Error: Form XObject has a BBox entry with an invalid type.\n) pdfformaterror
- ( Ignoring transparency Group, output may be incorrect.\n) pdfformaterror
- pop pop pop pop pop pop
- } ifelse
- } {
- ( **** Error: Form XObject has a Group entry with an invalid type.\n) pdfformaterror
- ( Ignoring transparency Group, output may be incorrect.\n) pdfformaterror
- pop pop pop pop pop pop
- } ifelse
-} bind executeonly def
-
-% Make an ImageType 103 (soft-masked) image.
-/makesoftmaskimage { % <datasource> <imagemask> <SMask> makesoftmaskimage
- % <datasource> <imagemask>, updates currentdict =
- % imagedict
- % See the ImageType 3 case of makemaskimage below.
- % SMask is a stream, another Image XObject.
- % Stack: datasource imagemask(false) smaskstreamdict
- PDFfile fileposition exch
- dup /Matte knownoget { /Matte exch def } if
- dup length dict makeimagedict pop
- % In order to prevent the two data sources from being
- % aliased, we need to make at least one a reusable stream.
- % We pick the mask, since it's smaller (in case we need to
- % read all its data now).
- % Stack: datasource imagemask(false) savedpos
- % maskdict is currentdict
- /DataSource DataSource mark
- /Intent 1
- /AsyncRead //true
- .dicttomark {.reusablestreamdecode} stopped {pop} if def
- PDFfile exch setfileposition
- currentdict end currentdict end
- 5 dict begin
- /ImageType 103 def
- /DataDict exch def
- dup /InterleaveType 3 put
- DataDict /Matte knownoget {
- /Matte exch def
- } if
- .currentalphaisshape
- { /ShapeMaskDict } { /OpacityMaskDict } ifelse exch def
- /ColorSpace DataDict /ColorSpace get def
-} bind executeonly def
-
-% ---------------- Color setting ---------------- %
-
-/01_1 [0 1] readonly def
-/01_3 [0 1 0 1 0 1] readonly def
-/01_4 [0 1 0 1 0 1 0 1] readonly def
-
-% The keys here are resolved (PostScript, not PDF) color space names.
-/csncompdict 9 dict begin
- /DeviceGray { pop 1 } bind executeonly def
- /DeviceRGB { pop 3 } bind executeonly def
- /DeviceCMYK { pop 4 } bind executeonly def
- /CIEBasedA //DeviceGray def
- /CIEBasedABC //DeviceRGB def
- /CalGray //DeviceGray def
- /CalRGB //DeviceRGB def
- /Lab //DeviceRGB def
- /ICCBased { 1 oget /N oget } bind executeonly def
- /Separation //DeviceGray def
- /DeviceN { 1 oget length } bind executeonly def
- /Indexed //DeviceGray def
-currentdict end readonly def
-
-% <colorspace> csncomp <n>
-/csncomp {
- dup dup type /arraytype eq { 0 oget } if
- //csncompdict exch get exec
-} bind executeonly def
-
-currentdict /csncompdict undef
-
-/ICCBased-resolve {
- PDFfile fileposition exch
- dup dup 1 oget
- mark exch { oforce } forall .dicttomark
- dup dup //true resolvestream
- {
- /ReusableStreamDecode filter
- } stopped
- {
- pop null
-% ( **** Error: Failed to read ICC profile for an ICCBased colour space.\n) pdfformaterror
-% ( Falling back to a colour space determined by the /N value.\n) pdfformaterror
- }if
- /DataSource exch put
- dup /.hash 0 put % placeholder for use by seticc icc_profile_cache key
- % Check that the number of components (/N) defined in the ICCBased
- % dictionry matches the actual profile. Bug #696120
- dup /N get
- 1 index
- %% If we get an error reading the profile, just assume that /N is correct
- %% If its genuinely faulty we will use an alternate based on /N.
- {.numicc_components} stopped {pop dup} if
- dup 3 -1 roll ne {
- %% /N and the actual number of components don't match. Ensure
- %% that we have a valid number of components from the ICC
- %% profile. Certain kinds of profile can't determine the numebr of components
- %% and in ths case we must not override the /N value.
- dup 0 gt {
- ( **** Error: ICCbased space /N value does not match the ICC profile.\n) pdfformaterror
- ( Using the number of channels from the profile.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- 1 index dup /N get /OrigN exch put
- 1 index exch /N exch put
- }{
- pop
- } ifelse
- } {
- pop
- } ifelse
-
- 1 exch put
- exch PDFfile exch setfileposition
- % Resolve alternate color space
- dup 1 get % Get colorspace dictionary
- dup /Alternate .knownget { % Check for alternate color space
- oforce resolvecolorspace /Alternate exch put % resolve and replace
- } {
- pop % remove colorspace dictionary
- } ifelse
-} bind executeonly def
-
-/csrdict 13 dict begin
- /DeviceGray { } bind executeonly def
- /DeviceRGB { } bind executeonly def
- /DeviceCMYK { } bind executeonly def
-
- /CalGray { 1 oget [ exch /CalGray exch ] } bind executeonly def
- /CalRGB { 1 oget [ exch /CalRGB exch ] } bind executeonly def
- /Lab { 1 oget [ exch /Lab exch ] } bind executeonly def
-
- /CalCMYK {
- pop /DeviceCMYK % not defined by Adobe
- } bind executeonly def
-
- /ICCBased {
- dup 1 get type /dicttype ne { % don't resolve more than once
- ICCBased-resolve
- } if
- } bind executeonly def
-
- /Separation {
- aload pop exch oforce resolvecolorspace
- % Contrary to PDF manuals up to v.1.5, Acrobat Distiller 3.01
- % can use /Identity name here instead of a function.
- exch oforce resolveidfnproc
-
- %% Make sure the ink name is not an indirect object....
- 3 -1 roll oforce 3 1 roll
-
- 4 array astore
- } bind executeonly def
-
- /DeviceN {
- [ exch aload pop ] % Copy into a new array
- dup dup 1 oget % Resolve Names array
- [ exch { oforce } forall ] % resolve each of the names
- 1 exch put
- dup dup 2 oget resolvecolorspace
- 2 exch put
- dup dup 3 oget resolvefnproc
- 3 exch put
- dup length 4 gt { % Check for attributes dict
- dup dup 4 oget % devn_array devn_array attr_dict
- dup /Colorants knownoget % Check for Colorants Dict
- { % Create a new attribute dict with only a Colorants dict entry.
- % Resolve all of the Colorant dict entries. This is needed
- % to prevent a conflict if we attempt to resolve the tint
- % transform functions of the Colorant color spaces multiple
- % times.
- exch pop % Remove old attributes dict
- << exch % Start new attributes dict
- % Build new Colorants dict with resolved entries
- << exch { oforce resolvecolorspace } forall >>
- /Colorants exch >> % Finish new attributes dict
- } if
- % devn_array devn_array <<..attributes..>>
- 1 index 4 oget /Process knownoget {
- dup /ColorSpace knownoget {
- 1 index exch resolvecolorspace /ColorSpace exch put
- } if
- % devn_array devn_array <<..attributes..>> <<..Process..>>
- 1 index
- /Process 3 -1 roll
- put
- } if
- 4 exch put % Put resolved or new attributes dict
- } if
- } bind executeonly def
-
- /Indexed {
- aload pop
- %% Resolve 'hival' in case it is an indirect reference. This is kind of
- %% dumb, it just makes the file bigger, but it *is* legal.
- 3 1 roll oforce 3 -1 roll
-
- 1 index -1 eq {
- exch pop 255 exch
- ( **** Error: Highest color index given as -1. Assuming this actually means 255.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } if
- 3 -1 roll oforce resolvecolorspace
- % Stack: /Indexed hival lookup basespace
- % If the underlying space is a Lab space, we must scale
- % the output of the lookup table as part of DecodeABC.
- dup dup type /arraytype eq { 0 get } if /CIEBasedABC eq {
- dup 1 get /DecodeLMN known {
- 1 get dup length dict copy
- begin /DecodeABC [ 0 2 4 {
- RangeABC 1 index 1 add get RangeABC 2 index get sub /mul load
- RangeABC 3 index get /add load
- DecodeABC 6 -1 roll 2 idiv get [ 6 1 roll aload pop ] cvx
- } for ] def
- /RangeABC //01_3 def
- currentdict end /CIEBasedABC exch 2 array astore
- } if
- } if
- 3 1 roll % Stack: /Indexed csp comp table
- oforce dup type /stringtype ne {
- % The color lookup table is a stream.
- % Get its contents. Don't lose our place in PDFfile.
- % Stack: /Indexed basespace hival lookup
- PDFfile fileposition 5 1 roll
- dup /Filter oknown not { % For Bug691941.pdf and similar lossage
- dup /Length knownoget not { 0 } if
- } {
- 0
- } ifelse
- % Stack: filepos /Indexed basespace hival lookup Length
- 2 index 1 add
- % Stack: filepos /Indexed basespace hival lookup Length len
- 4 index csncomp mul .max string
- % Stack: filepos /Indexed basespace hival lookup (...)
- exch //true resolvestream
- 1 index readstring not {
- % The string is padded with 0s
- ( **** Error: Short look-up table in the Indexed color space was padded with 0's.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } if
- pop
- % Stack: filepos /Indexed basespace hival (...)
- PDFfile 6 -1 roll setfileposition
- } if
- 4 array astore
- % Stack: [filepos /Indexed basespace hival (...)]
- % Replace the PDFColorSpace with the Indexed space if needed.
- dup 1 get
- dup type /arraytype eq {
- dup length 2 ge {
- dup 1 get type /dicttype eq {
- dup 1 get /PDFColorSpace known {
- dup 1 get /PDFColorSpace 3 index put
- } if
- } if
- } if
- } if pop
- } bind executeonly def
-
- /I { % Bug 689815
- ( **** Error: The name /Indexed cannot be abbreviated to /I in the color space\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- dup 0 /Indexed put
- //Indexed exec
- } bind executeonly def
-
- /Pattern {
- dup type /nametype ne {
- dup length 1 gt {
- 1 oget resolvecolorspace
- /Pattern exch 2 array astore
- } if
- } if
- } bind executeonly def
-
-currentdict end readonly def
-
-/cssubst { % <csname> cssubst <cspace'> true
- % <csname> cssubst false
- dup resolvecolorspace
- dup 1 index ne { exch pop //true } { pop pop //false } ifelse
-} bind executeonly def
-
-/csnames mark
- /DeviceGray dup /DeviceRGB dup /DeviceCMYK dup /Pattern dup
-.dicttomark readonly def
-/csresolve { % <csresourcename> csresolve <cspace> <true> | <false>
- dup type /nametype ne {
- (\n **** Error: CS/cs (setcolorspace) operand not a name: ) pdfformaterror
- dup stderrfile dup 3 -1 roll write==only flushfile
- ( ****\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- dup type /arraytype eq { % Adobe InDesign + PDF Library has array
- resolvecolorspace
- } if //true
- } {
- dup Page /ColorSpace rget {
- exch pop resolvecolorspace //true
- } {
- //csnames 1 index known {
- //true
- } {
- ( **** Error: Undefined space resource: /)
- exch .namestring concatstrings (\n) concatstrings pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- //false
- } ifelse
- } ifelse
- } ifelse
-} bind executeonly def
-
-/resolvecolorspace { % <cspace> resolvecolorspace <cspace'>
- dup type /dicttype eq {
- dup /N known {
- ( **** ICCBased color space is a bare stream dictionary\n) pdfformatwarning
- [ /ICCBased 3 -1 roll ] ICCBased-resolve exec
- //false
- } {
- dup /ColorSpace knownoget {
- ( **** Error: unrecognised color space <</ColorSpace /Device...>>\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- exch pop //true
- } {
- //true
- } ifelse
- } ifelse
- } {
- //true
- } ifelse {
- dup dup type /arraytype eq { 0 get } if
- dup type /packedarraytype eq {exch pop exec dup} if
-
- //csrdict exch .knownget {
- exec dup type /nametype ne { dup length 1 eq { 0 get } if } if
- } {
- dup type /nametype eq {
- csresolve not { /DeviceRGB } if % Arbitrary
- } {
- csset exch pop
- } ifelse
- } ifelse
- } if
-} bind executeonly def
-
-/scresolve { % <c0> ... scresolve <multi>
- % We can't really make sc[n] and SC[N] work, because
- % the color space information isn't available at
- % conversion time; so we hack it by assuming that
- % all the operands on the stack are used, and that
- % if the top operand is a name, it's a Pattern resource.
- dup type /nametype eq
- { Page /Pattern rget { resolvepattern } { //null } ifelse }
- if
- dup type /dicttype eq {
- % Check the PaintType, if any (shading patterns don't
- % have one).
- dup /PaintType knownoget { 2 eq } { //false } ifelse
- } {
- .pdfcount 1 gt
- } ifelse
-} bind executeonly def
-
-%% Bug #696017 When we begin a text block, we switch to a special set of marking operations
-%% for paths, these ops don't use the current CTM, but the 'SavedTextMatrix', in order to
-%% correctly position marks which are illegally present inside a text block. But, if we are
-%% executing a PaintProc (eg for a pattern) we *don't* want to do that or the pattern will be wrong.
-%% So we moved the .pdfpaintproc to .actual_pdfpaintproc, and redefined .pdfpaintproc to test
-%% the current value of /m. We always switch to the regular marking operations, but if the definition
-%% of /m at the start of the PaintProc was a special text version, then we switch back to that after we
-%% finished running the PaintProc.
-
-/.actual_pdfpaintproc { % <patdict> <resdict> .pdfpaintproc -
- % Check the object number of the pattern, from the pattern dictionary. Somehow
- % there is a means to get here with no object number set, I have no idea how
- % but this solves the immediate problem. Hopefully good enough until we drop
- % this code. Fixes bug #704487 which is recursion caused by a pattern
- % referenced via resolving a name from a Page as it is not defined in the Form
- % which uses it.
- 1 index /.gs.pdfobj# known {
- 1 index /.gs.pdfobj# get
- }
- {
- 0
- } ifelse
- 3 1 roll
- NestedPatterns 3 index known 3 index 0 ne and
- {
- PDFSTOPONERROR not {
- ( **** Error: Attempting to run a Pattern while already executing that Pattern.\n Ignoring this pattern, output may be incorrect.\n) pdfformaterror
- pop pop pop
- }
- {
- /PaintProc cvx /circular_reference signalerror
- } ifelse
- }
- {
- % Store the currnet object number in the dictionary just so we can find it later.
- NestedPatterns 3 index null put
- PDFDEBUG { //pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Begin PaintProc) print dup === flush } if } if
- PDFfile fileposition 3 1 roll
- q
- 1 index /PaintType oget 1 eq {
- % For colored patterns, set default fill and stroke colors.
- 0 g 0 G
- } {
- % For uncolored patterns, we have to unbind the current
- % color and color space before running the PaintProc.
- % Not true since moving the ExtGState parameters into the gstate.
- % //null sc1 //null SC1
- } ifelse
-
- % Save old values on opstack, set pdfemptycount to new value.
- pdfemptycount countdictstack mark
-
- %% We can't simply 'def' into the dictionary saved by 'q' above, we need to
- %% call gput to copy it and store inside it. Stupid or what....
- /pdfemptycount count 3 sub gput 5 3 roll
- %
- % Stack: ... <old emptycount> <dictcount> mark <patdict> <resdict>
- % |
- % New empty count points here -----------+
-
- exch //false resolvestream pdfopdict .pdfruncontext
- cleartomark
-
- //false
- { countdictstack
- 2 index le { exit } if
- currentdict /n known not or
- currentdict /n known currentdict /self known or{
- Q
- }{
- (\n **** Error: File has unbalanced q/Q operators \(too many Q's\)\n Output may be incorrect.\n)
- //pdfdict /.Qqwarning_issued .knownget
- {
- {
- pop
- }
- {
- currentglobal //pdfdict gcheck .setglobal
- //pdfdict /.Qqwarning_issued //true .forceput
- .setglobal
- pdfformaterror
- } executeonly ifelse
- } executeonly
- {
- currentglobal //pdfdict gcheck .setglobal
- //pdfdict /.Qqwarning_issued //true .forceput
- .setglobal
- pdfformaterror
- } executeonly ifelse
- end
- } executeonly ifelse
- } executeonly loop
- {
- (\n **** Error: File has unbalanced q/Q operators \(too many q's\)\n Output may be incorrect.\n)
- //pdfdict /.Qqwarning_issued .knownget
- {
- {
- pop
- }
- {
- currentglobal //pdfdict gcheck .setglobal
- //pdfdict /.Qqwarning_issued //true .forceput
- .setglobal
- pdfformaterror
- } executeonly ifelse
- } executeonly
- {
- currentglobal //pdfdict gcheck .setglobal
- //pdfdict /.Qqwarning_issued //true .forceput
- .setglobal
- pdfformaterror
- } executeonly ifelse
- } executeonly if
- pop
-
- % restore pdfemptycount
- /pdfemptycount exch def
-
- Q
- PDFDEBUG { //pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%End PaintProc) print dup === flush } if } if
- PDFfile exch setfileposition
- NestedPatterns exch undef
- }ifelse
-} bind executeonly odef
-
-/.pdfpaintproc {
- % Copy the pattern dictionary, we need it to rewind the /File if it is a file
- % rather than a string, after we've run .actual_pdfpaintproc. If we don't reset
- % the file position then if we try to run the PaintProc again we will already be
- % at EOF and nothing will be executed.
- 1 index 3 1 roll
-
- %% Get the /m from pdfopdict (must be present)
- %% and check its a packedarray
- pdfopdict /m get dup type /packedarraytype eq {
- %% The non-text version of /m is executeonly, so if we can't read it, its not a text block.
- dup rcheck {
- %% get the initial element of the packedarray
- %% and check its a name
- 0 get dup type /nametype eq {
- %% If the name is inside_text_m then we are in a text block
- /inside_text_m eq
- }{
- pop //false
- } ifelse
- }{
- pop //false
- } ifelse
- }{
- pop //false
- } ifelse
- %% rearrange the operands, move the boolean to the back
- 3 1 roll
- %% Unconditionally use the normal marking ops
- switch_to_normal_marking_ops
- .actual_pdfpaintproc
- %% If we were in a text block, restore the text marking ops.
- {
- switch_to_text_marking_ops
- } if
-
- % If the pattern dictionary has a /File (it should always but let's be safe)
- % *and* the /File is a file object, not a string, then we need to set the
- % position of that file (it's a subfiledecode filter) back to 0 so we can
- % run the PaintProc again, should we need to.
- % cf bug #704388
- /File .knownget {
- dup type /filetype eq
- {
- 0 setfileposition
- }
- {
- pop
- } ifelse
- } if
-}bind executeonly odef
-
-/resolvepattern { % <patternstreamdict> resolvepattern <patterndict>
- % Don't do the resolvestream now: just capture the data
- % from the file if necessary.
- dup length dict copy
- dup /FilePosition .knownget {
- 1 index /File get dup fileposition 3 1 roll
- % Stack: dict savepos pos file
- dup 3 -1 roll setfileposition
- dup 3 index /Length knownoget {
- dup 65535 le {
- dup 0 eq {
- pop pop ()
- } {
- string readstring pop
- } ifelse
- } {
- () /SubFileDecode filter /ReusableStreamDecode filter
- } ifelse
- } {
- 0 (endstream) /SubFileDecode filter /ReusableStreamDecode filter
- } ifelse
- % Stack: dict savepos file string
- 3 1 roll exch setfileposition
- 1 index /File 3 -1 roll put
- dup /FilePosition undef
- } if
- dup /Shading knownoget {
- resolveshading 1 index /Shading 3 -1 roll put
- } if
- dup /PaintProc [
- % Bind the resource dictionary into the PaintProc.
- 2 index /Resources knownoget { oforce } { 0 dict } ifelse
- /.pdfpaintproc cvx
- ] cvx put
- dup /BBox 2 copy knownoget { normrect FixPatternBBox put } { pop pop } ifelse
- dup /.pattern_uses_transparency 1 index patternusestransparency put
-
- % Regardless of whether we are using transparency, if we are doing Overprint
- % simulation we still need to have the pattern code push the pdf14 compositor.
- % We consider we are doing overprint simulation if:
- % The current page device has /Overprint set to /simulate
- % The current page device does NOT contain PageSpotColors (spot-capable devices can overprint)
- % The current page device has a /PageUsesOverprint key (set by the interpreter) and it is set to true
- % If all these conditions are true then we set /.pattern_uses_transparency, otherwise we leave it
- % untouched as set above.
- %
- currentpagedevice dup
- /Overprint .knownget {/simulate eq}{false} ifelse
- 1 index /PageSpotColors known not and
- exch /PageUsesOverprint .knownget not { //false } if
- and
- {
- dup /.pattern_uses_transparency //true put
- } if
-
- PDFDEBUG { //pdfdict /PDFSTEPcount .knownget { 1 le } { //true } ifelse { (%Pattern: ) print dup === flush } if } if
-} bind executeonly def
-
-/ignore_color_op ( **** Error: Ignoring a color operation in a cached context.\n Output may be incorrect.\n) readonly def
-
-drawopdict begin
- /g { .incachedevice { % Bug 689302
- pop //ignore_color_op pdfformaterror
- } {
- /DeviceGray cssubst { cs sc1 } { g } ifelse
- } ifelse
- } bind executeonly def
-
- /rg { .incachedevice {
- pop pop pop //ignore_color_op pdfformaterror
- } {
- /DeviceRGB cssubst { cs sc* } { rg } ifelse
- } ifelse
- } bind executeonly def
-
- /k { .incachedevice {
- pop pop pop pop //ignore_color_op pdfformaterror
- } {
- k
- } ifelse
- } bind executeonly def
-
- /cs { .incachedevice {
- pop //ignore_color_op pdfformaterror
- } {
- csresolve { cs } if
- } ifelse
- } bind executeonly def
-
- /sc { .incachedevice {
- .pdfcount { pop } repeat //ignore_color_op pdfformaterror
- } {
- scresolve 1 index //null eq {
- pop pop
- //ignore_color_op pdfformaterror
- } {
- { sc*_and_set } { sc1_and_set } ifelse
- } ifelse
- } ifelse
- } bind executeonly def
-
- /scn /sc load def
-
- /G { .incachedevice {
- pop //ignore_color_op pdfformaterror
- } {
- /DeviceGray cssubst { CS SC1 } { G } ifelse
- } ifelse
- } bind executeonly def
-
- /RG { .incachedevice {
- pop pop pop //ignore_color_op pdfformaterror
- } {
- /DeviceRGB cssubst { CS SC* } { RG } ifelse
- } ifelse
- } bind executeonly def
-
- /K { .incachedevice {
- pop pop pop pop //ignore_color_op pdfformaterror
- } {
- K
- } ifelse
- } bind executeonly def
-
- /CS { .incachedevice {
- pop //ignore_color_op pdfformaterror
- } {
- csresolve { CS } if
- } ifelse
- } bind executeonly def
-
- /ri { .incachedevice {
- pop //ignore_color_op pdfformaterror
- } {
- ri
- } ifelse
- } bind executeonly def
-
- /SC { .incachedevice {
- .pdfcount { pop } repeat //ignore_color_op pdfformaterror
- } {
- scresolve 1 index //null eq {
- pop pop
- //ignore_color_op pdfformaterror
- }{
- { SC*_and_set } { SC1_and_set } ifelse
- }ifelse
- } ifelse
- } bind executeonly def
-
- /SCN /SC load def
-end
-
-currentdict /ignore_color_op undef
-
-% ---------------- Paths ---------------- %
-
-drawopdict begin
- % Path construction
- /m { { moveto } stopped { count pdfemptycount sub 2 .min { pop } repeat 0 0 moveto } if } bind executeonly def
- /l { { lineto } stopped { count pdfemptycount sub 2 .min { pop } repeat } if } bind executeonly def
- /c { { curveto } stopped { count pdfemptycount sub 6 .min { pop } repeat } if } bind executeonly def
-
- /v { count pdfemptycount sub 4 ge {
- { currentpoint 6 2 roll curveto } stopped { count pdfemptycount sub 6 .min { pop } repeat } if
- } {
- count pdfemptycount sub { pop } repeat
- } ifelse
- } bind executeonly def
- /y { { 2 copy curveto } stopped { count pdfemptycount sub 6 .min { pop } repeat } if } bind executeonly def
-
- /re {
- 4 2 roll moveto exch dup 0 rlineto 0 3 -1 roll rlineto neg 0 rlineto
- closepath
- } bind executeonly def
-
- /h { closepath } bind 0 get def
- % Path painting and clipping
- /n { n } executeonly def
- /S { S } executeonly def
- /s { s } executeonly def
- /f { f } executeonly def
- /f* { f* } executeonly def
- /B { B } executeonly def
- /b { b } executeonly def
- /B* { B* } executeonly def
- /b* { b* } executeonly def
- /W { W } executeonly def
- /W* { W* } executeonly def
-
- /sh_save 1 array def
-
- /do_shade {
- 0 .setoverprintmode
- { dup /.shading .knownget {
- exch pop
- } {
- .buildshading_and_shfill
- } ifelse
- } stopped {
- pop
- ( **** Error: Ignoring invalid smooth shading object, output may be incorrect.\n)
- pdfformaterror
- } if
- } bind executeonly def
-
- /sh {
- OFFlevels length 0 eq {
- setsmaskstate resolvesh
- //sh_save 0 save put
- PDFusingtransparency {
- gsave
- dup /BBox knownoget {
- { oforce } forall
- 4 2 roll moveto exch 0 lineto 0 exch lineto closepath
- } {
- clippath
- } ifelse
- % If we get an error, just emit an empty box
- { pathbbox } stopped { 0 0 0 0 } if
- 4 array astore
- grestore
- //null
- setup_trans
- //do_shade exec
- teardown_trans
- } {
- //do_shade exec
- } ifelse
- //sh_save 0 get restore
- } {
- pop
- } ifelse
- } bind executeonly def
- currentdict dup /sh_save undef /sh_group undef
-end
-
-% ---------------- XObjects ---------------- %
-
-/xobjectprocs mark % <dict> -proc- -
- /Image { DoImage } executeonly
- /Form { DoForm } executeonly
- /PS { DoPS } executeonly
-.dicttomark readonly def
-
-% Note that the keys in defaultdecodedict are resolved (PostScript, not PDF)
-% color space names.
-/defaultdecodedict mark
- /DeviceGray { pop //01_1 } bind executeonly
- /DeviceRGB { pop //01_3 } bind executeonly
- /DeviceCMYK { pop //01_4 } bind executeonly
- /CIEBasedA { 1 get /RangeA knownoget not { //01_1 } if } bind executeonly
- /CIEBasedABC { 1 get /RangeABC knownoget not { //01_3 } if } bind executeonly
- /CalGray { pop //01_1 } bind executeonly
- /CalRGB { pop //01_3 } bind executeonly
- /Lab { 1 get /Range knownoget not { [-100 100 -100 100] } {aload pop 0 100 6 2 roll 6 array astore}ifelse } bind executeonly
- /ICCBased {
- 1 oget dup /Range knownoget {
- exch pop
- }{
- /N get [ exch {0 1} repeat ] readonly
- } ifelse
- } bind executeonly
- /Separation { pop //01_1 } bind executeonly
- /DeviceN {
- 1 oget length [ exch {0 1} repeat ] readonly
- } bind executeonly
- /Indexed {
- pop [ 0 1 BitsPerComponent bitshift 1 sub ]
- } bind executeonly
-.dicttomark readonly def
-
-/checkaltimage { % <resdict> checkaltimage <resdict[']>
- Printed {
- dup /Alternates knownoget {
- {
- dup /DefaultForPrinting knownoget {
- {
- /Image oget exch pop exit
- } {
- pop
- } ifelse
- } {
- pop
- } ifelse
- } forall
- } if
- } if
-} bind executeonly def
-
-% <string> <index> getu16 <integer>
-/getu16 {
- 2 copy get 8 bitshift 3 1 roll 1 add get add
-} bind executeonly def
-
-% <string> <index> getu32 <integer>
-/getu32 {
- 2 copy getu16 16 bitshift 3 1 roll 2 add getu16 add
-} bind executeonly def
-
-/jp2_csp_dict mark
- 12 { /DeviceCMYK } % CMYK
- 14 { [ /Lab << /WhitePoint [ 0.9505 1 1.0890 ] readonly >> ] } % LAB, WhitePoint == D65
- 16 { /sRGBICC /ColorSpace findresource } bind executeonly
- 17 { /sGrayICC /ColorSpace findresource } bind executeonly
- 18 3 index % YCC is converted to RGB
-% 19 % CIEJab not supportec by PDF 1.7
- 20 { /esRGBICC /ColorSpace findresource } bind executeonly % e-sRGB
- 21 { /rommRGBICC /ColorSpace findresource} bind executeonly % ROMMRGB
- 24 { /esRGBICC /ColorSpace findresource } bind executeonly % e-sYCC
-.dicttomark readonly def
-
-% Process jp2 blocks (aka boxes). All procedures have the signature
-% <file> <length> -> ... <file> <flush_length>
-/jp2_tag_dict 10 dict begin
-
- /jp2h { % descend into a sub-stream, don't return.
- () /SubFileDecode filter 0
- } bind executeonly def
-
- /ihdr {
- 14 sub % file len-14
- 1 index (1234567890abcd) readstring pop % file len-14 (14)
- /JPXComponents 1 index 8 getu16 % file len-14 (14) /JPXComponents NC
- def % file len-14 (14)
- 10 get
- %% If the BPC is 255 then each component has variable depth
- %% we can't handle this, but JasPer is known to produce
- %% images whcih declare this, but are actually all equal, we cater
- %% for that in the bpcc box below.
- dup 16#FF eq not {
- 16#7F and 1 add
- dup 12 eq { pop 16 } if
- /BitsPerComponent exch def % file len-14
- } {pop} ifelse
- } bind executeonly def
-
- %% if the ihdr has a BPC of 255 then we get a bpcc box which
- %% gives the bpc for each component individually. We cannot
- %% actually deal with differing component depths, but it
- %% seems JasPer produces images with this box where all the
- %% component depths are in fact the same.
- /bpcc {
- JPXComponents sub
- 1 index JPXComponents string readstring pop
- dup 0 get /BitsPerComponent exch def
- 1 1 JPXComponents 1 sub {
- 1 index exch get BitsPerComponent eq not {
- ( **** Error: JPX image colour channels do not all have the same colour depth\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } if
- } for
-
- pop
- /BitsPerComponent BitsPerComponent 1 add def
- } bind executeonly def
-
- /colr {
- currentdict /ColorSpace known not {
- 3 sub
- 1 index (123) readstring pop % file len-3 (3)
- 0 get dup 1 eq {
- pop 4 sub % file len-7
- 1 index (1234) readstring pop % file len-16 (4)
- 0 getu32 % file len-16 enum
- //jp2_csp_dict exch .knownget {
- exec /ColorSpace exch def % file len-7
- } {
- ( **** Error: Unknown enumerated color space in JPX stream.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- } {
- dup 2 eq exch 3 eq or {
- 1 index exch () /SubFileDecode filter /ReusableStreamDecode filter
- /JPXICC exch def
- 0 % file 0
- } {
- ( **** Error: Unknown color space method in JPX stream.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- } ifelse
- } if
- } bind executeonly def
-
- % Palette colors are decoded by the library.
- /pclr {
- 4 sub
- 1 index (1234) readstring pop
- 3 get 16#7F and 1 add
- /BitsPerComponent exch def
- } bind executeonly def
-
- /cdef {
- pop
- dup (12) readstring pop
- 0 getu16 {
- dup (123456) readstring pop
- 2 getu16
- dup 3 lt {
- { /JPXColors /JPXOpacity /JPXPremult } exch get
- currentdict 1 index .knownget { 1 add } { 1 } ifelse def
- } {
- pop
- } ifelse
- } repeat
- 0
- } bind executeonly def
-
-currentdict end readonly def
-
-% Parse jp2 file format to get color space and image depth info.
-% <file> get_jp2_csp -
-/get_jp2_csp {
- {
- dup (01234567) readstring pop % f (LBoxTBox)
- dup length 8 lt {
- pop exit
- } if
- dup 4 4 getinterval exch % f (TBox) (LBoxTBox)
- 0 getu32 % f (TBox) LBox
- dup 0 eq {
- pop pop exit % cannot happen
- } {
- dup 1 eq {
- pop 1 index (01234567) readstring pop
- 4 getu32 % f (TBox) LBox
- 16 sub
- } {
- 8 sub
- } ifelse
- } ifelse % f (TBox) LBox-8..16
-
- PDFDEBUG {
- 2 copy 2 packedarray //== exec % f (TBox) LBox-8..16
- } if
-
- //jp2_tag_dict 3 -1 roll .knownget {
- exec
- } if % f flush
-
- dup 0 ne {
- 1 index exch % f f flush
- () /SubFileDecode filter flushfile % skip unwanted blocks
- } {
- pop
- } ifelse
- } loop
- pop
-} bind executeonly def
-
-currentdict /jp2_tag_dict .undef
-currentdict /jp2_csp_dict .undef
-
-% Add a key-value pair to the last /DecodeParms dictionary
-% Copy the objects to avoid spoiling shared ones.
-% <resdict> <key> <value> -> <resdict>
-/add-to-last-param {
- 2 index /DecodeParms knownoget {
- dup type /dicttype ne 1 index type /arrratype ne and 1 index length 1 lt or {
- pop //false
- } {
- //true
- } ifelse
- } {
- //false
- }
- ifelse
- {
- dup type /arraytype eq {
- [ exch { oforce } forall
- dup //null eq { pop 1 dict } if
- ]
- dup dup length 1 sub get % <resdict> <key> <value> [] <<>>
- } {
- dup length 1 add dict copy dup % <resdict> <key> <value> <<>> <<>>
- } ifelse
- 4 2 roll put % <resdict> obj
- } {
- % <resdict> <key> <value>
- mark 3 1 roll .dicttomark % <resdict> obj
- 1 index /Filter knownoget {
- dup type /arraytype eq {
- length array % <resdict> obj [...]
- dup dup length 1 sub % <resdict> obj [...] [...] len-1
- 4 -1 roll put % <resdict> [... obj]
- } {
- pop
- } ifelse
- } if
- } ifelse
- 1 index exch
- /DecodeParms exch put % <resdict>
-} bind executeonly def
-
-% Add a key-value pair to the all the /DecodeParms
-% dictionaries (i.e. handle the array)
-% Copy the objects to avoid spoiling shared ones.
-% <resdict> <patch dict> -> <resdict>
-/add-to-all-params {
- 1 index % <resdict> <patch dict> <resdict>
- /Filter knownoget
- { % <resdict> <patch dict> </name or [array]>
- dup type /arraytype eq
- {
- length % <resdict> <patch dict> <len>
- dup 0 gt
- {
- 2 index /DecodeParms
- knownoget
- {
- oforce_recursive % resolve indirect references
- exch pop % <resdict> <patch dict> [array]
- [
- exch
- {
- dup type /dicttype eq
- {
- mark exch {} forall .dicttomark
- }
- {
- pop 1 dict
- } ifelse
- } forall
- ] % <resdict> <patch dict> [array]
- }
- { % <resdict> <patch dict> <len>
- % create an array of dictionaries
- [
- 0 1 4 -1 roll 1 sub
- { pop 1 dict } for
- ]
- % <resdict> <patch dict> [array]
- } ifelse
- dup % <resdict> <patch dict> [array] [array]
- { % <resdict> <patch dict> [array] [dict]
- 2 index % <resdict> <patch dict> [array] [dict] <patch dict>
- { % <resdict> <patch dict> [array] [dict] </key> <value>
- 2 index % <resdict> <patch dict> [array] [dict] </key> <value> [dict]
- 3 1 roll
- put
- } forall
- pop
- } forall
- % <resdict> <patch dict> [array]
- exch pop
- % <resdict> [dict/array]
- 1 index exch /DecodeParms exch put
- }
- {
- pop pop
- } ifelse
- }
- { % <resdict> <patch dict> </name>
- pop
- 1 index
- /DecodeParms knownoget
- {
- oforce_recursive
- dup type /dicttype eq
- {
- mark exch {} forall .dicttomark
- }
- {
- pop 1 dict
- } ifelse
- }
- {
- 1 dict
- } ifelse % <resdict> <patch dict> [dict]
-
- 1 index % <resdict> <patch dict> [dict] <patch dict>
- { % <resdict> <patch dict> [dict] </key> <value>
- 2 index
- 3 1 roll put
- } forall
- exch pop
- % <resdict> [dict/array]
- 1 index exch /DecodeParms exch put
- } ifelse
- }
- {pop} ifelse
-} bind def
-
-/last-ditch-bpc-csp {
- currentdict /BitsPerComponent oknown not {
- ( **** Error: image has no /BitsPerComponent key; assuming 8 bit.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- /BitsPerComponent 8 def
- } if
-
- currentdict /ColorSpace knownoget not {
- dup /ColorSpace knownoget not {
- ( **** Error: image has no /ColorSpace key; assuming /DeviceRGB.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- /DeviceRGB
- } if
- } if
- resolvecolorspace
-
- %% This section is to deal with the horrible pair of files in Bug #696690 and Bug #696120
- %% These files have ICCBased spaces where the value of /N and the number of components
- %% in the profile differ. In addition the profile in Bug #696690 is invalid. In the
- %% case of Bug #696690 the /N value is correct, and the profile is wrong, in the case
- %% of Bug #696120 the /N value is incorrect and the profile is correct.
- %% We 'suspect' that Acrobat uses the fact that Bug #696120 is a pure image to detect
- %% that the /N is incorrect, we can't be sure whether it uses the profile or just uses
- %% the /N to decide on a device space. What we now do is; If the /N and device profile
- %% number of components don't match, we assume the device profile is correct and patch
- %% /N to be the same as the profile (see /ICCBased-resolve), but we save the original
- %% value of /N in /OrigN. In setcolor, if the space is a genuine ICCBased space
- %% (not a replacement for a device profile) we call set_dev_color which will actually
- %% exercise the profile. If that fails we return an error. Here we run setcolor in a
- %% stopped context, and if it fails we check to see if there is a /OrigN (ths occurs
- %% only if the /N was different to the number of components in the profile). If there
- %% is a /OrigN then prefer that to the profile, otherwise they agreed, so just use
- %% /N and select a device space. If we can't select a device space with the correct
- %% number of components, give up and throw an error. See also 'Cdict' in pdf_ops.ps.
- dup type /arraytype eq {
- dup 0 get /ICCBased eq {
- gsave
- dup setcolorspace dup 1 get /N get
- 1 sub mark exch 0 1 3 -1 roll
- {pop 0} for
- {setcolor} stopped
- grestore
- {
- cleartomark
- 1 get
- dup /OrigN .knownget {exch pop}{/N get} ifelse
- [//null /DeviceGray //null /DeviceRGB /DeviceCMYK] exch
- {get} stopped
- {
- ( **** Error: Unable to set an ICCBased colour space, and cannot set an alternate from the number of components.\n) print
- /setcolorspace cvx /undefined signalerror
- }
- {
- dup //null eq {
- ( **** Error: Unable to set an ICCBased colour space, and cannot set an alternate from the number of components.\n) print
- /setcolorspace cvx /undefined signalerror
- }{
- ICCProfileNError not {
- ( **** Warning : Error setting an ICCBased colour space, using /N to set an alternate device space.\n) print
- ( Output may be incorrect.\n) print
- } if
- } ifelse
- }ifelse
- /ICCProfileNError //true def
- }{cleartomark}ifelse
- } if
- } if
- /ColorSpace exch def
-} bind executeonly def
-
-/get-smask-in-data { % <dict> -> <int>
- /SMaskInData knownoget {
- dup dup 1 ne exch 2 ne and {
- pop 0
- } if
- } {
- 0
- } ifelse
-} bind executeonly def
-
-/makeimagedict { % <resdict> <newdict> makeimagedict <imagemask?>
- % On return, newdict' is currentdict
- begin
- /Width 2 copy oget def
- /Height 2 copy oget def
- % Handle missing BitsPerComponent later.
- /BitsPerComponent 2 copy knownoget { cvi def } { pop } ifelse
- /Interpolate 2 copy knownoget { def } { pop } ifelse
- makeimagekeys
-} bind executeonly def
-
-/makeimagekeys { % <resdict> makeimagekeys <imagemask>
- % newdict is currentdict
- % Assumes Width, Height, BPC, Interpolate already copied.
- /ImageType 1 def
- /ImageMatrix Width 0 0
- % Handle 0-height images specially.
- Height dup 0 eq { pop 1 } if neg 0 1 index neg
- 6 array astore def
-
- %% If the image has a rendering intent, get its numeric equivalent
- %% from renderingintentdict, and save it in the dictionary we pass
- %% on to render images.
- dup /Intent knownoget {
- //.renderingintentdict exch .knownget { /Intent exch def } if
- } if
-
- dup /ImageMask knownoget dup { and } if {
- % Image mask
- % Decode is required for the PostScript image operators.
- % AI8 writes bogus decode array [0 1 0 0 0 0 0 0]
- /Decode 2 copy knownoget { 0 2 getinterval } { //01_1 } ifelse def
- % BitsPerComponent is optional for masks.
- /BitsPerComponent 2 copy known { pop } { 1 def } ifelse
- % Even though we're going to read data,
- % pass false to resolvestream so that
- % it doesn't try to use Length (which may not be present).
-
- % Bug 701083: We add a /ErrsAsEOD key to the DecodeParms here too.
- <</ErrsAsEOD //true>> //add-to-all-params exec
- //false resolvestream /DataSource exch def
- //true
- } {
- % Opaque image
- dup /Filter knownoget {
- dup type /arraytype eq {
- dup length
- dup 0 gt {
- 1 sub get oforce
- } {
- pop
- } ifelse
- } if
- /JPXDecode eq
- } {
- //false
- } ifelse {
- % /JPXDecode tricks
-
- % Previously we only ran the code to extract the Color Space and Bits Per Component
- % from the JOX stream if the image dict had either BPC or ColorSpace undefined.
- % However, while this is correct for the ColorSpace, its *not* correct for the BPC.
- % According to the spec we should ignore any BPC in the image dicitonary and
- % always use the BPC from the JPX stream.
- % Now the code in get_jp2_csp always overwrites the ColorSpace (in the image resource dict)
- % which technically is fine, because the image dictionary entry must be either not present or the
- % same as the JPX stream. However, this doesn't work, so instead we just save the existing
- % color space (if any). Then after extracting the color space and BPC from the JPX stream
- % we put back the saved color space, but only if there was one previously.
- dup /ColorSpace oknown {
- dup dup /ColorSpace get /ImageDictColorSpace exch put
- } if
- dup /IDFlag known {
- ( **** Warning: PDF spec bans inline JPX images.\n) pdfformatwarning
- % Inline stream is not positionable. Cannot get ColorSpace.
- } {
- % Drop the last filter (JPXDecode) from the pipeline
- dup dup length dict copy
- dup /Filter oget
- dup type /arraytype eq {
- dup length 1 gt {
- dup length 1 sub 0 exch getinterval
- 1 index exch /Filter exch put
-
- dup /DecodeParms knownoget {
- dup type /arraytype eq {
- dup length 1 gt {
- dup length 1 sub 0 exch getinterval
- 1 index exch /DecodeParms exch put
- } {
- pop
- dup /DecodeParms undef
- } ifelse
- } {
- pop
- dup /DecodeParms undef
- } ifelse
- } if
- } {
- pop
- dup /Filter undef
- dup /DecodeParms undef
- } ifelse
- } {
- pop
- dup /Filter undef
- dup /DecodeParms undef
- } ifelse
-
- //false resolvestream get_jp2_csp
-
- currentdict /ColorSpace oknown not {
- currentdict /JPXICC .knownget {
- [ /ICCBased mark
- /DataSource 5 -1 roll
- /N currentdict /JPXColors .knownget not {
- currentdict /JPXComponents get
- } if
- .dicttomark
- ] /ColorSpace exch def
- } if
- } if
-
- { /JPXICC /JPXColors /JPXComponents /JPXOpacity /JPXPremult } {
- currentdict exch undef
- } forall
-
- } ifelse
-
- % If we had a Color Space in the image dictionary before we read the JPX
- % stream, put it back now. We mujst do this before last-ditch-bpc-csp
- % because that resolves any indirect references to the color space.
- dup /ImageDictColorSpace known {
- dup /ImageDictColorSpace get currentdict /ColorSpace 3 -1 roll put
- } if
-
- //last-ditch-bpc-csp exec
-
- dup /ColorSpace oknown {
- % Propagate known color space to the filter
- /ColorSpace currentdict /ColorSpace get //add-to-last-param exec
- } if
-
- /Decode 2 copy knownoget not {
- ColorSpace //defaultdecodedict
- ColorSpace dup type /arraytype eq { 0 get } if get exec
- } if def
-
- dup get-smask-in-data dup 0 ne {
- PDFusingtransparency {
- currentdict dup length dict copy begin
- {/Mask/SMask/SMaskInData/Name} { currentdict exch undef } forall
- 2 eq {
- /Matte [ Decode length 2 idiv { 0 } repeat ] def
- } if
- /Decode //01_1 def
- /ColorSpace /DeviceGray def
- {/File /FilePosition /Filter /Length /DecodeParms /FFilter /FDecodeParms } {
- 2 copy knownoget {
- def
- } {
- pop
- } ifelse
- } forall
- currentdict /Alpha //true //add-to-last-param exec pop
- /SMask currentdict end def
- } {
- pop
- } ifelse
- } {
- pop
- } ifelse
- } { % not JPX image
- //last-ditch-bpc-csp exec
- /Decode 2 copy knownoget not {
- ColorSpace //defaultdecodedict
- ColorSpace dup type /arraytype eq { 0 get } if get exec
- } if def
-
- } ifelse % fi JPX tricks
-
- % Add a /Height key containing the image height to the DecodeParms
- % for any Filters we will apply. If there are no DecodeParms for any
- % filter, create one and add a /Height key. This is to solve the problem
- % in Bug #695116 where a JPEG image has a bad height, which is later
- % fixed up using a DNL marker. By placing the image height from the
- % PDF in the DecodeParms we can use it in the DCTDecode filter to
- % work around this.
- % Bug 701083: We add a /ErrsAsEOD key to the DecodeParms here too.
- << /Height 2 index /Height oget round cvi /ErrsAsEOD //true >> //add-to-all-params exec
-
- % Even though we're going to read data,
- % pass false to resolvestream so that
- % it doesn't try to use Length (which may not be present).
- //false resolvestream /DataSource exch def
- //false
- } ifelse
-} bind executeonly def
-
-currentdict /add-to-last-param undef
-currentdict /add-to-all-params undef
-currentdict /last-ditch-bpc-csp undef
-
-/DoImage {
- %% Bug #696439. This is incredibly icky. When we find indirect obects we resolve them
- %% and store the resolved object in the containing object. This means that we retain
- %% the image dicionary here until the end of job. Potentially wasteful. Even worse though
- %% is the case where the image has a ColorSpace which is not an indirect object, but *is*
- %% an ICCBased colour space. In ths case we end up resolving the colour space and storing it
- %% here. Unfortunately, we use a ReusableStreamDecode filter on the ICC profile, which means
- %% we end up retaining the memory for that too. ICC profiles can be large, and if there are a
- %% lot of places where they get used, we can exhaust memory.
- %% Here we check if the ColorSpace is an array object, if it is we *copy* the image dictionary
- %% and use the copy instead. The copy is (eventually) discarded so we don't retain the ICC profile
- %% and don't exhaust memory. Note that we have to copy the actual colour space array too, copying
- %% the dictionary just copies the opriginal array as well.
- %%
- 1 dict begin
- /.ImageDictStackDepth countdictstack def
- /.ImageOpStackDepth count 2 sub def
- {
- dup /ColorSpace known {
- dup /ColorSpace get dup type /arraytype eq {
- exch dup length dict copy exch
- dup length array copy /ColorSpace exch 2 index 3 1 roll put
- } {pop} ifelse
- } if
-
- checkaltimage dup length 6 add dict % <<image>> <<>>
- 1 index /SMask knownoget { % <<image>> <<>> <<sm>>
- dup 3 index ne { % <<image>> <<>> <<sm>> <<sm>>
- 1 index exch /SMask exch put
- } {
- pop
- ( **** Error: ignoring recursive /SMask attribute.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- } if
- 1 index /Mask knownoget {
- dup type dup /dicttype eq exch /arraytype eq or { % Bug #703681
- 1 index exch /Mask exch put
- } {
- pop
- ( **** Error: Ignoring Mask attribute that is not an array or a dictionary.\n)
- pdfformaterror
- } ifelse
- } if
- makeimagedict doimagesmask
- } PDFSTOPONERROR {exec false}{stopped} ifelse
- {
- (\n **** Error: File encountered ')
- $error /errorname get dup length string cvs concatstrings
- (' error while processing an image.\n) concatstrings
- ( Output may be incorrect.\n) concatstrings
- pdfformaterror
- } if
- count .ImageOpStackDepth sub {pop} repeat
- countdictstack .ImageDictStackDepth sub {end} repeat
- end
-} bind executeonly def
-/makemaskimage { % <datasource> <imagemask> <Mask> makemaskimage
- % <datasource> <imagemask>, updates currentdict =
- % imagedict
- dup type /arraytype eq {
- /ImageType 4 def
- % Check that every element of the Mask is an integer.
- //false 1 index {
- type /integertype ne or
- } forall {
- oforce_array
- //false 1 index {
- type /integertype ne or
- } forall {
- (\n **** Error: Some elements of Mask array are not integers.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- [ exch { 0.5 add cvi } forall ] % following AR4, 5, 6 implementation
- } if
- } if
- % Check elements of array are within 0::(2**BitsPerComponent)-1
- % This is a PostScript error, but AR tries to fix the Mask.
- 1 BitsPerComponent bitshift 1 sub //false 2 index {
- % stack: max_value result_bool value
- dup 0 lt exch 3 index gt or or
- } forall exch pop
- {
- ( **** Error: Some elements of Mask array are out of range.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
-
- ColorSpace dup type /arraytype eq { 0 oget } if /Indexed eq
- BitsPerComponent 1 eq and
- {
- % AR9 treats Indexed 1 bpc images specially. Bug 692852 see also 697919 and 689717.
- dup 0 oget
- dup 0 lt exch 1 BitsPerComponent bitshift ge or {
- % First component is invalid - AR9 ignores the mask
- pop //null
- } {
- % Second component is invalid; AR9 replaces it with 1.
- [ exch 0 oget 1 ]
- } ifelse
- }
- {
- BitsPerComponent 1 eq {
- dup length 2 gt {
- % There are too many Mask entries, discard the Mask array
- pop //null
- }{
- % Bug 701468 and 689717, the latter requires us to set the Mask values
- % so that the value is calculated from the BPC, the other requires us
- % to ignore the Mask. The only difference between the two files is the
- % actual range of the Mask values. This may yet need more work.
- % Note! Both files are technically invalid....
-
- aload 3 1 roll eq {
- % There's only one Mask value, but its illegal, substitute with the
- % calculated maximum.
- [ exch { 1 BitsPerComponent bitshift 1 sub and } forall ]
- } {
- % The Mask values are not the same. This is a 2 colour image, if
- % we mask off any range then the result will be blank, so ignore the Mask
- pop //null
- } ifelse
- } ifelse
- } {
- % We think AR5, AR9 do this for most other cases. Originally Bug 690786,
- % but that is actually handled in the /Indexed case above.
- [ exch { 1 BitsPerComponent bitshift 1 sub and } forall ]
- } ifelse
- } ifelse
- } if
-
- dup //null ne {
- /MaskColor exch def
- } {
- pop
- /ImageType 1 def
- } ifelse
- } {
- % Mask is a stream, another Image XObject.
- % Stack: datasource imagemask(false) maskstreamdict
- PDFfile fileposition exch
- dup length dict makeimagedict pop
- % In order to prevent the two data sources from being
- % aliased, we need to make at least one a reusable stream.
- % We pick the mask, since it's smaller (in case we need to
- % read all its data now).
- % Stack: datasource imagemask(false) savedpos
- % maskdict is currentdict
- /DataSource DataSource mark
- /Intent 1
- /AsyncRead //true
- .dicttomark {.reusablestreamdecode} stopped {pop} if def
- PDFfile exch setfileposition
- currentdict end currentdict end
- 5 dict begin
- /ImageType 3 def
- /InterleaveType 3 def
- /DataDict exch def
- /MaskDict exch def
- /ColorSpace DataDict /ColorSpace get def
- } ifelse
-} bind executeonly def
-
-/doimagesmask { % <imagemask> doimagesmask -
- PDFusingtransparency not
- /PreserveSMask /GetDeviceParam .special_op { exch pop } { //false } ifelse
- or {
- % not using transparency OR the device supports SMask (e.g. pdfwrite)
- doimage
- } {
- currentdict /SMask knownoget {
- % We are doing transparency and SMask is present in the image
- % stack: <imagemask> <SMask>
- % Normalize /Matte attribute for .begintransparencymaskimage
- dup /Matte .knownget {
- oforce dup //null eq {
- pop dup /Matte undef
- } {
- 1 index /Matte [ 4 -1 roll { oforce } forall ] put
- } ifelse
- } if
- .begintransparencymaskimage
- PDFfile fileposition exch
- gsave //nodict begin
- //null .setSMask
- 1 CA 1 ca
- /Compatible .setblendmode
- DoImage
- end grestore
- PDFfile exch setfileposition
- 0 .endtransparencymask
- << /Subtype /Group /Isolated //true
- /.image_with_SMask //true
- % pdfwrite needs : see gs/src/ztrans.c, gs/src/gdevpdft.c
- % Code to deal with a Matte in the SMask. We know the image dictionary must have an SMask
- % entry if we get here, so we don't need to check its existence. Just pull it out and see if
- % the SMask has a Matte entry. If it does, get the ColorSpace from the parent image and
- % put a /CS key with that colour space in the Group that we manufacture. Bug #700686
- % We also need to actually set the current colour space to be the same as the group
- % code only picks up the current colour space, not the space from the dictionary.
- currentdict /SMask get /Matte known {/CS currentdict /ColorSpace get dup pdfopdict /cs get exec } if
- >> 0 0 1 1
- gsave 1 1 moveto 0 0 lineto
- % If we get an error, just emit an empty box
- { pathbbox } stopped { 0 0 0 0 } if
- 4 array astore grestore
- /image
- setup_trans
- .begintransparencygroup
- .currentstrokeconstantalpha .currentfillconstantalpha 3 -1 roll
- 1 .setfillconstantalpha 1 .setstrokeconstantalpha
- doimage
- .setfillconstantalpha .setstrokeconstantalpha
- .endtransparencygroup
- % tell the compositor we're done with the SMask.
- % Note that any SMask in the ExtGState should be reapplied
- % by the next call to setfill(stroke)state AND this relies
- % on our lazy evaulation of SMask groups
- //false << /Subtype /None >> 0 0 0 0 .begintransparencymaskgroup
- } {
- % We don't have an SMask in the image but there might be an SMask in the ExtGState
- .currentSMask //null ne {
- % the image doesn't have an SMask, but the ExtGState does, force a group.
- << /Subtype /Group /Isolated //true >> 0 0 1 1
- .begintransparencygroup
- .currentstrokeconstantalpha .currentfillconstantalpha 3 -1 roll
- 1 .setfillconstantalpha 1 .setstrokeconstantalpha
- doimage
- .setfillconstantalpha .setstrokeconstantalpha
- .endtransparencygroup
- } {
- doimage
- } ifelse
- } ifelse
- } ifelse
-} bind executeonly def
-
-% For development needs we define a special option for running with a new handler
-% for images with a soft mask.
-//systemdict /NEW_IMAGE3X .knownget not { //false } if {
- /doimagesmask { % <imagemask> doimagesmask -
- doimage
- } bind executeonly def
-} if
-
-/ValidateDecode { % <<image dict>> -imagemask- ValidateDecode <<image dict>>
- exch
- dup /Decode .knownget {
- dup length % -imagemask- <<image dict>> [Decode] length
- 4 -1 roll % <<image dict>> [Decode] length -imagemask-
- {
- 1 % ImageMask Decode arrays must be [0 1] or [1 0]
- }
- {
- mark currentcolor counttomark % <<image dict>> [Decode] length [ ... component_count
- dup 2 add 1 roll % <<image dict>> [Decode] length component_count [ ....
- cleartomark % <<image dict>> [Decode] length component_count
- } ifelse
- 2 mul dup % <<image dict>> [Decode] length comp_count*2 comp_count*2
- 3 1 roll % <<image dict>> [Decode] comp_count*2 length comp_count*2
- eq { % <<image dict>> length of Decode matches colour space requirement
- pop pop % <<image dict>> remove [Decode] and comp_count*2
- }{ % <<image dict>> Decode array incorrect
- dup 2 index length % <<image dict>> [Decode] comp_count*2 comp_count*2 length
- exch sub 0 gt { % Decode is too long
- (\n **** Warning: Decode array for an image is too long\n) pdfformatwarning
- ( Output may be incorrect.\n) pdfformatwarning
- 0 exch % <<image dict>> [Decode] 0 comp_count*2
- getinterval % <<image dict>> [subarray of Decode]
- 1 index exch /Decode exch % <<image dict>> <<image dict>> /Decode [subarray]
- put % <<image dict>>
- }{
- % Decode is too short, Acrobat throws errors on this
- (\n **** ERROR: Decode array for an image is too short\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop pop % remove [Decode] and comp_count*2
- } ifelse
- } ifelse
- } {
- exch pop
- }ifelse
-}bind executeonly def
-
-/doimage { % <imagemask> doimage -
- % imagedict is currentdict, gets popped from dstack
- %% We must save the colour space, in case it gets changed. I did try doing this
- %% at a higher level (/Do) but that caused numerous problems with pdfwrite.
- currentcolorspace exch
- %% save the current rendering intent
- .currentrenderintent exch
-
- %% Check the image dictionary to see if there is a /Intent
- currentdict /Intent known {
- %% and set the current rendering intent to match if so
- Intent .setrenderingintent
- } if
-
- DataSource exch
- currentdict /SMask known PDFusingtransparency and {
- /PreserveSMask /GetDeviceParam .special_op {
- pop pop
- currentdict /SMask oget
- makesoftmaskimage
- } if
- } if
- currentdict /Mask knownoget {
- makemaskimage
- } if
- % Stack: datasource imagemask
- { currentdict end setsmaskstate //true ValidateDecode { imagemask } }
- { ColorSpace setgcolorspace currentdict end setsmaskstate //false ValidateDecode { image } }
- ifelse
- PDFSTOPONERROR { exec //false } { stopped } ifelse {
- dup type /dicttype eq { pop } if % Sometimes image fails to restore the stack
- $error /errorname get dup /ioerror eq {
- pop (\n **** Error: File has insufficient data for an image.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } {
- (\n **** Error: File encountered ')
- exch 40 string cvs concatstrings
- (' error while processing an image.\n) concatstrings
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- } if
- % Close the input stream, unless it is PDFfile or
- % PDFsource.
- dup dup PDFfile eq exch PDFsource eq or { pop } { closefile } ifelse
-
- %% restore the rendering intent
- .setrenderingintent
-
- %% and restore the colour space. We need to do this in a stopped context because
- %% if we are rendering a glyph, the cache device will throw an error if we try
- %% to change colour space (even when the new space is the same as the old space)
- %% We can't tell if we are rendering a bitmap for a glyph, and its hard to compare
- %% colour spaces, so just ignore errors for now.
- {setcolorspace} stopped {pop} if
-
- teardown_trans
-} bind executeonly def
-
-/.paintform { % <formdict> <resdict> <stream> .paintform -
- 1 index /FormResDict gput % For broken forms that inherit resources from the context.
- 3 -1 roll dup /Group oknown PDFusingtransparency and {
- .paintgroupform
- } {
- pop pdfopdict .pdfruncontext
- } ifelse
-} bind executeonly def
-
-/IncrementAppearanceNumber {
- //pdfdict /AppearanceNumber .knownget {
- 1 add //pdfdict /AppearanceNumber 3 -1 roll .forceput
- } executeonly
- {
- //pdfdict /AppearanceNumber 0 .forceput
- } executeonly ifelse
-}bind executeonly odef
-
-/MakeAppearanceName {
- //pdfdict /AppearanceNumber get
- 10 string cvs
- dup length 10 add string dup 0 (\{FormName) putinterval
- dup 3 -1 roll
- 9 exch putinterval
- dup dup length 1 sub (\}) putinterval
-} bind executeonly def
-
-/MakeNewAppearanceName {
- IncrementAppearanceNumber
- MakeAppearanceName
-}bind executeonly def
-
-/DoAppearance {
-%% Might need to rethink this. The problem is that if the page has a CropBox, we apply
-%% that as an initial clip. When we run the form, we don't apply the /Rect from the
-%% annotation, which means that the form could be out of the clip, which results in
-%% content going missing. Resetting the clip prevents this.
- gsave initclip
- MakeNewAppearanceName
- .pdfFormName
- //pdfdict /.PreservePDFForm known {//pdfdict /.PreservePDFForm get} {//false}ifelse exch
- //pdfdict /.PreservePDFForm //true .forceput
- DoForm
- //pdfdict /.PreservePDFForm 3 -1 roll .forceput
- grestore
-} bind executeonly odef
-
-%% We don't want to do any high level forms stuff if the source
-%% is PDF because :
-%% 1) Transparent forms are handled separately and we don't want to ge confused
-%% 2) PDF forms are too llikely to trip over the limitations in our support
-%% 3) Its highly unusual to find a PDF file which uses forms sensibly.
-%%
-%% So we have a special PDF version of execform which doesn't do high level forms.
-
-pdfdict
-/.PDFexecform {
- % This is a separate operator so that the stacks will be restored
- % properly if an error occurs.
- dup /Matrix get concat
- dup /BBox get aload pop
- exch 3 index sub exch 2 index sub rectclip
- dup /PaintProc get
- 1 index /Implementation known not {
- 1 index dup /Implementation //null .forceput readonly pop
- } executeonly if
- exec
-} .bind executeonly put
-
-pdfdict
-/PDFexecform {
- gsave { //.PDFexecform exec } stopped
- grestore {stop} if
-} .bind executeonly put
-
-/DoForm {
- %% save the current value, if its true we will set it to false later, in order
- %% to prevent us preserving Forms which are used *from* an annotation /Appearance.
- //pdfdict /.PreservePDFForm known {//pdfdict /.PreservePDFForm get} {//false}ifelse exch
-
- %% We may alter the Default* colour spaces, if the Resources
- %% ColorSpace entry contains one of them. But we don't want that
- %% to become the new default, we want to revert to any existing
- %% definition, or the Device space. The Default* spaces are defined
- %% as ColorSpace resources, so the only way to handle them is to
- %% save and restore round the definitions
- 3 dict dup begin
- /saved_DG /DefaultGray /ColorSpace findresource def
- /saved_DRGB /DefaultRGB /ColorSpace findresource def
- /saved_DCMYK /DefaultCMYK /ColorSpace findresource def
- end
- exch
-
- % Adobe 2nd edition of the PDF 1.3 spec makes /FormType
- % and /Matrix keys optional. Cope with the missing keys.
- begin <<
- currentdict /FormType known not { /FormType 1 } if
- currentdict /Matrix known not
- { /Matrix { 1 0 0 1 0 0 } cvlit }
- {
- 0 1 Matrix length 1 sub
- {
- dup Matrix exch get type dup
- /integertype eq exch
- /realtype eq or not
- {
- (\n **** Error: Invalid element in /Form XObject matrix.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- Matrix exch 0.00 put
- }
- { pop }
- ifelse
- } for
- } ifelse
- currentdict /BBox known not {
- (\n **** Error: Required entry /BBox not present in Form.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- /BBox [0 1 0 1]
- } if
- currentdict end { oforce } forall
- >>
- dup [ 2 index /Resources knownoget { oforce } { 0 dict } ifelse
-
- %% Ugly hackery for Default* colour spaces in forms
- %%
- dup /ColorSpace knownoget {
- oforce {
- //false 3 1 roll
- exch dup /DefaultGray eq
- {
- pop exec resolvecolorspace dup csncomp 1 eq {
- dup type /nametype eq { 1 array astore } if
- /DefaultGray exch /ColorSpace defineresource pop
- pop //true
- }{
- pop
- ( **** Error: ignoring invalid /DefaultGray color space.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- }{
- dup /DefaultRGB eq {
- pop exec resolvecolorspace dup csncomp 3 eq {
- dup type /nametype eq { 1 array astore } if
- /DefaultRGB exch /ColorSpace defineresource pop
- pop //true
- }{
- pop
- ( **** Error: ignoring invalid /DefaultRGB color space in Form Resources.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- }{
- /DefaultCMYK eq {
- exec resolvecolorspace dup csncomp 4 eq {
- dup type /nametype eq { 1 array astore } if
- /DefaultCMYK exch /ColorSpace defineresource pop
- pop //true
- }{
- pop
- ( **** Error: ignoring invalid /DefaultCMYK color space in Form Resources.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- }{
- pop
- } ifelse
- } ifelse
- }ifelse
- { % if using color space substitution, "transition" the current color space
- currentcolorspace dup length 1 eq { % always an array
- 0 get
- dup /DeviceGray eq 1 index /DeviceRGB eq or 1 index /DeviceCMYK eq or {
- /Pattern setcolorspace setcolorspace
- } {
- pop
- } ifelse
- } {
- pop
- } ifelse
- } if
- } forall
- } if
-
- 3 index
- % /Contents for the stream is not per the spec, but Acrobat handles it
- dup /Contents knownoget
- {
- % We want to make it's a dictionary, and represents a stream
- dup type /dicttype eq
- {
- dup /FilePosition known
- {
- PDFSTOPONERROR { /DoForm cvx /undefinedresource signalerror } if
- ( **** Error: Invalid Form definition. Output may be incorrect.\n) pdfformaterror
- exch pop
- }
- {pop} ifelse
- }
- {
- pop
- }
- ifelse
- }if
- //false /resolvestream cvx
- /.paintform cvx
- ] cvx /PaintProc exch put
- % Adjust pdfemptycount since we have an extra dictionary on the stack
- pdfemptycount countdictstack 3 -1 roll
- /pdfemptycount count 4 sub store
-
- //pdfdict /.PreservePDFForm known {//pdfdict /.PreservePDFForm get}{//false} ifelse
- {
- %% We must *not* preserve any subsidiary forms (curently at least) as PDF
- %% form preservation doesn't really work. This is used just for Annotation
- %% Appearances currently, and if they should happen to use a form, we do not
- %% want to preserve it.
- //pdfdict /.PreservePDFForm //false .forceput
- /q cvx /execform cvx 5 -2 roll
- } executeonly
- {
- /q cvx /PDFexecform cvx 5 -2 roll
- } ifelse
-
- 4 .execn
- % Restore pdfemptycount
- 0
- { countdictstack
- 2 index le { exit } if
- currentdict /n known not { 1 add } if
- countdictstack
- Q
- countdictstack eq {end} if
- } loop
- 1 gt {
- ( **** Error: Form stream has unbalanced q/Q operators \(too many q's\)\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } if
- pop
- /pdfemptycount exch store
-
- % We've now seen Form XObjects leaving junk on the stack, so we
- % can't assume that when we finish the form the stack will be restored
- % nor can we assume that the junk won't include a 'mark' so we an't
- % simply do a cleartomark. Instead clear the stack until we get back
- % to a dictionary which contains /saved_DG. We can still get errors;
- % if the stream removes too many objects from the stack we will end
- % up with a stackunderflow, but there's nothing we can do about that.
- dup type /dicttype eq not {
- //true
- } {
- dup /saved_DG known {
- //false
- } {
- //true
- } ifelse
- } ifelse
- {
- ( **** Error: Form stream left garbage on the stack, attempting to recover.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- {
- dup type /dicttype eq not {
- pop
- } {
- dup /saved_DG known {
- exit
- } {
- pop
- } ifelse
- } ifelse
- } loop
- } if
-
- %% Put back pre-existing Default* ColorSpace definitions.
- dup type /dicttype eq {
- begin
- saved_DG /DefaultGray exch /ColorSpace defineresource pop
- saved_DRGB /DefaultRGB exch /ColorSpace defineresource pop
- saved_DCMYK /DefaultCMYK exch /ColorSpace defineresource pop
- end
- } if
- //pdfdict /.PreservePDFForm 3 -1 roll .forceput
-} bind executeonly odef
-
-/_dops_save 1 array def
-
-/DoPS {
- DOPS
- {
- //_dops_save 0 save put
- //true resolvestream cvx exec
- //_dops_save 0 get restore
- }
- { pop }
- ifelse
-} bind executeonly def
-
-currentdict /_dops_save undef
-
-/ocg_pocs 4 dict begin
- /AllOn {
- //true exch {
- oforce dup type /dicttype eq {
- /OFF known not and
- } {
- pop
- } ifelse
- } forall
- } bind executeonly def
- /AnyOn {
- //false exch {
- oforce dup type /dicttype eq {
- /OFF known not or
- } {
- pop
- } ifelse
- } forall
- } bind executeonly def
- /AnyOff {
- //AllOn exec not
- } bind executeonly def
- /AllOff {
- //AnyOn exec not
- } bind executeonly def
-currentdict end readonly def
-
-% Check whether OCG or OCMD is visible
-% <dict> oc-is-visible <bool>
-/ocg-is-visible {
- dup /Type knownoget {
- /OCMD eq {
- dup /OCGs knownoget not { {} } if % OC OCGs
- dup type /dicttype eq { 1 array astore } if
- //true 1 index { //null eq and } forall {
- pop pop //true % all nulls => show
- } {
- exch /P knownoget not { /AnyOn } if % OCGs P
- //ocg_pocs exch get exec % bool
- } ifelse
- } {
- dup /OFF known not % OFF is inserted by process_trailer_attrs
- {
- %% /OC is not in the OCProperties /OFF array, so we need to
- %% test its usage. We may eventually have to add a /ON to the dictionary
- %% if the OCProperties /ON array defines the /OC, I think that should override
- % the Usage, but I don't have an example to test.
- /Usage .knownget {
- oforce
- /Printed where {
- /Printed get
- } {
- //false
- }ifelse
- {
- %% We are behaving as a printer, check the Print state
- /Print .knownget {
- oforce
- /PrintState .knownget {
- oforce
- /OFF eq {
- //false
- }{
- //true
- } ifelse
- }{
- //true
- } ifelse
- }{
- %% If we don't know, assume its visible
- //true
- } ifelse
- }{
- %% We are behaving as a viewer, check the View state
- /View .knownget {
- oforce
- /ViewState .knownget {
- oforce
- /OFF eq {
- //false
- }{
- //true
- } ifelse
- }{
- //true
- } ifelse
- }{
- %% If we don't know, assume its visible
- //true
- } ifelse
- } ifelse
- }{
- %% If we don't know, assume its visible
- //true
- } ifelse
- }{
- pop //false
- }ifelse
- } ifelse
- } {
- /OFF known not % OFF is inserted by process_trailer_attrs
- } ifelse
-} bind executeonly def
-
-drawopdict begin
- /Do { % /Name
- %% Bug 695897 This file has nested text blocks and also a Do image inside
- %% a text block. Here we attempt to detect and recover from this by setting the
- %% CTM to the matrix we saved before the text block. NB we update the 'TextSaveMatrix'
- %% or 'qTextSaveMatrix' whenever a 'cm' is issued, even if we are in a text block, so
- %% these matrices 'ought' to be correct.
- %% Of course, the file is badly broken, but 'Acrobat can open it....'
- currentdict /TextSaveMatrix known {
- gsave
- ( **** Error: Executing Do inside a text block, attempting to recover\n) pdfformaterror
- currentdict /TextSaveMatrix get setmatrix
- ( Output may be incorrect.\n) pdfformaterror
- } if
- currentdict /qTextSaveMatrix known {
- gsave
- ( **** Error: Executing Do inside a text block, attempting to recover\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- currentdict /qTextSaveMatrix get setmatrix
- } if
- setsmaskstate
- PDFfile fileposition exch % pos /Name
-
- % Bug #698226, Acrobat signals an error for recursive XObjects in a PDF file
- % but continues. This is true even if the XObject is not a simple self-reference
- % (eg /Fm1 -> /Fm2 -> /Fm3 -> /Fm1).
- % Normally when dealing with recursion we would put a dictionary on the stack, store the
- % object numbers encoutnered in it, and check each new object number to see if we've
- % already seen it. This doesn't work well for XObjects, because the operand stack can be
- % in any state when we run a Do. So we make a new dictionary in pdfdict to hold the
- % object numbers.
- % We also don't usually know the object number of a Form, we just get given its name
- % so we need a new routine to return the object number. This is because the parent XObject
- % might reference teh object by one name, while the child references it by another, we
- % can't permit clashes.
- %
- % Start by getting the object number for a Form XObject
- dup Page /XObject obj_get dup 0 eq not {
- % Now get the recording dictionary and see if that object number has been seen
- //pdfdict /Recursive_XObject_D get 1 index known {
- ( **** Error: Recursive XObject detected, ignoring ") print 1 index 256 string cvs print (", object number ) print 256 string cvs print (\n) print
- ( Output may be incorrect.\n) pdfformaterror
- //false
- }{
- % We haven't seen it yet, so record it.
- //pdfdict /Recursive_XObject_D get 1 index //null put
- 3 1 roll
- //true
- }ifelse
- }
- {
- % I don't think this should be possible, but just in case
- ( **** Error: Unable to determine object number for ) print exch 256 string cvs print ( so ignoring it) print
- ( Output may be incorrect.\n) pdfformaterror
- //false
- } ifelse
-
- % If we could get the object number, and we haven't already seen it, then execute it.
- {
- dup Page /XObject rget {
- exch pop % pos obj
- OFFlevels length 0 eq {
- dup /OC knownoget { ocg-is-visible } { //true } ifelse
- } {
- //false
- } ifelse {
- dup /Subtype oget //xobjectprocs exch get % pos obj {proc}
- % Don't leave extra objects on the stack while executing
- % the definition of the form.
- 3 -1 roll % obj {proc} pos
- 2 .execn % pos
- } {
- pop % pos
- } ifelse
- } {
- % This should cause an error, but Acrobat Reader can
- % continue, so we do too.
- ( **** Error: Undefined XObject resource: )
- exch =string cvs concatstrings (\n) concatstrings
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- PDFfile exch setfileposition
- //pdfdict /Recursive_XObject_D get exch undef
- }{
- % Otherwise ignore it and tidy up the stacks
- pop pop
- } ifelse
- } bind executeonly def
-end
-
-currentdict /xobjectprocs .undef
-currentdict /ocg_pocs .undef
-
-% ---------------- In-line images ---------------- %
-
-% Undo the abbreviations in an in-line image dictionary.
-% Note that we must look inside array values.
-% /I is context-dependent.
-/unabbrevkeydict mark
- /BPC /BitsPerComponent /CS /ColorSpace /D /Decode /DP /DecodeParms
- /F /Filter /H /Height /I /Interpolate /IM /ImageMask /W /Width
-.dicttomark readonly def
-/unabbrevvaluedict mark
- /AHx /ASCIIHexDecode /A85 /ASCII85Decode /CC /CalCMYK
- /CCF /CCITTFaxDecode /CG /CalGray /CR /CalRGB
- /DCT /DCTDecode /CMYK /DeviceCMYK /Fl /FlateDecode
- /G /DeviceGray /RGB /DeviceRGB
- /I /Indexed /LZW /LZWDecode /RL /RunLengthDecode
-.dicttomark readonly def
-/unabbrevtypedict mark
- /nametype {
- //unabbrevvaluedict 1 index .knownget { exch pop } if
- }
- /arraytype {
- dup 0 1 2 index length 1 sub {
- 2 copy get unabbrevvalue put dup
- } for pop
- }
-.dicttomark readonly def
-/unabbrevvalue { % <obj> unabbrevvalue <obj'>
- oforce //unabbrevtypedict 1 index type .knownget { exec } if
-} bind executeonly def
-
-/is_space_dict << 0 0 9 9 10 10 12 12 13 13 32 32 >> readonly def
-
-drawopdict begin
- /BI { mark } bind executeonly def
- /ID {
- gsave
- %% Bug 696547, related to Bug 695897 (see /Do above) This file has an inline image inside
- %% a text block. Here we attempt to detect and recover from this by setting the
- %% CTM to the matrix we saved before the text block. NB we update the 'TextSaveMatrix'
- %% or 'qTextSaveMatrix' whenever a 'cm' is issued, even if we are in a text block, so
- %% these matrices 'ought' to be correct.
- %% Of course, the file is badly broken, but 'Acrobat can open it....'
- currentdict /TextSaveMatrix known {
- ( **** Error: Executing ID inside a text block, attempting to recover\n) pdfformaterror
- currentdict /TextSaveMatrix get setmatrix
- ( Output may be incorrect.\n) pdfformaterror
- } if
- currentdict /qTextSaveMatrix known {
- ( **** Error: Executing ID inside a text block, attempting to recover\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- currentdict /qTextSaveMatrix get setmatrix
- } if
-
- counttomark 2 idiv dup 7 add dict begin {
- exch //unabbrevkeydict 1 index .knownget { exch pop } if
- exch unabbrevvalue def
- } repeat pop
- /IDFlag //true def % flag for stream processing.
- /File PDFsource def
- currentdict makeimagekeys
- OFFlevels length 0 eq {
- gsave 1 1 moveto 0 0 lineto
- % If we get an error, just emit an empty box
- { pathbbox } stopped { 0 0 0 0 } if
- 4 array astore grestore
- /image
- setup_trans
- doimage
- } {
- pop Width
- currentdict /ImageMask knownoget dup { and } if not {
- ColorSpace oforce csncomp mul
- BitsPerComponent mul
- } if
- 7 add 8 idiv Height mul
- DataSource exch () /SubFileDecode filter flushfile
- end
- } ifelse
- % The Adobe documentation says that the data following ID
- % consists of "lines", and some PDF files (specifically, some files
- % produced by PCL2PDF from Visual Software) contain garbage bytes
- % between the last byte of valid data and an EOL.
- % Some files (PDFOUT v3.8d by GenText) have EI immediately following
- % the stream. Some have no EOL and garbage bytes.
- % Sometimes (bug 690300) CCITTDecode filter consumes 'E' in 'EI'.
- % Therefore, we search for <start>I<sp|end> or <start|sp>EI<sp|end>
- PDFsource read not {
- /ID cvx /syntaxerror signalerror
- } if
- dup 73 eq {
- pop 10 69 73 % Seed to: <sp>EI
- } {
- 10 10 3 -1 roll % Seed to: <sp><sp><any>
- } ifelse
- { PDFsource read not dup { 10 exch } if
- //is_space_dict 2 index known
- 3 index 73 eq and 4 index 69 eq and
- //is_space_dict 6 index known and {
- pop pop pop pop pop exit
- } {
- {
- pop pop pop /ID cvx /syntaxerror signalerror
- } {
- 4 -1 roll pop
- } ifelse
- } ifelse
- } loop
- grestore
- } bind executeonly def
-end
-
-currentdict /is_space_dict undef
-
-% ================================ Text ================================ %
-
-drawopdict begin
- % Text control
- /BT { BT } executeonly def
- /ET { ET } executeonly def
- /Tc { Tc } executeonly def
- /TL { TL } executeonly def
- /Tr { Tr } executeonly def
- /Ts { Ts } executeonly def
- /Tw { Tw } executeonly def
- /Tz { Tz } executeonly def
- % Text positioning
- /Td { Td } executeonly def
- /TD { TD } executeonly def
- /Tm { Tm } executeonly def
- /T* { T* } executeonly def
- % Text painting
- /Tj { Tj } executeonly def
- /' { ' } executeonly def
- /" { " } executeonly def
- /TJ { TJ } executeonly def
-
- /Tform { Tform } executeonly def % Text formatting and painting for AcroForm
- % without appearance streams.
-end
-
-% ======================= Invalid operators ============================ %
-
-drawopdict begin
- /QBT {
- Q BT
- ( **** Error: invalid operator QBT processed as Q BT .\n)
- pdfformaterror % Bug 690089
- ( Output may be incorrect.\n) pdfformaterror
- } executeonly def
-
- /. {
- 0.
- ( **** Error: invalid operator . processed as number 0. .\n)
- pdfformaterror % Bug 690730
- ( Output may be incorrect.\n) pdfformaterror
- } executeonly def
-end
-
-% ============================== Annotations ============================== %
-
-% Create links from separate widget annotations to the parent field nodes.
-% Surprisingly, separate widget annotations don't have a link to the parent
-% from which they inherit some data.
-/link_widget_annots { % <<parent>> <<kid>> -> <<parent>> <<kid>>
- dup /Kids knownoget {
- { oforce
- dup type /dicttype eq {
- link_widget_annots
- } if
- pop
- } forall
- } if
- dup /Parent oknown not {
- 2 copy exch /ParentField exch put
- } if
-} bind executeonly def
-
-% Get and normalize an annotation's rectangle.
-/annotrect { % <annot> annotrect <x> <y> <w> <h>
- /Rect oget oforce_recursive aload pop
- exch 3 index sub dup 0 lt { dup 5 -1 roll add 4 1 roll neg } if
- exch 2 index sub dup 0 lt { dup 4 -1 roll add 3 1 roll neg } if
-} bind executeonly def
-
-% Set an annotation color.
-% If the /C array is empty we don't want to draw the annotation
-%
-/annotsetcolor { % <annot> annotsetcolor bool
- /C knownoget {
- dup length 4 eq {
- aload pop setcmykcolor //true
- }{
- dup length 3 eq {
- aload pop setrgbcolor //true
- }{
- dup length 1 eq {
- aload pop setgray //true
- } {
- dup length 0 eq {
- pop
- //false
- }{
- ( **** Error: invalid color specified for annotation /C entry)
- pdfformaterror //false
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- } ifelse
- } ifelse
- } ifelse
- }
- { 0 setgray //true} ifelse
-} bind executeonly def
-
-% Set an annotation color.
-% If the /C array is empty we don't want to draw the annotation
-%
-/annotsetinteriorcolor { % <annot> annotsetcolor bool
- /IC knownoget {
- dup length 4 eq {
- aload pop setcmykcolor //true
- }{
- dup length 3 eq {
- aload pop setrgbcolor //true
- }{
- dup length 1 eq {
- aload pop setgray //true
- } {
- dup length 0 eq {
- pop
- //false
- }{
- ( **** Error: invalid color specified for annotation /C entry)
- pdfformaterror //false
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- } ifelse
- } ifelse
- } ifelse
- }
- { //false } ifelse
-} bind executeonly def
-
-% Draw the border. Currently, we ignore requests for beveling, and we
-% don't round the corners of rectangles.
-/strokeborder { % <annot> <width> <dash> strokeborder -
- 1 index 0 ne { % do not draw if border width is 0
- gsave
-% 2 index annotsetcolor
-% {
- 0 setdash dup setlinewidth
- exch dup annotrect
- 5 -1 roll /RD knownoget {
- applyRD
- } if
- 2 { 4 index sub 4 1 roll } repeat
- 2 { 4 index 0.5 mul add 4 1 roll } repeat
- rectstroke pop
- grestore
-% } {
-% pop pop pop
-% } ifelse
- } {
- pop pop pop
- }ifelse
-} bind executeonly def
-
-% Draw an annotation border.
-/drawborder { % <annot> drawborder -
- gsave
- dup /BS known 1 index /Border known or {
- dup /BS knownoget {
- dup type /dicttype ne % <annot> <border> <bad?>
- } {
- dup /Border oget
- dup type /arraytype eq {
- dup length 3 lt
- } {
- //true
- } ifelse % <annot> [border] <bad?>
- } ifelse {
- ( **** Error: Invalid annotation border object, border has not been drawn.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop { 0 0 0 }
- } if
- dup type /dicttype eq {
- dup /W knownoget not { 1 } if
- % Per PDF1.6 Reference table 8.13, /W in the border style dictionary is
- % expressed in points (an absolute unit), so compensate here for any
- % scaling of the PostScript user space done due to /UserUnit.
- % Scaling due to -dPDFFitPage is not undone, to keep the correct border width
- % compared to the size of the surrounding marks.
- //systemdict /NoUserUnit .knownget not { //false } if not
- //systemdict /PDFFitPage known not and
- % Don't apply USerUnit if we are passing it to the device
- /PassUserUnit /GetDeviceParam .special_op {exch pop} {//false} ifelse not and
- { % UserUnit is ignored if -dPDFFitPage
- Page /UserUnit knownoget { div } if
- } if
- {} 2 index /S knownoget {
- /D eq { 2 index /D knownoget not { {3} } if exch pop } if
- } if
- 3 -1 roll pop strokeborder
- } {
- dup 2 get
- exch dup length 3 gt { 3 get } { pop {} } ifelse
- strokeborder
- } ifelse
- } {
- 1 {} strokeborder
- } ifelse
- grestore
-} bind executeonly def
-
-% stroke the path of an annotation border.
-/strokeborderpath { % <annot> strokeborderpath -
- gsave
- dup /BS known 1 index /Border known or {
- dup /BS knownoget {
- dup type /dicttype ne % <annot> <border> <bad?>
- } {
- dup /Border oget
- dup type /arraytype eq {
- dup length 3 lt
- } {
- //true
- } ifelse % <annot> [border] <bad?>
- } ifelse {
- ( **** Error: Invalid annotation border object, border has not been drawn.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop { 0 0 0 }
- } if
- dup type /dicttype eq {
- dup /W knownoget not { 1 } if
- % Per PDF1.6 Reference table 8.13, /W in the border style dictionary is
- % expressed in points (an absolute unit), so compensate here for any
- % scaling of the PostScript user space done due to /UserUnit.
- % Scaling due to -dPDFFitPage is not undone, to keep the correct border width
- % compared to the size of the surrounding marks.
- //systemdict /NoUserUnit .knownget not { //false } if not
- //systemdict /PDFFitPage known not and
- % Don't apply USerUnit if we are passing it to the device
- /PassUserUnit /GetDeviceParam .special_op {exch pop} {//false} ifelse not and
- { % UserUnit is ignored if -dPDFFitPage
- Page /UserUnit knownoget { div } if
- } if
- {} 2 index /S knownoget {
- /D eq { 2 index /D knownoget not { {3} } if exch pop } if
- } if
- 3 index /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if
- 3 -1 roll pop
-% 2 index annotsetcolor {
- 0 setdash setlinewidth stroke
-% } if
- } {
- dup 2 get
- % If element 3 of the /Border array is 0, then don't draw the border
- dup 0 ne {
- exch dup length 3 gt { 3 get } { pop {} } ifelse
- 3 index /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if
-% 2 index annotsetcolor {
- 0 setdash setlinewidth stroke
-% } if
- }{
- pop pop
- } ifelse
- } ifelse
- } {
- dup /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if
- 1 {}
-% 2 index annotsetcolor {
- 0 setdash setlinewidth stroke
-% } if
- } ifelse
- pop
- grestore
-} bind executeonly def
-
-/fillborderpath { % <annot> fillborderpath -
- gsave
- dup /ca knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if
- annotsetinteriorcolor
- {fill} if
- grestore
-}bind executeonly def
-
-%
-% The PDF annotation F (flags) integer is bit encoded.
-% Bit 1 (LSB) Invisible: 1 --> Do not display if no handler.
-% Note: We have no handlers but we ignore this bit.
-% Bit 2 Hidden: 1 --> Do not display. We will not display if this bit is set.
-% Bit 3 Print: 1 --> Display if printing. We will display if this bit set
-% (and not hidden) and Printed is true
-% Bit 4 NoZoom: 1 --> Do not zoom annotation even if image is zoomed.
-% Bit 5 NoRotate: 1 --> Do not rotate annotation even if image is rotated.
-% Bit 6 NoView: 0 --> Display if this is a 'viewer'. We will display
-% if this bit is not set (and not hidden) and Printed is false
-% Bit 7 Read Only - 1 --> No interaction. We ignore this bit
-%
-% AR8 and AR9 print 3D annotations even if Print flag is off. Bug 691486.
-%
-/annotvisible { % <annot> annotvisible <visible>
- dup /Subtype knownoget { /3D eq } { //false } ifelse % 3D annot
- exch /F knownoget not { 0 } if % Get flag value
- dup 2 and 0 eq {
- /Printed load {
- 4 and 4 eq or % Printed or 3D
- } {
- 32 and 0 eq exch pop % not NoView
- } ifelse
- } {
- pop pop //false % Hidden
- } ifelse
-} bind executeonly def
-
-/set_bc_color <<
- 1 { 0 get oforce setgray } bind executeonly
- 3 { { oforce } forall setrgbcolor } bind executeonly
- 4 { { oforce } forall setcmykcolor } bind executeonly
->> readonly def
-
-% Get an inherited attribute from a node through /Parent and /ParentField
-% links. The latter is set at start-up to access parents of annotations and
-% defaults at AcroForm.
-/fget % <field> <key> fget <value> -true-
- { % <field> <key> fget -false-
- {
- 2 copy knownoget {
- exch pop exch pop //true exit
- } {
- exch
- dup /Parent knownoget {
- exch pop exch
- } {
- /ParentField knownoget {
- exch
- } {
- pop //false exit
- } ifelse
- } ifelse
- } ifelse
- } loop
- } bind executeonly def
-
-% <annot> foo <annot>
-/make_tx_da {
- dup /AP << /N 10 dict dup cvx begin >> put
- /Subtype /Form def
- /BBox [ 0 0 4 index /Rect oget { oforce } forall 3 -1 roll sub abs 3 1 roll sub abs exch ] def
- /Resources 1 index /DR fget not { 0 dict } if def
- /File 1 index /V fget not { () } if length
- 2 index /DA fget not { () } if length add
- 500 add 65535 .min string dup 3 1 roll def
- /NullEncode filter % <annot> file
-
- dup (BT ) writestring
- 1 index /DA fget not {
- 1 index /V fget {
- <EFBBBF> anchorsearch {
- pop /Helvetica findfont
- 12 scalefont setfont
- } {
- <FEFF> anchorsearch {
- pop pop /FallBackFont /Identity-UTF16-H [/CIDFallBack] composefont 12 scalefont setfont
- } {
- pop /Helvetica findfont
- % re-encode the font to PDFDocEncoding
- dup length dict begin
- {
- 1 index /FID ne 2 index /UniqueID ne and { def } { pop pop } ifelse
- } forall
- /Encoding /PDFDocEncoding /Encoding findresource def
- /FontName /Helvetica-PDFDocEncoding def
- currentdict
- end
- /Helvetica-PDFDocEncoding exch definefont
- 12 scalefont setfont
- }ifelse
- }ifelse
- } if
- ()
- }if
-
- [ exch
- { token {
- dup /Tf eq {
- 2 index 0 eq {
- /BBox load 3 get
- 0.75 mul % empirical constant
- 4 -1 roll pop 3 1 roll
- } if
- } if
- exch
- } {
- exit
- } ifelse
- } loop
- ]
- { 1 index exch write== } forall
- dup 2 index /MaxLen fget not { 0 } if write=
- dup 2 index /V fget not { () } if write==
- dup 2 index /Ff fget not { 0 } if write=
- dup 2 index /Q fget not { 0 } if write=
- dup (Tform ET) write=
- dup .fileposition /Length exch def
- /File File 0 Length getinterval def
- closefile % <annot>
- end
-} bind executeonly def
-
-/can-regenerate-ap { % <annot> -> <bool>
- //false exch
- NeedAppearances {
- dup /FT fget {
- dup /Tx eq {
- pop
- dup /V oknown {
- pop not 1
- } if
- } {
- /Ch eq {
- dup /V oknown {
- pop not 1
- } if
- } if
- } ifelse
- } if
- } if
- pop
-} bind executeonly def
-
-/drawwidget { % <scalefactor_x> <scalefactor_y> <annot> drawwidget -
-
-%% This code checks to see if we can geenrate an appearance stream for the
-%% given widget, and if we can it ignores the given Appearance stream, so that
-%% we generate one instead. This seems wrong to me, if we've been given an
-%% appearance stream we should use it, no synthesize something else. Several
-%% files in our regression test suite render 'incorrectly' when compared to
-%% Acrobat with this removed, clearly Acrobat always ignores appearances. However
-%% several other files are rendered better when we *don't* ignore the Appearance
-%% So on balance I'm choosing to honour the appearance.
-%%
-% dup /UpdatedAP known not {
-% dup can-regenerate-ap {
-% dup /AP undef
-% } if
-% } if
-
- % Acrobat doesn't draw Widget annotations unles they have both /FT
- % (which is defined as required) and /T keys present. Annoyingly
- % these can either be inherited from the Form Definition Field
- % dictionary (via the AcroForm tree) or present directly in the
- % annotation, so we need to check the annotation to make sure its
- % a Widget, then follow any /Parent key up to the root node
- % extracting and storing any FT or T keys as we go (we only care if
- % these are present, their value is immaterial). If after all that
- % both keys are not present, then we don't draw the annotation.
-
- dup /Subtype get /Widget eq {
- dup /FT known 1 index /T known and not {
- dup
- {
- dup /FT knownoget {
- /FT exch 3 index 3 1 roll put
- } if
- dup /T knownoget {
- /T exch 3 index 3 1 roll put
- } if
- /Parent knownoget not {
- exit
- } if
- } loop
- } if
- dup /FT known 1 index /T known and {
- //true
- } {
- ( **** Warning: A Widget annotation dictionary lacks either the FT or T key.\n)
- pdfformaterror
- ( Acrobat ignores such annotations, annotation will not be rendered.\n)
- pdfformaterror
- ( Output may not be as expected.\n) pdfformaterror
- //false
- } ifelse
- } {
- //true
- }ifelse
-
- {
- dup /AP knownoget {
- dup /N known not {
- ( **** Error: Appearance dictionary (AP) lacks the mandatory normal (N) appearance.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } if
- //false
- [/N /R /D] {
- % stack: scalex scaley annot appearance false key
- 2 index exch knownogetdict {
- exch not exit
- } if
- } forall
- % stack: scalex scaley annot appearance value true
- % stack: scalex scaley annot appearance false
- dup {
- pop exch pop
- % Acrobat Distiller produces files in which this Form
- % XObject lacks Type and Subtype keys. This is illegal,
- % but Acrobat Reader accepts it. The only way we can
- % tell whether this is a Form or a set of sub-appearances
- % is by testing for the stream Length or File key.
- % If the stream lacks Length key, try File key.
- dup /Length knownoget { type /integertype eq } { //false } ifelse
- 1 index /File knownoget { type /filetype eq or } if {
- % If this is a form then simply use it
- //true
- } {
- 1 index /AS knownoget not {
- % If we do not have AS then use any appearance
- { exch pop oforce exit } forall //true
- } {
- % Stack: annot Ndict AS
- % Get the specified appearance. If no appearance, then
- % display nothing - set stack = false.
- knownoget
- } ifelse
- } ifelse
- } {
- exch pop % discard useless AP dictionary
- } ifelse
-
- % Stack: scalex scaley annot appearance true
- % Stack: scalex scaley annot false
- {
- dup type /dicttype eq {
- % Draw appearance
- % Initialize graphic following "7.4.4 Appearance Streams"
- q graphicsbeginpage textbeginpage
- 1 index annotrect pop pop translate
- 3 index 3 index scale % Apply scale factors
- dup /BBox knownoget {
- 1 index /Matrix knownoget not { {1 0 0 1 0 0} } if
- .bbox_transform pop pop
- % Compensate for non-zero origin of BBox
- neg exch neg exch translate
- } if
- DoForm Q
- } {
- ( **** Error: Annotation's appearance is not a dictionary.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- } if
- } {
- dup /MK knownoget { % mk
- dup /BG knownoget { % mk bg
- dup length % mk bg len
- //set_bc_color exch .knownget {
- gsave
- exec
- 3 index 3 index scale
- 1 index annotrect rectfill
- grestore
- } {
- pop
- } ifelse
- } if
- dup /BC knownoget {
- dup length
- //set_bc_color exch .knownget {
- gsave
- exec
- 1 setlinewidth
- 3 index 3 index scale
- 1 index annotrect rectstroke
- grestore
- } {
- pop
- } ifelse
- } if
- pop
- } if
-
- dup can-regenerate-ap {
- make_tx_da
- dup /UpdatedAP //true put
- 3 copy drawwidget
- } if
- } ifelse
- } if
- pop pop pop
-} bind executeonly def
-
-
-currentdict /set_bc_color undef
-
-% For annotation object we have to determine the size of the output rectangle
-% and the size of the BBox for the form XObject. From these we calculate
-% a scale factors for drawing it.
-/calc_annot_scale { % <annot> calc_annot_scale <x_scale> <y_scale>
- dup /Rect knownoget {
- pop dup annotrect 4 2 roll pop pop % get width height size in user space
- 2 index /AP knownoget {
- /N knownogetdict { % <<Annot>> x y <<N>>
- dup 4 index /AS knownoget {
- knownoget {
- exch pop
- } if
- } {
- pop
- } ifelse
- dup /Matrix knownoget not { {1 0 0 1 0 0} } if
- exch /BBox knownoget { % <<>> x y {matrix} [box]
- exch .bbox_transform % <<>> x y x0 y0 x1 y1
- 3 -1 roll sub % <<>> x y x0 x1 y1-y0
- 3 1 roll exch sub % <<>> x y y1-y0 x1-x0
- 2 copy mul 0 eq {
- ( **** Error: /BBox has zero width or height, which is not allowed.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop pop pop pop 1 1 % zero size -- revert to unity scaling
- } {
- 3 1 roll div % <<>> x x1-x0 y/(y1-y0)
- 3 1 roll div % <<>> y/(y1-y0) x/(x1-x0)
- exch % <<>> x/(x1-x0) y/(y1-y0)
- } ifelse
- } {
- pop pop pop 1 1 % default to unity scaling
- } ifelse % if we have /BBox
- } {
- pop pop 1 1
- } ifelse % if we have /N
- } {
- pop pop 1 1
- } ifelse % if we have /AP
- 3 -1 roll pop
- } {
- ( **** Error: /Annot dict is missing required /Rect entry.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop 1 1
- } ifelse
-} bind executeonly def
-
-/applyRD {
- % x y w h [l t r b]
- dup 0 get % x y w h [] l
- 6 -1 roll add
- 5 1 roll %x+l y w h []
- dup 1 get %x+l y w h [] b
- 5 -1 roll add %x+l w h [] b+y
- 4 1 roll %x+l y+b w h []
- aload pop %x+l y+b w h l t r b
- exch %x+l y+b w h l t b r
- 4 -1 roll add %x+l y+b w h t b r+l
- 3 1 roll add %x+l y+b w h r+l t+b
- 3 -1 roll exch sub %x+l y+b w r+l h-(t+b)
- 3 1 roll sub %x+l y+b h-(t+b) w-(r+l)
- exch
-} bind executeonly def
-
-% Draw an annotation.
-/drawannottypes 20 dict begin
-
- /startannottransparency {
- PDFusingtransparency {
- dup /BM known {
- dup /BM get
- << exch /BM exch >>
- } {
- << >>
- }ifelse
- %% We should be able to use the Rect to create the group, but it seems
- %% Acrobat ignores this, or at least doesn't clip the annotation to it :-(
-% 1 index /Rect known {
-% 1 index annotrect exch % llx lly h w
-% 3 index add exch % x y urx h
-% 2 index add
-% }{
- clippath pathbbox newpath
-% } ifelse
- .begintransparencygroup
- } if
- }bind executeonly def
-
- /endannottransparency {
- PDFusingtransparency {
- .endtransparencygroup
- } if
- }bind executeonly def
-
- /ValidateAP {
- dup /AP oknown {
- dup /AP oget
- /N oknown not {
- //false
- } {
- //true
- } ifelse
- } {
- //false
- }ifelse
- } bind executeonly def
-
- % x0 y0 x1 y1 x2 y2 x3 y3 -> x0 y0 x1-x0 y1-y0 x2-x0 y2-y0
- /quadpoints2basis {
- 8 { oforce 8 1 roll } repeat
-
- % The text is oriented with respect to the vertex with the smallest
- % y value (or the leftmost of those, if there are two such vertices)
- % (x0, y0) and the next vertex in a counterclockwise direction
- % (x1, y1), regardless of whether these are the first two points in
- % the QuadPoints array.
-
- 2 {
- 2 index 1 index eq {
- 3 index 2 index gt {
- 4 2 roll
- } if
- } {
- 2 index 1 index gt {
- 4 2 roll
- } if
- } ifelse
- 8 4 roll
- } repeat
- 6 index 3 index gt {
- 8 4 roll
- } if
-
- % ^
- % |
- % * (x2,y2) * (x3,y3)
- % |
- % |
- % *------------*->
- % (x0,y0) (x1,y1)
-
- pop pop % x0 y0 x1 y1 x2 y2
- 4 index sub exch % x0 y0 x1 y1 y2-y0 x2
- 5 index sub exch % x0 y0 x1 y1 x2-x0 y2-y0
- 4 2 roll
- 4 index sub exch % x0 y0 x2-x0 y2-y0 y1-y0 x1
- 5 index sub exch % x0 y0 x2-x0 y2-y0 x1-x0 y1-y0
- 4 2 roll % x0 y0 x1-x0 y1-y0 x2-x0 y2-y0
- } bind executeonly def
-
- /Square {
- //ValidateAP exec
- {
- //true
- } {
- gsave
- //startannottransparency exec
- dup
- annotsetinteriorcolor
- {
- gsave
- dup /ca knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if
- dup annotrect
- 5 index /RD knownoget {
- applyRD
- } if
- rectfill
- grestore
- dup /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if
- dup annotsetcolor {
- drawborder
- } if
- //false
- }{
- dup annotrect
- 5 index /RD knownoget {
- applyRD
- } if
- drawopdict /re get exec
- dup annotsetcolor {
- strokeborderpath
- } if
- } ifelse
- //endannottransparency exec
- grestore
- //false
- }ifelse
- } bind executeonly def
-
-%% Width Height drawellipse -
-/drawellipse {
- %% Don Lancaster's code for drawing an ellipse
- 0.55228475 0.00045 sub % improved magic value
- 3 1 roll % magic width height
- 2 div exch 2 div % magic y-radius x-radius
- dup 3 index mul % magic y-radius x-radius x-magic
- 2 index % magic y-radius x-radius x-magic y-radius
- 5 -1 roll mul % magic y-radius x-radius x-magic y-magic
-
- 2 index neg 0 moveto % xrad neg 0 moveto
- 2 index neg 1 index 3 index neg 6 index 0 8 index curveto % xrad neg ymag xmag neg yrad 0 yrad curveto
- 1 index 4 index 4 index 3 index 1 index 0 curveto % xmag yrad xrad ymag xrad 0 curveto
- 2 index 1 index neg 3 index 6 index neg 0 1 index curveto % xrad ymag neg xmag yrad neg 0 yrad neg curveto
- % Stack: yrad xrad xmag ymag
- exch neg 4 1 roll 3 -1 roll neg 3 1 roll exch neg exch
- neg 1 index 0 curveto % xmag neg yrad neg xrad neg ymag neg 0 curveto
-}bind executeonly def
-
- /Circle {
- //ValidateAP exec
- {
- //true
- } {
- gsave
- //startannottransparency exec
- dup annotrect
- 5 index /RD knownoget {
- applyRD
- } if
- 4 2 roll exch 3 index 2 div add exch 2 index 2 div add
- translate //drawellipse exec
- dup
- fillborderpath
- dup annotsetcolor {
- strokeborderpath
- } if
- //endannottransparency exec
- grestore
- //false
- } ifelse
- } bind executeonly def
-
- /Polygon {
- //ValidateAP exec
- {
- //true
- } {
- gsave
- //startannottransparency exec
- dup /Vertices knownoget {
- dup length 2 div 1 sub cvi 0 1 3 -1 roll
- {
- 2 mul dup
- 2 index exch 2 getinterval aload pop
- 3 -1 roll 0 eq {
- moveto
- }{
- lineto
- } ifelse
- }
- for
- pop
- closepath
- //true
- } {
- ( **** Error: Invalid Vertices for Polygon, annotation has not been drawn.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- //false
- } ifelse
-
- 1 index annotsetinteriorcolor {
- //true
- }{
- //false
- }ifelse
- and
-
- {
- gsave
- dup /ca knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if
- fill
- grestore
- dup /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if
- dup annotsetcolor {
- strokeborderpath
- } if
- } {
- dup annotsetcolor {
- strokeborderpath
- } if
- } ifelse
- //endannottransparency exec
- //false
- grestore
- } ifelse
- } bind executeonly def
-
- /LineEnd_dict 10 dict begin
- %% Stack contains <annot>
- %% CTM rotated so line segment is vertical, translated so line endpoint at 0,0
-
- /Square {
- dup
- /BS knownoget {
- /W knownoget {
- }{
- 1
- }ifelse
- }{
- 1
- }ifelse
- dup 2.5 mul
- gsave
- dup neg 1 index neg exch moveto
- dup neg 1 index lineto
- dup 1 index exch lineto
- dup neg lineto
- closepath
- 1 index /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if
- 1 index fillborderpath
- grestore
- 3 mul
- dup neg 1 index neg exch moveto
- dup neg 1 index lineto
- dup 1 index exch lineto
- dup neg lineto
- closepath
- strokeborderpath
- } bind executeonly def
- /Circle {
- dup
- /BS knownoget {
- /W knownoget {
- }{
- 1
- }ifelse
- }{
- 1
- }ifelse
- dup
- gsave
- 2.5 mul dup
- 0 moveto
- 0 0 3 -1 roll 0 360 arc
- 1 index /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if
- 1 index fillborderpath
- grestore
- 3 mul dup
- 0 moveto
- 0 0 3 -1 roll 0 360 arc
- strokeborderpath
- } bind executeonly def
- /Diamond {
- dup
- /BS knownoget {
- /W knownoget {
- }{
- 1
- }ifelse
- }{
- 1
- }ifelse
- dup 2.5 mul
- gsave
- dup neg 0 exch moveto
- dup neg 0 lineto
- dup 0 exch lineto
- 0 lineto
- closepath
- 1 index /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if
- 1 index fillborderpath
- grestore
- 3 mul
- dup neg 0 exch moveto
- dup neg 0 lineto
- dup 0 exch lineto
- 0 lineto
- closepath
- strokeborderpath
- } bind executeonly def
- /OpenArrow {
- dup
- gsave
- /BS knownoget {
- /W knownoget {
- }{
- 1
- }ifelse
- }{
- 1
- }ifelse
- 0 setlinejoin
- dup 6 mul neg 1 index 4 mul neg moveto dup 1.2 div neg 0 lineto
- dup 6 mul neg exch 4 mul lineto
- strokeborderpath
- grestore
- } bind executeonly def
- /ClosedArrow {
- dup
- gsave
- /BS knownoget {
- /W knownoget {
- }{
- 1
- }ifelse
- }{
- 1
- }ifelse
- dup
- gsave
- 0 setlinejoin
- dup 6 mul neg 1 index 4 mul neg moveto dup 1.2 div neg 0 lineto
- dup 6 mul neg exch 4 mul lineto closepath
- 1 index strokeborderpath
- grestore
- dup 1.3 mul neg 0 translate
- dup 2 div sub
- dup 8.4 mul neg 1 index 5.9 mul neg moveto dup 1.2 div neg 0 lineto
- dup 8.4 mul neg exch 5.9 mul lineto closepath
- dup /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if
- fillborderpath
- grestore
- } bind executeonly def
- /None {pop} bind executeonly def
- /Butt {
- dup
- /BS knownoget {
- /W knownoget {
- }{
- 1
- }ifelse
- }{
- 1
- }ifelse
- 3 mul dup neg 0 exch moveto 0 exch lineto
- strokeborderpath
- } bind executeonly def
- /ROpenArrow {
- gsave
- dup
- /BS knownoget {
- /W knownoget {
- }{
- 1
- }ifelse
- }{
- 1
- }ifelse
- 180 rotate
- 0 setlinejoin
- dup 6 mul neg 1 index 4 mul neg moveto dup 1.2 div neg 0 lineto
- dup 6 mul neg exch 4 mul lineto
- strokeborderpath
- grestore
- } bind executeonly def
- /RClosedArrow {
- gsave
- dup
- /BS knownoget {
- /W knownoget {
- }{
- 1
- }ifelse
- }{
- 1
- }ifelse
- 180 rotate
- dup
- gsave
- 0 setlinejoin
- dup 6 mul neg 1 index 4 mul neg moveto dup 1.2 div neg 0 lineto
- dup 6 mul neg exch 4 mul lineto closepath
- 1 index strokeborderpath
- grestore
- dup 1.3 mul neg 0 translate
- dup 2 div sub
- dup 8.4 mul neg 1 index 5.9 mul neg moveto dup 1.2 div neg 0 lineto
- dup 8.4 mul neg exch 5.9 mul lineto closepath
- dup /CA knownoget {dup .setstrokeconstantalpha .setfillconstantalpha} if
- fillborderpath
- grestore
- } bind executeonly def
- /Slash {
- gsave
- dup
- /BS knownoget {
- /W knownoget {
- }{
- 1
- }ifelse
- }{
- 1
- }ifelse
- 330 rotate
- 3 mul dup neg 0 exch moveto 0 exch lineto
- strokeborderpath
- grestore
- } bind executeonly def
-
- currentdict end readonly def
-
- /Line {
- //ValidateAP exec
- {
- //true
- } {
- gsave
- //startannottransparency exec
- dup annotsetcolor {
- dup /L knownoget {
- 1 index /LE knownoget { % <annot> [x1 y1 x2 y2] [LE1 LE2]
- gsave
- 1 index aload pop % <annot> [x1 y1 x2 y2] [LE1 LE2] x1 y1 x2 y2
- 3 -1 roll sub % <annot> [x1 y1 x2 y2] [LE1 LE2] x1 x2 dy
- 3 1 roll exch sub % <annot> [x1 y1 x2 y2] [LE1 LE2] dy dx
- 3 index aload pop 4 2 roll pop pop
- translate
- 0 0 moveto
- {atan} stopped {pop pop 0} if % <annot> [x1 y1 x2 y2] [LE1 LE2]
- rotate
- dup 1 get % <annot> [x1 y1 x2 y2] [LE1 LE2] LE1
- dup //LineEnd_dict exch known not
- {
- pop /None
- } if
- //LineEnd_dict exch % <annot> [x1 y1 x2 y2] [LE1 LE2] <dict> LE1
- get % <annot> [x1 y1 x2 y2] [LE1 LE2] {}
- 3 index exch % <annot> [x1 y1 x2 y2] [LE1 LE2] <annot> {}
- exec
- grestore
- gsave
- 1 index aload pop % x1 y1 x2 y2
- 3 -1 roll sub % x1 x2 dy
- 3 1 roll exch sub % dy dx
- 3 index aload pop pop pop
- translate
- 0 0 moveto
- {atan} stopped {pop pop 0} if 180 add
- rotate
- 0 get dup //LineEnd_dict exch known not {pop /None} if //LineEnd_dict exch get 3 index exch exec
- grestore
- }if
- aload pop 4 2 roll
- moveto lineto
- strokeborderpath
- }{
- ( **** Error: Invalid L array for Line, annotation has not been drawn.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop
- } ifelse
- } if
- //endannottransparency exec
- //false
- grestore
- } ifelse
- } bind executeonly def
-
- /PolyLine {
- //ValidateAP exec
- {
- //true
- } {
- gsave
- //startannottransparency exec
- dup annotsetcolor pop
- dup /Vertices knownoget {
- 1 index /LE knownoget {
- gsave
- 1 index 0 4 getinterval aload pop
- 4 2 roll
- 2 copy translate 4 2 roll
- 3 -1 roll exch sub % x1 x2 dy
- 3 1 roll sub % dy dx
- {atan} stopped {pop pop 0} if
- rotate
- dup 0 get dup //LineEnd_dict exch known not {pop /None} if //LineEnd_dict exch get 3 index exch exec
- grestore
-
- gsave
- 1 index dup length 4 sub 4 getinterval aload pop
- 2 copy translate
- 3 -1 roll sub % x1 x2 dy
- 3 1 roll exch sub % dy dx
- {atan} stopped {pop pop 0} if
- rotate
- 1 get dup //LineEnd_dict exch known not {pop /None} if //LineEnd_dict exch get 3 index exch exec
- grestore
- } if
- dup length 2 div 1 sub cvi 0 1 3 -1 roll
- {
- 2 mul dup
- 2 index exch 2 getinterval aload pop
- 3 -1 roll 0 eq {
- moveto
- }{
- lineto
- } ifelse
- }
- for
- pop
- //true
- } {
- ( **** Error: Invalid Vertices for Polygon, annotation has not been drawn.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- //false
- } ifelse
-
- {
- strokeborderpath
- } if
- //endannottransparency exec
- //false
- grestore
- } ifelse
- } bind executeonly def
-
- /Link { % <annot> -> <false>
- //startannottransparency exec
- dup annotsetcolor {
- dup drawborder dup calc_annot_scale
- 2 copy mul 0 ne
- {3 -1 roll drawwidget}
- {
- pop pop
- ( **** Error: ignoring annotation with scale factor of 0\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }ifelse
- } if
- //endannottransparency exec
- //false
- } bind executeonly def
-
- /Ink { % <annot> -> <annot> <true>
- % <annot> -> <false>
- //ValidateAP exec
- {
- //true
- } {
- //startannottransparency exec
- 1 setlinewidth
- 1 setlinecap
- 1 setlinejoin
- dup annotsetcolor
- {
- dup calc_annot_scale
- 2 copy mul 0 ne
- {
- scale
- dup /InkList knownoget {
- { oforce
- [ exch { oforce } forall ]
- .pdfinkpath
- stroke
- } forall
- pop
- } {
- /Path knownoget {
- oforce
- dup length 1 sub 0 1 3 -1 roll {
- dup 0 eq {
- 1 index exch get aload pop moveto
- } {
- 1 index exch get dup length 2 eq {
- aload pop lineto
- }{
- aload pop curveto
- } ifelse
- }ifelse
- } for
- pop dup
- strokeborderpath
- } if
- }ifelse
- }
- {
- pop pop
- ( **** Error: ignoring annotation with scale factor of 0\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }
- ifelse
- } if
- //endannottransparency exec
- //false
- } ifelse
- } bind executeonly def
-
- /Underline {
- //ValidateAP exec
- {
- //true
- } {
- 0 setlinecap
- dup annotsetcolor
- {
- dup calc_annot_scale
- 2 copy mul 0 ne
- {
- scale
- /QuadPoints knownoget {
- aload length 8 idiv {
- //quadpoints2basis exec
-
- % Acrobat draws the line at 1/7 of the box width from the bottom
- % of the box and 1/16 thick of the box width. /Rect is ignored.
-
- 2 copy dup mul exch dup mul add sqrt 16 div setlinewidth
- 7 div 4 index add exch % x0 y0 x1-x0 y1-y0 (y2-y0)/7+y0 x2-x0
- 7 div 5 index add exch % x0 y0 x1-x0 y1-y0 (x2-x0)/7+x0 (y2-y0)/7+y0
- 2 copy moveto
- 2 index add exch
- 3 index add exch lineto % x0 y0 x1-x0 y1-y0
- pop pop pop pop
- stroke
- } repeat
- } if
- }
- {
- pop pop
- ( **** Error: ignoring annotation with scale factor of 0\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }
- ifelse
- } if
- //false
- } ifelse
- } bind executeonly def
-
- /StrikeOut {
- //ValidateAP exec
- {
- //true
- } {
- 0 setlinecap
- dup annotsetcolor
- {
- dup calc_annot_scale
- 2 copy mul 0 ne
- {
- scale
- /QuadPoints knownoget {
- aload length 8 idiv {
- //quadpoints2basis exec
-
- % Acrobat draws the line at 3/7 of the box width from the bottom
- % of the box and 1/16 thick of the box width. /Rect is ignored.
-
- 2 copy dup mul exch dup mul add sqrt 16 div setlinewidth
- 0.4285714 mul 4 index add exch % x0 y0 x1-x0 y1-y0 (y2-y0)*3/7+y0 x2-x0
- 0.4285714 mul 5 index add exch % x0 y0 x1-x0 y1-y0 (x2-x0)*3/7+x0 (y2-y0)*3/7+y0
- 2 copy moveto
- 2 index add exch
- 3 index add exch lineto % x0 y0 x1-x0 y1-y0
- pop pop pop pop
- stroke
- } repeat
- } if
- }
- {
- pop pop
- ( **** Error: ignoring annotation with scale factor of 0\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }
- ifelse
- } if
- //false
- } ifelse
- } bind executeonly def
-
- % Connect 2 points with an arc that has max distance from the line
- % segment to the ark equal 1/4 of the radius.
- /highlight-arc { % x1 y1 x0 y0 -> -
- 4 2 roll % x0 y0 x1 y1
- dup 3 index add 2 div % x0 y0 x1 y1 (y1+y0)/2
- 2 index 5 index sub .9375 mul sub % x0 y0 x1 y1 (y1+y0)/2-15/16*dx=yc
- 4 index 3 index add 2 div % x0 y0 x1 y1 yc (x0+x1)/2
- 2 index 5 index sub .9375 mul add % x0 y0 x1 y1 yc xc
- exch % x0 y0 x1 y1 xc yc
- dup 3 index exch sub % x0 y0 x1 y1 xc yc y1-yc
- 4 index 3 index sub % x0 y0 x1 y1 xc yc y1-yc x1-xc
- dup dup mul 2 index dup mul add sqrt %x0 y0 x1 y1 xc yc y1-yc x1-xc r
- 3 1 roll atan % x0 y0 x1 y1 xc yc r a1
- 6 index 3 index sub % x0 y0 x1 y1 xc yc r a1 y0-yc
- 8 index 5 index sub % x0 y0 x1 y1 xc yc r a1 y0-yc x0-xc
- atan % x0 y0 x1 y1 xc yc r a1 a2
- exch arcn % x0 y0 x1 y1
- pop pop pop pop
- } bind executeonly def
-
- /emptydict 0 dict readonly def
-
- /Highlight {
- //ValidateAP exec
- {
- //true
- } {
- 0 setlinecap
- dup annotsetcolor
- {
- /QuadPoints knownoget {
- aload length 8 idiv {
- 6 -2 roll
- 2 copy moveto
- //highlight-arc exec
- 2 copy lineto
- //highlight-arc exec
- closepath
- } repeat
- PDFusingtransparency {
- //emptydict
- % If we get an error, just emit an empty box
- { pathbbox } stopped { 0 0 0 0 } if
- 2 index add exch 3 index add exch .begintransparencygroup
- /Multiply .setblendmode
- fill
- .endtransparencygroup
- } { % for -dNOTRANSPARENCY
- stroke newpath
- } ifelse
- } if
- } if
- //false
- } ifelse
- } bind executeonly def
- currentdict /emptydict undef
- currentdict /highlight-arc undef
-
- /Squiggly {
- //ValidateAP exec
- {
- //true
- } {
- //startannottransparency exec
- dup annotsetcolor
- {
- dup calc_annot_scale
- 2 copy mul 0 ne
- {
- scale
- /QuadPoints knownoget {
- aload length 8 idiv {
- gsave
- 8 copy moveto lineto
- 4 2 roll lineto lineto closepath clip newpath
- //quadpoints2basis exec
- 6 -2 roll translate % adjust for x0 y0 % x1-x0 y1-y0 x2-x0 y2-y0
- 1 index 56 div 1 index 56 div translate % zigzag box is 1/56 up
- 1 index 72 div 1 index 72 div translate % the line in the box is 1/72 up
- 2 copy dup mul exch dup mul add sqrt % x1-x0 y1-y0 x2-x0 y2-y0 |p2|
- 4 index dup mul 4 index dup mul add sqrt % x1-x0 y1-y0 x2-x0 y2-y0 |p2| |p1|
- dup 0 gt 2 index 0 gt and {
- div % x1-x0 y1-y0 x2-x0 y2-y0 |p2|/|p1|=p12
- dup 1 exch div 4 mul 1 add cvi exch 6 2 roll % cnt p12 x1-x0 y1-y0 x2-x0 y2-y0
- 4 2 roll % cnt p12 x2-x0 y2-y0 x1-x0 y1-y0
- 4 index mul exch 4 index mul exch % cnt p12 x2-x0 y2-y0 (x1-x0)*p12 (y1-y0)*p12
- 4 2 roll 0 0 6 array astore concat % cnt p12
- 1 40 div 1 72 div scale
- pop % cnt
- 0 0 moveto
- 1 setlinecap
- 1 setlinejoin
- 1 setlinewidth
- {
- 5 10 lineto
- 10 0 lineto
- 10 0 translate
- } repeat
- stroke
- } {
- 6 { pop } repeat
- } ifelse
- grestore
- } repeat
- } if
- }
- {
- pop pop
- ( **** Error: ignoring annotation with scale factor of 0\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }
- ifelse
- } if
- //endannottransparency exec
- //false
- } ifelse
- } bind executeonly def
-
- /Text {
- //ValidateAP exec
- {
- //true
- } {
- //startannottransparency exec
- dup calc_annot_scale
- 2 copy mul 0 ne
- {
- scale
- annotrect 4 2 roll translate
- exch pop
-
- % Draw a page icon
- 0.5 exch 18.5 sub translate
- 1 setlinewidth
- 0.75 setgray
- 0.5 -1 moveto 10 -1 lineto 15 4 lineto 15 17.5 lineto stroke
-
- 0 0 moveto
- 9 0 lineto
- 14 5 lineto
- 14 18 lineto
- 0 18 lineto closepath
- gsave .5 setgray fill grestore 0 setgray stroke
-
- 3 8 moveto 7.5 8 lineto
- 3 11 moveto 10 11 lineto
- 3 14 moveto 10 14 lineto
- 9 0 moveto 9 5 lineto 14 5 lineto
- stroke
- }
- {
- pop pop
- ( **** Error: ignoring annotation with scale factor of 0\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }
- ifelse
- //endannottransparency exec
- //false
- } ifelse
- } bind executeonly def
-
- /FreeText {
- //ValidateAP exec
- {
- //true
- }
- %% We either have no appearance, or its invalid, make one up.
- {
- gsave
-
- //startannottransparency exec
- dup annotrect rectclip
-
- dup /CA knownoget {
- dup .setstrokeconstantalpha .setfillconstantalpha
- } if
-
- dup /ca knownoget {
- dup .setstrokeconstantalpha .setfillconstantalpha
- } if
-
- dup /C knownoget {
- dup length 4 eq {
- aload pop setcmykcolor //true
- }{
- dup length 3 eq {
- aload pop setrgbcolor //true
- }{
- dup length 1 eq {
- aload pop setgray //true
- } {
- dup length 0 eq {
- pop
- //false
- }{
- ( **** Error: invalid color specified for FreeText annotation /C entry)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- //false
- } ifelse
- } ifelse
- } ifelse
- } ifelse
- }{
- //false
- } ifelse
- {
- dup annotrect
- 5 index /RD knownoget {
- applyRD
- } if
- rectfill
- } if
-
- %% get and process the default appearance string, if we don't have one, use a default
- /DA_Action_Dict
- <<
- /Tf
- {
- exch dup /Helv eq
- {
- pop /Helvetica dup findfont
- }
- {dup findfont}ifelse
-
- % re-encode the font to PDFDocEncoding
- dup length dict begin
- {
- 1 index /FID ne 2 index /UniqueID ne and { def } { pop pop } ifelse
- } forall
- /Encoding /PDFDocEncoding /Encoding findresource def
- /FontName /Helvetica-PDFDocEncoding def
- currentdict
- end
- definefont
- exch scalefont setfont
- }
- /r {aload pop setrgbcolor} % Can't find this actually defined anywhere, but Acrobat seems to honour it :-(
- /rg {setrgbcolor}
- /RG {setrgbcolor}
- /G {setgray}
- /g {setgray}
- /k {setcmykcolor}
- /K {setcmykcolor}
- >> def
-
- % Set some sane defaults, in case the /DA does not.
- 0 setgray
- /Helvetica findfont
- % re-encode the font to PDFDocEncoding
- dup length dict begin
- {
- 1 index /FID ne 2 index /UniqueID ne and { def } { pop pop } ifelse
- } forall
- /Encoding /PDFDocEncoding /Encoding findresource def
- /FontName /Helvetica-PDFDocEncoding def
- currentdict
- end
- /Helvetica-PDFDocEncoding exch definefont
- 12 scalefont setfont
-
- dup /DA knownoget {
- length string /tempstr exch def
- dup /DA get tempstr copy pop
-
- gstate
- mark
- {
- {
- %% This is kind of ugly, we use token to process the string
- %% and process each token separately.
- tempstr
- token {
- exch /tempstr exch def
- %% If the token is a name
- %%
- dup type /nametype eq {
- %% Is it a name we want to take actionon
- dup DA_Action_Dict exch known {
- DA_Action_Dict exch get exec
- }{
- %% Its not a name we know, is it executable
- dup xcheck {exec} if
- } ifelse
- }{
- %% Not a name, just make it executable and execute it
- cvx exec
- }ifelse
- }{
- exit
- }ifelse
- } loop
- } stopped
- {cleartomark setgstate}
- {cleartomark pop} ifelse
- } if
-
- %% draw the border, if we don't have a border style dictionary, draw a default one.
- dup /BS knownoget
- {
- pop dup drawborder
- }{
- newpath
- 0 setgray 1 setlinewidth
- dup annotrect
- 5 index /RD knownoget {
- applyRD
- 4 -1 roll 4 -1 roll 4 -1 roll 4 -1 roll
- 4 2 roll
- } {
- 4 -1 roll 1 add 4 -1 roll 1 add 4 -1 roll 2 sub 4 -1 roll 2 sub
- 4 2 roll
- }ifelse
- moveto
- currentpoint exch 3 index add exch
- lineto
- currentpoint 2 index add
- lineto
- exch currentpoint 3 1 roll exch sub exch
- lineto
- currentpoint 3 -1 roll sub
- lineto stroke
- }ifelse
-
- gsave % in case we rotate the contents
- %% Start the current point at the top left of the annotation Rect
- %%
- dup /Rotate knownoget
- % x y w h - x' w' x' y'
- {
- dup 90 eq {
- pop
- dup annotrect
- 5 index /RD knownoget {
- applyRD
- } if
- exch pop 3 -1 roll 2 index
- moveto 90 rotate
- 1 index add
- } {
- dup 180 eq {
- pop
- dup annotrect
- 5 index /RD knownoget {
- applyRD
- } if
- pop 3 -1 roll 1 index add -1 mul exch 1 index -1 mul 4 -1 roll
- moveto 180 rotate
- 1 index add
- }{
- 270 eq {
- dup annotrect
- 5 index /RD knownoget {
- applyRD
- } if
- dup 4 -1 roll add 3 -1 roll 3 index add exch
- moveto 270 rotate
- exch pop currentpoint
- pop dup 3 -1 roll add
- }{
- dup annotrect
- 5 index /RD knownoget {
- applyRD
- 3 -1 roll add 2 index exch
- moveto 1 index add
- }{
- 4 -1 roll 2 add 4 -1 roll 2 add 4 -1 roll 4 sub 4 -1 roll 4 sub
- 3 -1 roll add 2 index exch
- moveto 1 index add
- } ifelse
- } ifelse
- } ifelse
- } ifelse
- }{
- dup annotrect
- 5 index /RD knownoget {
- applyRD
- 3 -1 roll add 2 index exch
- moveto 1 index add
- }{
- 4 -1 roll 2 add 4 -1 roll 2 add 4 -1 roll 4 sub 4 -1 roll 4 sub
- 3 -1 roll add 2 index exch
- moveto 1 index add
- } ifelse
- } ifelse
-
- %% Get the Contents string, if we don't have one, we're done
- %%
- 2 index /Contents knownoget {
- dup length 0 gt {
- PDFusingtransparency {
- .begintransparencytextgroup
- } if
- %% Check for UTF16-BE, we probably don't work properly with this yet.
- %% (If the string is less than 4 bytes its either not UTF16-BE or it is
- %% but has no actual content)
- dup length 4 ge {
- dup 0 get 254 eq 1 index 1 get 255 eq and
- }{
- //false
- } ifelse
-
- {
- /FallBackFont /Identity-UTF16-H [/CIDFallBack] composefont 12 scalefont setfont
- dup length 2 div 1 sub 0 1 3 -1 roll {
- %% llx urx (string) index
- 1 index exch 2 mul 2 getinterval %% llx urx (string) (substring)
- dup stringwidth pop currentpoint pop add 3 index gt {
- currentpoint exch pop 4 index exch 12 sub moveto
- } if
- show
- } for
- pop
- }
- {
- %% Heuristic to determine the height (ascender to descender) of the text
- %% for when we move down a line.
- gsave
- /..TextHeight (Hy) //false charpath pathbbox exch pop exch sub exch pop def
- grestore
- %% and use it immediatley to start the text one line down
- %%
- currentpoint ..TextHeight sub moveto
- %% Now we process each character code in the string. If we find
- %% a /r/ or /n then we drop a line. If the character would end up
- %% outside the Annot Rect, then we drop a line before showing it.
- %%
- dup length 1 sub 0 1 3 -1 roll {
- %% llx urx (string) index
- 1 index exch get %% llx urx (string) int
- dup 10 eq 1 index 13 eq or {
- pop
- currentpoint exch pop 3 index exch ..TextHeight sub moveto
- } {
- 1 string dup 0 4 -1 roll
- put dup %% llx urx (string) (int) (int)
- stringwidth pop currentpoint pop add 3 index
- gt {
- currentpoint exch pop 4 index exch ..TextHeight sub moveto
- } if
- show
- } ifelse
- } for
- pop
- }ifelse
- PDFusingtransparency {
- .endtransparencytextgroup
- } if
- }
- {
- pop
- } ifelse
- } if
- pop pop
-
- grestore % in case the contents were rotated
- dup /CL knownoget {
- dup length 6 eq {
- dup aload pop pop pop
- } {
- dup length 4 eq {
- dup aload pop
- } {
- pop 0
- } ifelse
- } ifelse
- 4 2 roll
- exch 4 -1 roll sub
- 3 1 roll exch sub
- atan exch
- aload pop moveto lineto lineto
- currentpoint
-% stroke
-% 0 1 0 setrgbcolor
- moveto currentpoint translate 0 0 moveto
- 360 exch sub rotate
- currentpoint
- -5 -8 rlineto
- moveto
- 5 -8 rlineto
- stroke
- } if
- //endannottransparency exec
- //false
- grestore
- } ifelse
- } bind executeonly def
-
- /frame {
- { 255 div } forall setrgbcolor
- -95 -25 translate
- 2 190 atan rotate
- {
- 6 0 moveto
- 190 0 190 6 6 arct
- 190 47 184 47 6 arct
- 0 47 0 41 6 arct
- 0 0 6 0 6 arct
- closepath
-
- 10 4 moveto
- 185 4 185 9 5 arct
- 185 43 180 43 5 arct
- 5 43 5 38 5 arct
- 5 4 9 4 5 arct
- closepath
- eofill
- }
- gsave 1 -1 translate 0.75 setgray dup exec grestore
- exec
- } bind executeonly def
-
- % (text) y h -> -
- /text {
- PDFusingtransparency {
- .begintransparencytextgroup
- } if
- /Times-Bold findfont
- % re-encode the font to PDFDocEncoding
- dup length dict begin
- {
- 1 index /FID ne 2 index /UniqueID ne and { def } { pop pop } ifelse
- } forall
- /Encoding /PDFDocEncoding /Encoding findresource def
- /FontName /Times-Bold-PDFDocEncoding def
- currentdict
- end
- /Times-Bold-PDFDocEncoding exch definefont
- exch scalefont setfont % (text) y
- gsave
- 0 0 moveto
- 1 index //false charpath flattenpath pathbbox
- pop exch pop sub 2 div
- grestore
- 95 add exch moveto
- gsave 1 -1 rmoveto 0.75 setgray dup show grestore
- show
- PDFusingtransparency {
- .endtransparencytextgroup
- } if
- } bind executeonly def
-
- /red <ef4023> readonly def
- /green <3fae49> readonly def
- /blue <0072bc> readonly def
-
- /stamp_dict 14 dict begin
- /Approved {
- //green //frame exec
- (APPROVED) 13 30 //text exec
- } bind executeonly def
- /AsIs {
- //red //frame exec
- (AS IS) 13 30 //text exec
- } bind executeonly def
- /Confidential {
- //red //frame exec
- (CONFIDENTIAL) 17 20 //text exec
- } bind executeonly def
- /Departmental {
- //blue //frame exec
- (DEPARTMENTAL) 17 20 //text exec
- } bind executeonly def
- /Draft {
- //red //frame exec
- (DRAFT) 13 30 //text exec
- } bind executeonly def
- /Experimental {
- //blue //frame exec
- (EXPERIMENTAL) 17 20 //text exec
- } bind executeonly def
- /Expired {
- //red //frame exec
- (EXPIRED) 13 30 //text exec
- } bind executeonly def
- /Final {
- //red //frame exec
- (FINAL) 13 30 //text exec
- } bind executeonly def
- /ForComment {
- //green //frame exec
- (FOR COMMENT) 17 20 //text exec
- } bind executeonly def
- /ForPublicRelease {
- //green //frame exec
- (FOR PUBLIC) 26 18 //text exec
- (RELEASE) 8.5 18 //text exec
- } bind executeonly def
- /NotApproved {
- //red //frame exec
- (NOT APPROVED) 17 20 //text exec
- } bdef
- /NotForPublicRelease {
- //red //frame exec
- (NOT FOR) 26 18 //text exec
- (PUBLIC RELEASE) 8.5 18 //text exec
- } bind executeonly def
- /Sold {
- //blue //frame exec
- (SOLD) 13 30 //text exec
- } bind executeonly def
- /TopSecret {
- //red //frame exec
- (TOP SECRET) 14 26 //text exec
- } bind executeonly def
- currentdict end readonly def
-
- {/text/frame/red/green/blue} {currentdict exch undef} forall
-
- /Stamp {
- //ValidateAP exec
- {
- //true
- } {
- //startannottransparency exec
- dup calc_annot_scale
- 2 copy mul 0 ne
- {
- scale
- % translate to the center of Rect
- dup annotrect
- 4 2 roll % dx dy x0 y0
- 2 index 2 div add exch
- 3 index 2 div add exch translate % dx dy
-
- 50 div exch 190 div .min dup 0.0 eq {pop 1.0} if dup scale
-
- /Name knownoget not { /Draft } if
- //stamp_dict 1 index known not { exch pop /Draft exch } if
- //stamp_dict exch get exec
- }
- {
- pop pop
- ( **** Error: ignoring annotation with scale factor of 0\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }
- ifelse
- //endannottransparency exec
- //false
- } ifelse
- } bind executeonly def
-
- /Popup {
- dup /Open oknown {
- dup /Open get {
- //ValidateAP exec
- {
- //true
- } {
- gsave
- //startannottransparency exec
- newpath
- 0.05 setlinewidth
- dup /Parent .knownget {
- oforce
- } {
- dup /P .knownget {
- oforce
- } {
- dup
- } ifelse
- } ifelse
- /C .knownget {
- aload pop
- }{
- 1 1 0
- }ifelse
- setrgbcolor
- dup /Rect get
- dup aload pop
- 2 index sub
- exch 3 index sub exch
- 4 copy
- gsave 1 setgray rectfill grestore
- gsave 0 setgray rectstroke grestore
- 1 index /Parent .knownget {
- oforce
- }{
- 1 index /P .knownget {
- oforce
- }{
- 1 index
- } ifelse
- }ifelse
- dup
- /Contents .knownget {
- gsave
- PDFusingtransparency {
- .begintransparencytextgroup
- } if
- 0 setgray
- /Helvetica findfont
- % re-encode the font to PDFDocEncoding
- dup length dict begin
- {
- 1 index /FID ne 2 index /UniqueID ne and { def } { pop pop } ifelse
- } forall
- /Encoding /PDFDocEncoding /Encoding findresource def
- /FontName /Helvetica-PDFDocEncoding def
- currentdict
- end
- /Helvetica-PDFDocEncoding exch definefont
- 9 scalefont setfont
- 2 index aload pop 3 1 roll pop pop 30 sub exch 5 add exch
- moveto show
- PDFusingtransparency {
- .endtransparencytextgroup
- } if
- grestore
- } if
- exch
- dup aload pop 3 -1 roll pop exch 2 index sub -15
- 4 copy rectfill
- 0 setgray rectstroke
- exch
- /T .knownget {
- gsave
- PDFusingtransparency {
- .begintransparencytextgroup
- } if
- 0 setgray
- /Helvetica findfont
- % re-encode the font to PDFDocEncoding
- dup length dict begin
- {
- 1 index /FID ne 2 index /UniqueID ne and { def } { pop pop } ifelse
- } forall
- /Encoding /PDFDocEncoding /Encoding findresource def
- /FontName /Helvetica-PDFDocEncoding def
- currentdict
- end
- /Helvetica-PDFDocEncoding exch definefont
- 9 scalefont setfont
- dup stringwidth pop
- 2 index aload pop pop exch pop exch sub
- exch sub 2 div 2 index aload pop 3 1 roll pop pop 11 sub 3 1 roll add exch moveto
- show
- PDFusingtransparency {
- .endtransparencytextgroup
- } if
- grestore
- } if
- grestore
- //endannottransparency exec
- //false
- } ifelse
- } {
- pop //false
- }ifelse
- } {
- pop //false
- }ifelse
- } bind executeonly def
-
- /Redact {
- %% Redact annotations are part of a process, a Redact annotation is only present
- %% until the content is removed, before that the content should be present and
- %% I beleive we should print it. So take no action for Redact annotations if they
- %% have no appearance.
- //ValidateAP exec
- {
- //true
- } {
- //false
- } ifelse
- } bind executeonly def
-
-currentdict /startannottransparency undef
-currentdict /endannottransparency undef
-currentdict /ValidateAP undef
-currentdict /quadpoints2basis undef
-currentdict /drawellipse undef
-currentdict end readonly def
-
-/.PDFDrawAnnotType?
-{
- //false exch
- /ShowAnnotTypes where
- {
- /ShowAnnotTypes get
- {
- dup /* eq exch 2 index eq or
- {
- pop //true exch
- exit
- } if
- } forall
- pop
- }
- {pop pop //true}
- ifelse
-} bind executeonly def
-
-/.PDFPreserveAnnotType?
-{
- //false exch
- /PreserveAnnotTypes where
- {
- /PreserveAnnotTypes get
- {
- dup /* eq exch 2 index eq or
- {
- pop //true exch
- exit
- } if
- } forall
- pop
- }
- {pop pop //true}
- ifelse
-} bind executeonly def
-
-/drawannot { % <annot> drawannot -
- dup annotvisible {
- gsave
- dup dup /Subtype knownoget {
- dup //.PDFDrawAnnotType? exec
- {
- //drawannottypes exch .knownget { exec } { //true } ifelse
- {
- dup calc_annot_scale 2 copy mul 0 ne
- {
- 3 -1 roll drawwidget
- }
- {
- ( **** Error: ignoring annotation with scale factor of 0\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }ifelse % Draw rejected annots as widgets
- } if % type known
- }
- {
- pop
- }ifelse
- } {
- pop
- ( **** Error: Ignoring /Annot dict without required /Subtype entry.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- grestore
- } if pop % annotvisible
-} bind executeonly def
-currentdict /drawannottypes undef
-
-% Draw an annotation.
-
-/loadannot {
- dup /AP .knownget { % <<Annot dict>> <<Appearance dictionary>> true | false
- oforce
-
- dup { % <<Annot dict>> <<Appearance dict>> /Key <</Key dict>>
- oforce % <<Annot dict>> <<Appearance dict>> /Key <<resolved /Key dict>>
-
- %%
- %% Check to see if the apperance key has a simple stream or a dictionary of states
- %%
- dup /Subtype known % <<Annot dict>> <<Appearance dict>> /Key <<resolved /Key dict>> bool
- {
- %% Simple appearance stream
- DoAppearance % <<Annot dict>> <<Appearance dict>> /Key
- 2 index % <<Annot dict>> <<Appearance dict>> /Key <<Annot dict>>
- /AP << % <<Annot dict>> <<Appearance dict>> /Key <<Annot dict>> /AP <<
- 4 -1 roll MakeAppearanceName cvx cvn >> put % <<Annot dict>> <<Appearance dict>>
- } {
- %% dictionary of states <<Annot dict>> <<Appearance dict>> /Key <<appearance states dict>>
- dup % <<Annot dict>> <<Appearance dict>> /Key <<appearance states dict>> <<appearance states dict>>
- { % <<Annot dict>> <<Appearance dict>> /Key <<appearance states dict>> /StateKey <<State dictionary>>
- oforce % <<Annot dict>> <<Appearance dict>> /Key <<appearance states dict>> /StateKey <<resolved State dictionary>>
- DoAppearance % <<Annot dict>> <<Appearance dict>> /Key <<appearance states dict>> /StateKey
- 1 index exch % <<Annot dict>> <<Appearance dict>> /Key <<appearance states dict>> <<appearance states dict>> /StateKey
- MakeAppearanceName cvx cvn % <<Annot dict>> <<Appearance dict>> /Key <<appearance states dict>> <<appearance states dict>> /StateKey {}
- put % <<Annot dict>> <<Appearance dict>> /Key <<appearance states dict>>
- } forall
- put % <<Annot dict>> <<Appearance dict>> /Key
- dup
- }ifelse
- } forall
- pop % <<Annot dict>>
- } if
-
- %% Parent (or /P) references will be incorrect. Remove them
- %% for now as they are optional.
- dup /Popup known {dup /Popup undef} if
- dup /IRT known {dup /IRT undef} if
- dup /RT known {dup /RT undef} if
- dup /P known {dup /P undef} if
- dup /Parent known {dup /Parent undef} if
-
- %% Resolve any indirect references. May need further work :-(
- {
- %% We know /AP doesn't need processing, we handled that above...
- 1 index /AP eq not {
- dup {oforce} stopped not {exch pop} if
- dup type /dicttype eq{
- dup
- {
- dup {oforce} stopped not {exch pop} if
- 2 index 3 1 roll put
- } forall
- Removepdfobj#
- } if
- dup type /arraytype eq {
- 0 1 2 index length 1 sub{
- dup 2 index exch get dup {oforce} stopped not {exch pop} if
- 2 index 3 1 roll put
- } for
- } if
- } if
- } forall
-} bind executeonly def
-
-
-/ApplyCTMToQuadPoints {
- %% Nasty hackery here really. We need to undo the HWResolution scaling which
- %% is done by pdfwrite. Default is 720 dpi, so 0.1. We also need to make
- %% sure that any translation of the page (because its been rotated for example)
- %% is also modified by the requisite amount. SO we ned to calculate a matrix
- %% which does the scaling and concatenate it with the current matrix.
- %% Do this inside a gsave/grestore pair to avoid side effects!
-
- gsave
- currentpagedevice /HWResolution get
- aload pop exch 72 exch div exch 72 exch div
- matrix 3 1 roll 2 index 3 3 -1 roll put
- 1 index 0 3 -1 roll put
- matrix currentmatrix exch matrix concatmatrix
- setmatrix
-
- oforce
-
- %% QuadPoints are given as 'n' sequences of 8 numbers.
-
- mark exch aload counttomark 1 roll
- counttomark 1 sub 2 div cvi {
- transform
- counttomark 1 sub 2 roll
- } repeat
- counttomark -1 roll astore
-
- exch pop % the mark
-
- grestore
-} bind executeonly def
-
-/preserveannottypes 20 dict begin
-
-/Circle {mark exch loadannot /ANN pdfmark //false} bind executeonly def
-/FileAttachment {mark exch loadannot /ANN pdfmark //false} bind executeonly def
-/FreeText {mark exch loadannot /ANN pdfmark //false} bind executeonly def
-
-/Highlight {
- mark exch
- dup /QuadPoints .knownget {
- 1 index /QuadPoints 3 -1 roll
- ApplyCTMToQuadPoints
- put
- } if
- loadannot /ANN pdfmark //false
-} bind executeonly def
-
-/Ink {mark exch loadannot /ANN pdfmark //false} bind executeonly def
-
-/PolyLine {mark exch loadannot /ANN pdfmark //false} bind executeonly def
-
-/Line {mark exch loadannot /ANN pdfmark //false} bind executeonly def
-
-/Link {
- /NO_PDFMARK_DESTS where {pop NO_PDFMARK_DESTS not}{//true}ifelse
- {
- mark exch
- dup /BS knownoget { << exch { oforce } forall >> /BS exch 3 -1 roll } if
- dup /F knownoget { /F exch 3 -1 roll } if
- dup /C knownoget { /Color exch 3 -1 roll } if
- dup /Rect knownoget { /Rect exch 3 -1 roll } if
- dup /Border knownoget {
- dup type /arraytype eq {
- dup length 3 lt
- } {
- //true
- } ifelse {
- pop [ 0 0 0 ] % Following AR5 use invisible border.
- } if
- /Border exch 3 -1 roll
- } if
- dup /A knownoget {
- dup /URI known {
- /A mark 3 2 roll % <<>> /A [ <<action>>
- { oforce } forall
- .dicttomark
- 3 2 roll
- } {
- dup /S knownoget {
- %% Because we process GoTo Destinations into absolute references in the PDF file
- %% we need to resolve the /D or /Dest. However, we must *not* do this for
- %% GoToR Destinations because (obviously) those are in a different file and
- %% we cannot resolve them into absolute references. We don't need to anyway
- %% because that file must already have a named destination.
- dup /GoTo eq {
- pop
- dup /D knownoget {
- exch pop exch dup length dict copy dup /Dest 4 -1 roll put
- } if
- }{
- dup /GoToR eq {
- pop /A mark % <<..action dict..>> /A [
- 3 2 roll % /A [ <<..action dict..>>
- { oforce } forall
- .dicttomark
- 3 2 roll
- }{
- dup /Launch eq {
- pop /A mark % <<..action dict..>> /A [
- 3 2 roll % /A [ <<..action dict..>>
- { oforce } forall
- .dicttomark
- 3 2 roll
- }{
- /Named eq {
- /N knownoget {
- namedactions exch .knownget {
- exec {
- pop
- ( **** Warning: Ignoring a named action pointing out of the document page range.\n)
- pdfformatwarning
- } {
- /Page exch 3 -1 roll
- } ifelse
- } if
- } if
- } if
- }ifelse
- } ifelse
- } ifelse
- } if
- } ifelse
- } if
- { linkdest } stopped {
- cleartomark
- ( **** Warning: Link annotation points out of the document page range.\n)
- pdfformatwarning
- } {
- pop
- {
- %% Need to remove any '/.gs.pdfobj# key/value pairs from any dictionaries
- counttomark array astore dup length 1 sub 0 1 3 -1 roll {
- dup 2 index exch get Removepdfobj# 2 index 3 1 roll put
- } for aload pop
- /LNK pdfmark
- } stopped {cleartomark} if
- } ifelse
- }{pop} ifelse
- //false
-} bind executeonly def
-
-%% We don't handle movies correctly, so don't try to preserve them
-%/Movie {mark exch loadannot /ANN pdfmark //false} bind executeonly def
-/Popup {mark exch loadannot /ANN pdfmark //false} bind executeonly def
-/Sound {mark exch loadannot /ANN pdfmark //false} bind executeonly def
-/Square {mark exch loadannot /ANN pdfmark //false} bind executeonly def
-/Stamp {mark exch loadannot /ANN pdfmark //false} bind executeonly def
-
-/StrikeOut {
- mark exch
- dup /QuadPoints .knownget {
- 1 index /QuadPoints 3 -1 roll
- ApplyCTMToQuadPoints
- put
- } if
- loadannot /ANN pdfmark //false
-} bind executeonly def
-
-/Squiggly {
- mark exch
- dup /QuadPoints .knownget {
- 1 index /QuadPoints 3 -1 roll
- ApplyCTMToQuadPoints
- put
- } if
- loadannot /ANN pdfmark //false
-} bind executeonly def
-
-/Text {mark exch loadannot /ANN pdfmark //false} bind executeonly def
-/TrapNet {mark exch loadannot /ANN pdfmark //false} bind executeonly def
-
-/Underline {
- mark exch
- dup /QuadPoints .knownget {
- 1 index /QuadPoints 3 -1 roll
- ApplyCTMToQuadPoints
- put
- } if
- loadannot /ANN pdfmark //false
-} bind executeonly def
-
-%% Widget annotations are only used with AcroForms, and since we don't preserve AcroForms
-%% we don't want to preserve widget annotations either, because the consumer of the new
-%% PDF won't know what values they should take. So we draw widget annotations instead. If we
-%% ever preserve AcroForms then we should alter this to preserve Widgets as well.
-%% simply chane "drawannot" to "mark exch loadannot /ANN pdfmark"
-/Widget {mark exch {drawannot} PDFSTOPONERROR {exec}{stopped {(Error: Ignoring invalid annotation, output may be incorrect.\n) pdfformaterror} if} ifelse cleartomark //false} bind executeonly def
-
-currentdict end readonly def
-
-/preserveannot { % <annot> preserveannot -
- dup /.gs.pdfobj# known {
- dup /.gs.pdfobj# undef
- } if
-
- gsave
- dup dup /Subtype knownoget {
- dup //.PDFPreserveAnnotType? exec
- {
- //preserveannottypes exch .knownget { exec } { //true } ifelse
- {
- dup annotvisible {
- dup calc_annot_scale 2 copy mul 0 ne
- {
- 3 -1 roll drawwidget
- }
- {
- ( **** Error: ignoring annotation with scale factor of 0\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }ifelse % Draw rejected annots as widgets
- } {
- pop
- }ifelse
- } if
- }
- {
- % Not preserving this type of annotation
- % discard teh Subtype
- pop
- % copy the Annot dictionary and try drawing it instead
- dup drawannot
- } ifelse
- % type known
- } {
- pop
- ( **** Error: Ignoring /Annot dict without required /Subtype entry.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- grestore
-} bind executeonly def
-
-currentdict /preserveannottypes undef
-currentdict /.PDFDrawAnnotType? undef
-
-% ============================ AcroForm fields ============================ %
-
-% Get an attribure of the 0th annotation of a node
-/annot_oget { % <annot> /Name annot_oget <value>
- 1 index /Kids knownoget {
- 0 oget exch oget exch pop
- } {
- oget
- } ifelse
-} bind executeonly def
-
-% All procedures have the signature:
-% <acroform> <field> <annot|field> foo <acroform> <field> <annot|field>
-/draw_terminal_field_dict 4 dict begin
-
-/Btn {
- 1 index /Tf pget not { 0 } if
- dup 16#20000 and 0 ne {
- pop % Push button
- dup /AP known {
- 1 1 2 index drawwidget
- } {
- (Push button without appearance stream is not yet implemented) =
- } ifelse
- } {
- 16#10000 and 0 ne {
- % Radio button
- dup /AP known {
- 1 index /Kids oget {
- 1 1 3 -1 roll drawwidget
- } forall
- } {
- (Radio button without appearance stream is not yet implemented) =
- } ifelse
- } {
- % Checkbox
- dup /AP known {
- dup 1 1 3 -1 roll drawwidget
- } {
- (CkeckBox without appearance stream is not yet implemented) =
- } ifelse
- } ifelse
- } ifelse
-} bind executeonly def
-
-/Tx {
- dup /AP known {
- dup 1 1 3 -1 roll drawwidget
- } {
- %% If we don't have a NeedApperances, treat as true, because Acrobat
- %% always regenerates Appearances anyway.
- 2 index /NeedAppearances knownoget not { //true } if {
- dup /AP << /N 10 dict dup cvx begin >> put
- /Subtype /Form def
- /BBox [ 0 0 4 index /Rect oget { oforce } forall 3 -1 roll sub abs 3 1 roll sub abs exch ] def
- /Resources 3 index /DR pget not { 0 dict } if def
- /File 1000 string dup 3 1 roll def
- /Length 1000 def
- % <acroform> <field> <annot> (string)
- /NullEncode filter % <acroform> <field> <annot> file
-
- dup (BT ) writestring
- 2 index /DA pget not { () } if
- [ exch
- { token {
- dup /Tf eq {
- 2 index 0 eq {
- /BBox load 3 get
- 0.75 mul % empirical constant
- 4 -1 roll pop 3 1 roll
- } if
- } if
- exch
- } {
- exit
- } ifelse
- } loop
- ]
- { 1 index exch write== } forall
- dup 3 index /MaxLen pget not { 0 } if write=
- dup 3 index /V pget not {
- 3 index /DV pget not { () } if
- } if write==
- dup 3 index /Ff pget not { 0 } if write=
- dup 3 index /Q pget not { 0 } if write=
- dup (Tform ET) write=
- end
- closefile % <acroform> <field> <annot>
- dup 1 1 3 -1 roll drawwidget
- } if
- } ifelse
-} bind executeonly def
-
-/Ch {
- dup /AP known 3 index /NeedAppearances knownoget not { //true } if not and {
- dup 1 1 3 -1 roll drawwidget
- } {
- %% If we don't have a NeedApperances, treat as true, because Acrobat
- %% always regenerates Appearances anyway.
- 2 index /NeedAppearances knownoget not { //true } if {
- dup /AP << /N 10 dict dup cvx begin >> put
- /Subtype /Form def
- /BBox [ 0 0 4 index /Rect oget { oforce } forall 3 -1 roll sub abs 3 1 roll sub abs exch ] def
- /Resources 3 index /DR pget not { 0 dict } if def
- /File 1000 string dup 3 1 roll def
- /Length 1000 def
- % <acroform> <field> <annot> (string)
- /NullEncode filter % <acroform> <field> <annot> file
-
- dup (BT ) writestring
- 2 index /DA pget not { () } if
- [ exch
- { token {
- dup /Tf eq {
- 2 index 0 eq {
- /BBox load 3 get
- 0.75 mul % empirical constant
- 4 -1 roll pop 3 1 roll
- } if
- } if
- exch
- } {
- exit
- } ifelse
- } loop
- ]
- { 1 index exch write== } forall
- dup 3 index /MaxLen pget not { 0 } if write=
- dup 3 index /V pget not {
- 3 index /DV pget not { () } if
- } if write==
- dup 3 index /Ff pget not { 0 } if write=
- dup 3 index /Q pget not { 0 } if write=
- dup (Tform ET) write=
- end
- closefile % <acroform> <field> <annot>
- dup 1 1 3 -1 roll drawwidget
- } if
- } ifelse
-} bind executeonly def
-
-/Sig {
- (Sig is not yet implemened ) //== exec
-} bind executeonly def
-
-currentdict end def
-
-/draw_terminal_field { % <field> draw_terminal_field -
- dup /Kids knownoget { 0 oget } { dup } ifelse
- dup /P knownoget {
- /Page load eq {
- //draw_terminal_field_dict 2 index /FT pget not { 0 } if .knownget {
- exec
- } if
- } if
- } if
- pop pop
-} bind executeonly def
-
-% We distinguish 4 types of nodes on the form field tree:
-% - non-terminal field - has a kid that refers to the parent (or anywhere else)
-% - terminal field with separate widget annotations - has a kid that doesn't have a parent
-% - terminal field with a merged widget annotation - has no kids
-% - widget annotation - has /Subtype and /Rect
-%
-% The recursive enumeration of the form fields doesn't descend into widget annotations.
-
-/draw_form_field { % <field> draw_form_field -
- dup type /dicttyype eq { % File for Bug692447 has 'null' Fields entries
- % This matches what pdf_main process_trailer_attrs
- dup /Kids knownoget { % field []
- dup length 0 gt {
- dup 0 oget /Parent knownoget { % field [] kid
- pop % mon-terminal field % field []
- exch pop % []
- { oforce draw_form_field } forall
- } {
- pop draw_terminal_field % separate annots % -
- } ifelse
- } {
- ( **** Error: Ignoring empty /Kids array in Form field.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- } {
- draw_terminal_field % merged annotation % -
- } ifelse
- } if
-} bind executeonly def
-
-/draw_acro_form { % <form> draw_acro_form -
- dup /Fields knownoget {
- { oforce draw_form_field } forall
- } if
- pop
-} bind executeonly def
-
-currentdict /draw_terminal_field_dict undef
-
-end % pdfdict
-end % GS_PDF_ProcSet
-.setglobal
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_font.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_font.ps
deleted file mode 100644
index 1be2871b105..00000000000
--- a/Master/tlpkg/tlgs/Resource/Init/pdf_font.ps
+++ /dev/null
@@ -1,2809 +0,0 @@
-% Copyright (C) 2001-2022 Artifex Software, Inc.
-% 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.
-%
-% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
-%
-
-% PDF font operations.
-
-% Since PDF font are not unique and can collide with external font resources
-% or each other, use font dictionaries obtained from PDF directly, never
-% register them as resources or look them up by name. Use findfont oparator
-% for non-embedded fonts only. CIDFont resources still use the old logic
-% described below.
-
-% Finding a font by name can't give a proper result when PDF font names aren't unique.
-% But it is only the way to obtain a font in Postscript after a font file is executed.
-% Therefore using a FontName (and findfont) is allowed only
-% immediately after a font file is executed.
-% In all other cases the font to be found by a pointer through PDF structures.
-%
-% This ideal logics can't work for documents,
-% which define a font resource with an embedded font,
-% and another font resource with same BaseFont but with no embedded font
-% (and possibly with no font descriptor).
-% Our testbase does contain such examples.
-% In this case we do find font by FontName (with findfont),
-% since there is no other way to get a reasonable result.
-
-/.setlanguagelevel where { pop 2 .setlanguagelevel } if
-.currentglobal //true .setglobal
-/GS_PDF_ProcSet load begin % from userdict at this point
-pdfdict begin
-
-% We cache the PostScript font in an additional element of the
-% font resource dictionary, called PSFont.
-
-% ---------------- Encodings ---------------- %
-
-/.notdefEncoding 256 { /.notdef } repeat 256 packedarray def
-
-% Apply a list of differences to an Encoding.
-% Note that the differences may cause the array to grow.
-/updateencoding { % <encoding|null> <differences> updateencoding <enc'>
- % Calculate the length of the result.
- % in case the incoming Encoding is null, use .notdefEncoding
- exch dup //null eq { pop .notdefEncoding } if
- 0 0 3 index {
- dup type /nametype ne { exch pop oforce } { pop 1 add } ifelse
- % Differences list may not be in order, update the largest_index
- % stack: <Differences> <encoding> <largest_index> <at_index>
- 2 copy lt { exch pop dup } if % at_index is new largest
- } forall
- pop 1 index length .max array dup 0 4 -1 roll putinterval
- exch 0 exch {
- % Stack: enc' code element
- dup type /nametype ne
- { exch pop oforce }
- { 3 copy put pop 1 add }
- ifelse
- } forall pop
-} bind executeonly def
-
-/good_encoding_names <<
- /MacRomanEncoding 0 /MacExpertEncoding 0 /WinAnsiEncoding 0
->> readonly def
-
-/known_symbolic_fonts <<
- /Wingdings2 0
- /ZapfDingbats 0
->> readonly def
-
-% Get the Encoding for a font.
-/getencoding % <base-encoding> <font-resource> getencoding <enc>
- { dup /Encoding knownoget
- { dup type /nametype eq
- {
- % The published PDF specification says the Encoding name
- % "must be" one of the 3 predefined Encodings, implying
- % that an error should occur if it isn't. However, Acrobat
- % Reader simply ignores unknown names, and since there are
- % some buggy applications that rely on this, we do the same.
-
- //good_encoding_names 1 index known {
- exch /BaseFont knownoget not { 0 } if
- % Ignore named encodings for known symbolic fonts. See bug 690135.
- //known_symbolic_fonts exch known {
- pop
- } {
- exch pop findencoding
- } ifelse
- } {
- pop pop
- } ifelse
- }
- { exch pop
- dup type /arraytype eq
- { exch pop
- ( **** Warning: Encoding is an array, not name or dictionary.\n) pdfformatwarning
- }
- { dup /BaseEncoding knownoget
- {
- %% Originally we ignored the specific invalid name '/' here from Bug #687786, however
- %% Bug #696942 contains an invalid BaseEncoding '/utf-8', so now we check all BaseEncoding
- %% against the permitted names, just as we do for Encodings.
- //good_encoding_names 1 index known{
- findencoding 3 -1 roll pop exch
- }{
- ( **** Error: Invalid BaseEncoding name ") print 256 string cvs print (" ignoring BaseEncoding.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }ifelse
- } if
- /Differences knownoget { updateencoding } if
- }
- ifelse
- }
- ifelse
- } {
- pop
- ( **** Error: Encoding not present.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }
- ifelse
- } bind executeonly def
-
-currentdict /good_encoding_names undef
-currentdict /known_symbolic_fonts undef
-
-/checkGlyphNames2Unicode % <dict> checkGlyphNames2Unicode -
-{
- PDFDEBUG {
- dup /FontInfo .knownget {
- /GlyphNames2Unicode .knownget {
- (Has GlyphNames2Unicode) =
- pop % { exch //== exec //== exec} forall
- } if
- } if
- } if
- pop
-} bind executeonly def
-
-% Define a font using it's FontName as the key.
-% Adjust a font according to the Encoding and Widths in the font resource.
-/adjustfont { % <font-resource> <font> adjustfont <font'>
- getfontencoding
- 3 copy .processToUnicode
- getfontmetrics 5 -1 roll pop .updatefont {
- %% Bug #696306 has a broken type 1 font where the eexec encrypted portion simply ends
- %% leaving a partial glyph description and, more importantly, the Private dictionary
- %% on the operand stack. Ths means the font dictonary does not contain a Private
- %% dictionary which causes .buildfont1 to throw an error. .completefont calls .buildfont1
- %% (which is obscured by a definition in gs_type1.ps) so we need to check the reault
- %% of .completefont. If it fails we must discard the font dictionary and use a fallback.
- {.completefont} stopped {
- (\n *** ERROR: The font ) print /FontName get 256 string cvs print ( is damaged and cannot be used. Switching to a\n) pdfformaterror
- ( last-ditch fallback, text may not render correctly, or at all.\n\n) pdfformaterror
- /Helvetica findfont
- }if
- } if
-} bind executeonly def
-
-% Get the (possibly modified) encoding of a font.
-/getfontencoding { % <font-resource> <font> getfontencoding
- % <font-resource> <font> <Encoding|null>
- % Ignore encoding when TrueType is requested
- % and loaded from an embedded stream.
- % All other cases are left unchanged.
- dup /FontType get 42 eq 1 index /PathLoad known not and
- 2 index /Subtype get /TrueType eq and {
- //null
- } {
- % Acrobat appears to be always using StandardEcoding as the
- % default encoding for some non-symbolic fonts (rather than,
- % as the spec states, the encoding specified by the font).
- % As this is contrary to spec, and we only have a CFF
- % example, I've restricted this to fonts with Subtype Type1C
- % *and* that result in a Type 2 PS font.
- 1 index /FontDescriptor knownoget
- {
- dup
- % Unfortunately, Acrobat doesn't enforce the meaning of
- % FontFile[23] so whilst, in theory, Type1C should only
- % occur in FontFile3, we can't rely on that.
- dup /FontFile knownoget not
- {
- dup /FontFile2 knownoget not
- {
- dup /FontFile3 knownoget not {1 dict} if
- } if
- } if
- exch pop /Subtype knownoget {/Type1C eq}{//false} ifelse
- exch /Flags knownoget {4 and 4 eq not}{//false}ifelse and
- } {//false} ifelse
-
- 1 index /FontType get 2 eq and
- {
- 2 index /Encoding knownoget {pop StandardEncoding 2 index getencoding} { //null } ifelse
- }
- {
- 2 index /Encoding known {
- dup /Encoding knownoget { 2 index getencoding } { //null } ifelse
- } {
- //null
- } ifelse
- } ifelse
- } ifelse
-} bind executeonly def
-
-% Returns true if the current glyph is in the Differences array at
-% the specified index value. This is needed because the Widths
-% array may map to the same glyph at different positions from the
-% Encoding. We want to use the Width that was associated with the
-% one specified in the Encoding::Differences list.
-/match_in_diff % <Differences> <index> <glyphname> match_in_diff <bool>
-{ //false 4 1 roll 0 4 -1 roll % stack: false index glyphname at_index==0 Differences
- { exch 1 index type /nametype ne {
- % stack: false index glyphname Diff_element at_index
- pop % Diff_element is new at_index
- } {
- % stack: false index glyphname Diff_element at_index
- exch 2 index eq {
- % stack: false index glyphname at_index
- dup 3 index eq {
- //true 5 1 roll % stack: true false index glyphname at_index
- pop exit
- } if
- } if
- 1 add % at_index++ stack: false index glyphname at_index'
- } ifelse
- } forall
- % stack: true false index glyphname
- % or : false index glyphname at_index
- pop pop pop
-} bind executeonly def
-
-/unique_name { % <dict> </root> unique_name </unique>
- %
- % Note : this function interacts with pdf_write_encoding in src/gdevpdtw.c
- % and with copied_drop_extension_glyphs in src\gxfcopy.c
- % by adding a reserved substring (~GS~).
- %
- .namestring % <<>> (root)
- 0 1 65535 {
- 5 string cvs % <<>> (root) (0)
- (~GS~) exch concatstrings
- 1 index exch % <<>> (root) (root) (~GS~0)
- concatstrings % <<>> (root) (root~GS~0)
- dup % <<>> (root) (root~GS~0) (root~GS~0)
- 3 index exch % <<>> (root) (root~GS~0) <<>> (root~GS~0)
- known not {
- exch pop exit % <<>> (root~GS~0)
- } if
- pop
- } for
- exch pop cvn % /root0
-} bind executeonly def
-
-% Get the metrics of a font, if specified.
-/getfontmetrics { % <font-resource> <font> <Encoding|null> getfontmetrics
- % <font-resource> <font> <Encoding|null>
- % <Metrics|null> <GlyphMap|null>
- 2 index /Widths oknown {
- dup //null eq { pop dup /Encoding get } if
- 7 dict begin
- dup length dict
- /Metrics exch def
- /Encoding exch def
- /GlyphMap //null def
- exch
- dup /Widths oget /Widths exch def
- % Stack: font font-res
- % Note that widths are always based on a 1000-unit
- % character space, but the FontMatrix may specify
- % some other scale factor. Compensate for this here,
- % by scaling the Widths if necessary.
- 0.001 2 index /FontMatrix get 0 get
- dup 0 eq {
- % FontMatrix.xx == 0, so we cannot scale down by xx.
- % - FontMatrix[0] == 0 implies either FontMatrix[1] <> 0 or
- % FontMatrix cannot be inverted. In the 1st case we have
- % FontMatrixNonHV == true and will render text with cshow + xshow.
- % In the 2nd case, metrics in the PDF Font object cannot be enforced
- % [by altering metrics in PS glyph space].
- % HACK:
- % - we scale down by FontMatrix[1];
- % - given the format of Metrics entries we use, wy = 0 in glyph space;
- % - as a result, the cshow procedure receives as wy the value we
- % need for wx (all of this in PS user space).
- pop
- 2 index /FontMatrix get 1 get
- dup 0 eq { pop 1 } if % sorry, no way to enforce PDF metrics by altering the font
- } if
- div
- % Stack: font font-res mscale
- /FirstChar 2 index /FirstChar knownoget not {
- ( **** Warning: /FirstChar attribute is missing, assuming 0.\n) pdfformatwarning
- 0
- } if def
- /LastChar 2 index /LastChar knownoget not {
- ( **** Warning: /LastChar attribute is missing, assuming 255.\n) pdfformatwarning
- 255
- } if def
-
- Encoding length LastChar le {
- ( **** Warning: Font Encoding array size is smaller than character range.\n)
- pdfformatwarning
- } if
-
- 1 index /FontDescriptor knownoget {
- /MissingWidth knownoget not { 0 } if
- }
- { 1000
- }
- ifelse /MissingWidth exch def
-
- Widths length LastChar FirstChar sub le {
- ( **** Warning: Font Widths array size is smaller than character range.\n)
- pdfformatwarning
- /Widths [Widths aload length LastChar FirstChar sub exch sub MissingWidth exch {dup} repeat] def
- } if
- FirstChar
-
- 0 Encoding
- { % Stack: font font-res mscale first-char index charname
-
- 1 index FirstChar lt { MissingWidth } {
- 1 index LastChar gt { MissingWidth } { Widths 2 index FirstChar sub get } ifelse
- } ifelse
- oforce
-
- % Stack: font font-res mscale first-char index charname width
- 4 index mul
- % The following 'loop' is only context for 'exit'.
- {
- % Work around a bug in pdfTeX, which can generate Encoding
- % vectors containing nulls :
- 1 index //null eq { exit } if
- Metrics 2 index .knownget {
- 1 index ne
- } {
- //false
- } ifelse {
- % Two or more Encoding elements refer same glyph name,
- % and Widths specify different wihts for it.
- % Since a Postscript font can't have different
- % Metrics for same glyph name,
- % we generate an unique name, and create a new
- % Charstrings entry with same glyph value.
- GlyphMap //null eq {
- /Encoding Encoding dup length array copy def
- /GlyphMap 4 dict def
- } if
- % To prevent too many new names, check whether
- % we can use one already created for same glyph.
- //true
- GlyphMap { % f r s c i n w b n1 n2
- 4 index eq { % f r s c i n w b n1
- dup Metrics exch get % f r s c i n w b n1 w1
- 3 index eq { % f r s c i n w b n1
- 4 3 roll pop % f r s c i w b n1
- 3 1 roll pop % f r s c i n1 w
- Encoding 3 index 3 index put
- //false % f r s c i n1 w b
- exit
- } {
- pop
- } ifelse
- } { % f r s c i n w b n1
- pop
- } ifelse
- } forall % f r s c i n w b
- { % Do create a new name.
- Metrics 2 index //unique_name exec % f r s c i n w nn
- Encoding 4 index 2 index put
- GlyphMap 1 index 5 -1 roll put % f r s c i w nn
- exch
- % Stack: font font-res mscale first-char index new_name width
- } if
- } if
- 2 copy Metrics 3 1 roll put
- exit
- } loop
- pop pop
- 1 add
- }
- forall pop pop pop
- exch Encoding Metrics GlyphMap end
- } {
- //null //null
- } ifelse
-} bind executeonly def
-
-currentdict /unique_name undef
-currentdict /match_in_diff undef
-
-/ToUnicodeCMapReader 4 dict begin
- /defineresource % <name> <dict> <cat-name> defineresource <dict>
- {
- pop
- dup userdict exch /.lastToUnicode exch put
- exch pop
- } bind executeonly def
-
- /CIDSystemInfo
- {
- ( **** Warning: ToUnicode CMap has invalid syntax near CIDSystemInfo.\n) pdfformatwarning
- /CIDSystemInfo
- } bind executeonly def % A work around a bug in Altona.Page_3.2002-09-27.pdf - a slash is missed.
-
- /CMapName
- {
- ( **** Warning: ToUnicode CMap has no CMapName.\n\
- See the comment to revision 6201 in gs/doc/ps2pdf.htm#Problems .\n) pdfformatwarning
- /CMap1 % arbitrary, PDF defineresource tolerates non-unique names
- } bind executeonly def % A work around incorrect ToUnicode CMap generated by GS before rev. 6201.
-
- % Split large ranges into smaller chunks to stay withing the limits
- % of various PS% objects and speed up operand stack manipulation,
- % esp. "counttomatk -3 roll". Bug 691908.
- /beginbfrange {
- { pop
- mark
- 256 {
- currentfile token not { /endbfrange exit } if
- dup /endbfrange eq { exit } if
- currentfile token not { pop /endbfrange } if
- currentfile token not { pop pop /endbfrange } if
- dup ([) eq {
- pop [
- { currentfile token not { exit } if
- dup (]) eq { pop exit } if
- } loop ]
- } if
- } repeat
- dup /endbfrange eq {
- pop endbfrange exit
- } {
- endbfrange
- mark
- } ifelse
- } loop
- } bind executeonly def
-currentdict end readonly def
-
-/string2number % <string> string2number <number>
-{ 0 exch dup 0 exch 1 exch length 1 sub { % n () i
- 1 index exch get % n () v
- 3 2 roll 256 mul add exch % v+n*256 ()
- } for
- pop % N
-} bind executeonly def
-
-/copy&def % <key> <value> <bool> copy&def -
-{
- { //true
- } {
- currentdict gcheck {
- dup gcheck not
- } {
- //false
- } ifelse
- } ifelse
- { currentglobal currentdict gcheck setglobal
- exch dup length string copy exch
- setglobal
- } if
- def
-} bind executeonly def
-
-/.convert_ToUnicode-into-g2u % <GlyphNames2Unicode> <Encoding|null> <CMap> .convert_ToUnicode-into-g2u -
-{
- CMAPDEBUG {
- (.convert_ToUnicode-into-g2u beg) =
- } if
- 3 2 roll begin
- /.CodeMapData get % About the data format see gs_cmap.ps, the comment after "CMap operators".
- 1 get % code maps
- {
- CMAPDEBUG {
- dup //== exec
- } if
- dup length 1 sub 0 exch 5 exch { % e [] i
- 2 copy get % e [] i (prefix)
- string2number % e [] i prefix
- 2 index 2 index 1 add get % e [] i prefix (key_size,?is_range,value_type,value_size)
- dup 0 get 8 mul % e [] i prefix (key_size,?is_range,value_type,value_size) key_size*8
- 3 2 roll exch bitshift exch % e [] i prefix<<key_size*8 (key_size,?is_range,value_type,value_size)
- dup 0 get exch 3 get % e [] i offset key_size value_size
- 4 index 4 index 2 add get % e [] i offset key_size value_size (keys)
- 5 index 5 index 3 add get % e [] i offset key_size value_size (keys) (values)
- CMAPDEBUG {
- ( offset=) print 4 index =string cvs print
- ( key_size=) print 3 index =string cvs print
- ( value_size=) print 2 index =
- ( keys=) print 1 index //== exec
- ( values=) print dup //== exec
- } if
- 1 index length 0 eq {
- % A single pair.
- exch pop exch pop exch pop exch % e [] i (values) offset
- 4 index //null ne {
- 4 index length 1 index gt {
- 4 index exch get
- } if
- } if % e [] i (values) cid|name
- exch
- CMAPDEBUG {
- ( defined single: ) print 1 index =string cvs print ( ) print dup //== exec
- } if
- //false copy&def % e [] i
- pop % e []
- } {
- % A range. % e [] i offset key_size value_size (keys) (values)
- dup length string copy % protect the original string from modifications below.
- 0 4 index 2 mul 3 index length 1 sub { % e [] i offset key_size value_size (keys) (values) j
- 2 index 1 index 6 index getinterval
- string2number % e [] i offset key_size value_size (keys) (values) j keyL
- CMAPDEBUG {
- ( keyL=) print dup =string cvs print
- } if
- 3 index 2 index 7 index add 7 index getinterval
- string2number % e [] i offset key_size value_size (keys) (values) j keyL keyH
- CMAPDEBUG {
- ( keyH=) print dup =
- } if
- 3 2 roll 6 index idiv 5 index mul % e [] i offset key_size value_size (keys) (values) keyL keyH J
- 3 index exch 6 index getinterval % e [] i offset key_size value_size (keys) (values) keyL keyH (valueL)
- 3 1 roll 1 exch { % e [] i offset key_size value_size (keys) (values) (value) k
- 9 index //null ne {
- 9 index exch get % e [] i offset key_size value_size (keys) (values) (value) name
- } if % e [] i offset key_size value_size (keys) (values) (value) cid|name
- 1 index % e [] i offset key_size value_size (keys) (values) (value) cid|name (value)
- CMAPDEBUG {
- ( defined from range: ) print 1 index =string cvs print ( ) print dup //== exec
- } if
- //true copy&def % e [] i offset key_size value_size (keys) (values) (value)
-
- %% Calculate the value from the last string
- dup dup length 1 sub 0 exch 0 1 3 -1 roll
- {
- % (string) value index
- exch 256 mul exch
- 2 index exch get add
- } for
-
- %% and increment the value for the next string
- 1 add
-
- %% Now convert the value into a string of bytes.
- 1 index length 1 sub 1 exch 0 1 3 -1 roll
- {
- % (string) value divisor index
- 2 index 2 index idiv 255 and % (string) value divisor index byte
- exch 4 index length 1 sub exch sub % (string) value divisor byte string_position
- 5 index % (string) value divisor byte string_position (string)
- exch 3 -1 roll put % (string) value divisor
- 256 mul
- } for
- pop pop pop
- } for % e [] i offset key_size value_size (keys) (values) (value)
- } for
- pop pop pop pop pop pop pop % e []
- } ifelse
- } for
- pop % e
- } forall
- end
- pop %
- CMAPDEBUG {
- (.convert_ToUnicode-into-g2u end) =
- } if
-} bind executeonly def
-
-/.DoToUnicode?
-{
- /IgnoreToUnicode where
- {/IgnoreToUnicode get not}
- {//true} ifelse
-} bind executeonly def
-
-/.processToUnicode % <font-resource> <font-dict> <encoding|null> .processToUnicode -
-{
- //.DoToUnicode? exec
- {
- currentdict count 1 sub /.stackdepth exch .forceput
- currentdict countdictstack /.dstackdepth exch .forceput
- {
- 1 index /FontType get 0 eq
- {
- 1 index /FDepVector get 0 get
- dup /FontType .knownget not
- {
- dup /CIDFontType .knownget
- { dup 2 eq {pop 11} if }
- {-1} % just some value that's not a valid font type
- ifelse
- }if
- 11 eq
- { /Path known}
- {pop //false}
- ifelse
- }
- {//false} ifelse
- % Currently pdfwrite is only device which can handle GlyphNames2Unicoide to
- % generate a ToUnicode CMaps. So don't bother with other devices.
- /WantsToUnicode /GetDeviceParam .special_op {
- exch pop
- }{
- //false
- }ifelse
- or
- {
- PDFDEBUG {
- (.processToUnicode beg) =
- } if
-
- 2 index /ToUnicode knownoget
- {
- dup type /nametype eq {
- % This is contrary to the specification but it seems that Acrobat at least will accept
- % a ToUnicode with a value of Identity-H *and* will use that for search, copy/paste.
- % We can't pass through a name, so the best we can do is build a GlyphNames2Unicode
- % map matching that which would have been generated by a full 16-bit Identity CMap
- %
- % See bug numbers 701003 and 687351
- %
- dup /Identity-H eq 1 index /Identity-V eq or{
- pop
- 1 index /FontInfo .knownget not {
- currentglobal 2 index dup gcheck setglobal
- /FontInfo 5 dict dup 5 1 roll .forceput
- setglobal
- } executeonly if
- dup /GlyphNames2Unicode .knownget not {
- //true % No existing G2U, make one
- } {
- dup wcheck {
- //false % Existing, writeable G2U, don't make new one
- } {
- pop //true % Existing read only G2U, make new one
- } ifelse
- } ifelse
- {
- currentglobal exch dup gcheck setglobal
- dup /GlyphNames2Unicode 100 dict dup 4 1 roll .forceput
- 3 2 roll setglobal
- } if % font-res font-dict encoding|null font-info g2u
-
- 0 1 65535{
- % g2u index
- dup dup 256 mod exch 256 idiv % g2u index lo-byte hi-byte
- 2 string dup 0 4 -1 roll % g2u index lo-byte () () 0 hi-byte
- put % g2u index lo-byte (x)
- dup 1 % g2u index lo-byte (x) (x) 1
- 4 -1 roll put % g2u index (x) (x) 1 lo-byte -> dict index (xx)
- 2 index % g2u index (xx) dict
- 3 1 roll % g2u g2u index (xx)
- put % g2u
- } for
- pop % font-res font-dict encoding|null font-info
- pop % font-res font-dict encoding|null
- //false % We built a GlyphNames2Unicode table, don't need to process further
- } executeonly
- {
- //true % name is not Identity-V or H, fail by falling through
- }ifelse
- } executeonly
- {
- //true
- } ifelse % not a name, try as a dictionary (as specified)
-
- % If the ToUnicode isn't a name, or the name isn't Identity-V or -H then follow the specification
- % If its not a dictionary type throw an error, otherwise decode it and build a GlyphNames2Unicode
- %
- {
- dup type /dicttype eq { dup /File known not } { //true } ifelse {
- % We undefine wrong /Length and define /File in stream dictionaries.
- % Bug687351.pdf defines /ToUnicode /Identity-H, what is incorrect.
- ( **** Warning: Ignoring bad ToUnicode CMap.\n) pdfformatwarning
- pop
- } {
- /PDFScanRules .getuserparam dup //null eq {
- pop //PDFScanRules_null
- } {
- 1 dict dup /PDFScanRules 4 -1 roll put
- } ifelse
- //PDFScanRules_true setuserparams
- PDFfile fileposition
- 3 -1 roll
- count 1 sub
- countdictstack
- { //false resolvestream
- % Following Acrobat we ignore everything outside
- % begincodespacerange .. endcmap.
- dup 0 (begincodespacerange) /SubFileDecode filter flushfile
- /CIDInit /ProcSet findresource begin
- //ToUnicodeCMapReader begin
- 12 dict begin
- /CMapType 2 def
- mark exch % emulate 'begincodespacerange'
- 0 (endcmap) /SubFileDecode filter cvx /begincmap cvx exch 2 .execn
- endcmap
- userdict /.lastToUnicode currentdict put
- end end end
- }
-
- PDFSTOPONERROR {
- { exec } 0 get
- //false
- 5 -2 roll
- 5
- } {
- { stopped } 0 get
- 4 2 roll
- 4
- } ifelse
- array astore cvx exec
-
- countdictstack exch sub 0 .max { end } repeat
- count exch sub 2 sub 0 .max { exch pop } repeat
- 3 1 roll % Stach the stop flag.
- PDFfile exch setfileposition
- setuserparams
- {
- ( **** Warning: Failed to read ToUnicode CMap.\n) pdfformatwarning
- } {
- 1 index /FontInfo .knownget not {
- currentglobal 2 index dup gcheck setglobal
- /FontInfo 5 dict dup 5 1 roll .forceput
- setglobal
- } if
- dup /GlyphNames2Unicode .knownget not {
- //true % No existing G2U, make one
- } {
- dup wcheck {
- //false % Existing, writeable G2U, don't make new one
- } {
- pop //true % Existing read only G2U, make new one
- } ifelse
- } ifelse
- {
- currentglobal exch dup gcheck setglobal
- dup /GlyphNames2Unicode 100 dict dup 4 1 roll .forceput
- 3 2 roll setglobal
- } if % font-res font-dict encoding|null font-info g2u
- exch pop exch % font-res font-dict g2u encoding|null
- userdict /.lastToUnicode get % font-res font-dict g2u Encoding|null CMap
- .convert_ToUnicode-into-g2u % font-res font-dict
- //null % font-res font-dict //null
- } ifelse
- } ifelse
- } if
- PDFDEBUG {
- (.processToUnicode end) =
- } if
- } executeonly if
- } executeonly if
- } executeonly stopped
- {
- .dstackdepth 1 countdictstack 1 sub
- {pop end} for
- .stackdepth 1 count 3 sub
- {pop pop} for
- } if
- pop pop pop
- currentdict /.stackdepth .forceundef
- currentdict /.dstackdepth .forceundef
- } executeonly
- {pop pop pop}
- ifelse
-
-} bind executeonly odef
-
-currentdict /.DoToUnicode? .forceundef
-
-% ---------------- Descriptors ---------------- %
-
-% Partial descriptors for the 14 built-in fonts. Note that
-% from PDF 1.1 to PDF 1.2, the meaning of the Flag 6 in the FontDescriptor
-% object has undergone a subtle change in its meaning which has serious
-% consequences for searching with Acrobat:
-% In PDF 1.1, the flag meant: Font has StandardEncoding
-% In PDF 1.2, the flag means: Font has (subset of) StandardRomanCharacterSet
-/standardfontdescriptors mark
- /Courier mark /Flags 16#23 .dicttomark
- /Courier-Oblique 1 index
- /Courier-Bold 1 index
- /Courier-BoldOblique 1 index
- /Helvetica mark /Flags 16#20 .dicttomark
- /Helvetica-Oblique 1 index
- /Helvetica-Bold 1 index
- /Helvetica-BoldOblique 1 index
- /Times-Roman mark /Flags 16#22 .dicttomark
- /Times-Bold 1 index
- /Times-Italic mark /Flags 16#62 .dicttomark
- /Times-BoldItalic 1 index
- /Symbol mark /Flags 16#4 .dicttomark
- /ZapfDingbats 1 index
-.dicttomark readonly def
-
-% ---------------- Utilities ---------------- %
-
-/.pdforigfontcache_g 20 dict def
-currentglobal //false setglobal
-systemdict /.pdforigfontcache_l 20 dict .forceput
-setglobal
-
-% Find an original font, using cache to prevent adjustfont to accumulate changes.
-/pdffindcachedfont { % <font_name> pdffindcachedfont <font>
- dup //.pdforigfontcache_g exch .knownget {
- exch pop
- } {
- dup .pdforigfontcache_l exch .knownget {
- exch pop
- } {
- dup findfont dup
- dup gcheck { //.pdforigfontcache_g } { .pdforigfontcache_l } ifelse
- % Stack : font_name font font cache
- 4 2 roll .growput
- } ifelse
- } ifelse
-} bind executeonly def
-
-% Add original font to cache to prevent adjustfont to accumulate changes.
-/pdfaddcachedfont { % <font_name> pdfaddcachedfont <font>
- dup findfont dup % name font font
- dup gcheck { //.pdforigfontcache_g } {.pdforigfontcache_l} ifelse
- 4 2 roll % font d name font
- put % font
-} bind executeonly def
-
-/.remove_font_name_prefix { % <name> .remove_font_name_prefix <name>
- dup .namestring (+) search {
- //true exch
- { dup 65 lt exch 90 gt or {
- pop //false exit
- } if
- } forall
- { pop exch pop cvn
- } {
- pop pop
- } ifelse
- } {
- pop
- } ifelse
-} bind executeonly def
-
-% Find a font (except for embedded ones), and adjust its encoding if necessary.
-/.pdfdfndict mark
- /defaultfontname /Helvetica
-.dicttomark readonly def
-
-% This code attempts to use the FontName and FontDescriptor to find a
-% 'better' match for a missing font than the default font. There
-% are a list of fonts and mappings here (TTfonts) and in gs_font.ps
-% (.substitutefaces) which we can use to map from a requested font
-% family name to a substitute family. If that fails we check the
-% FontDescriptor Flags to attempt a (very slightly) better match.
-% We use Times-Roman for serif fonts and Helvetica for non-serif.
-% This all seems pretty poor to me, but its long-standing, so we
-% won't attempt to meddle with it.
-/pdfsubstitutefont {
- % Stack: font-res fontname fontdesc
-
- dup /Flags oget
- dup 16#40 and -6 bitshift % 1, oblique/italic
- 1 index 16#40000 and -17 bitshift add % 2, bold
- exch 16#2 and 2 bitshift add % 8, serif
-
- % We should look at the fixed flag, too.
- % Stack: font-res fontname fontdesc properties
-
- % Even though /FontName is a required key in FontDescriptor dict
- % (As of the PDF 1.4 Reference Manual), In the case of missing
- % /FontName key, we substitue /BaseFont for the value of /FontName.
- % Yet another case of broken PDF's that Adobe Reader accepts.
- 1 index dup /FontName known
- {
- /FontName oget
- dup type /nametype ne
- {
- ( **** Error: /FontName in FontDescriptor is not a name.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- cvn
- } if
- }
- {
- ( **** Error: FontDescriptor missing required /FontName key. BaseFont name used.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop 2 index % grab the BaseFont from the stack.
- } ifelse
- .remove_font_name_prefix
- exch
-
- % Analyzes font name and extract "Bold" and "Narrow" properties
- % which are not described by the FontDescriptor Flags.
- % We also allow the font name analysis to override the Flags setting
- % for Italic/Oblique as this gives us results more consistent with
- % Acrobat.
- 0 2 index //.fontnameproperties exec 7 and or
-
- % Rebind the default font name to Helvetica so that
- % fonts with no properties are handled correctly.
- //.pdfdfndict begin .substitutefontname end
-
- % Stack: font-res fontname fontdesc substname|null
- Fontmap 1 index known
- {//false}
- { .buildnativefontmap pop NativeFontmap 1 index known not}
- ifelse
-
- {
- % No available good substitution, use the standard one.
- pop 1 index .substitutefont
- } if
-
- dup 3 index ne
- {
- QUIET not
- {
- (Substituting font ) print dup =only
- ( for ) print 2 index =only (.) = flush
- } if
- % Send a warning to the device, in case its pdfwrite and we are in PDF/A mode
- % In that case the substituted font may not (probably doesn't) have glyphs which
- % match the /Widths of the original font, and that will cause a fault with PDF/A
- % so we need to let the device know.
- /SubstitutedFont /EventInfo .special_op
- } if
-
- pdffindcachedfont
- % Stack: font-res fontname fontdesc font
-
- % Some non-compliant files are missing FirstChar/LastChar,
- % despite referencing a non-base14 font
- 3 index /FirstChar knownoget
- {
- 0 % push an initial value for accumating the Widths
- 0 string % and an empty string to interrogate the font
- 7 index /Widths knownoget
- {
- 0 1 2 index length 1 sub
- {
- dup 2 index exch get
- dup type /packedarraytype eq {exec} if % Handle entries which are indirect references (seriously ? !!)
- dup 0 gt % We ignore entries of zero in the widths array
- {
- exch 5 index add % add FirstChar to the idx to get a char code
- dup 64 gt 1 index 91 lt and % we only want to consider A~Z and....
- 1 index 96 gt 2 index 123 lt and or % ... a~z
- {
- exch
- 5 -1 roll add 4 1 roll % add the width to the accumulator on the stack
- 1 string dup 0 4 -1 roll put
- 3 -1 roll concatstrings exch % add the char code to the string
- }
- {
- pop pop
- } ifelse
- }
- {
- pop pop
- } ifelse
- } for
- pop % get rid of the Widths array
- 3 -1 roll pop % get rid of the FirstChar value
- dup length dup 0 gt
- {
- 3 -1 roll exch div % calculate an average width from the Widths array
- gsave
- 2 index 10 scalefont setfont
- exch dup length exch stringwidth
- grestore
- pop 100 mul exch div div
- % Only make the font smaller/narrower, not larger/wider
- dup 1.0 lt
- {
- 0 0 2 index 0 0 6 array astore
- exch //true .copyfontdict
- dup /FontMatrix get 3 -1 roll matrix concatmatrix
- exch dup 3 -1 roll /FontMatrix exch put
- % we don't need to definfont here, we can leave that to .completefont below
- }
- {
- pop
- } ifelse
- }
- {
- % no suitable Widths entries - carry on and hope for the best......
- pop pop pop
- } ifelse
- }
- {
- % Broken file: no Widths array for non-base14 font - carry on and hope for the best......
- ( **** Warning: Widths array missing in FontDescriptor for non-base14 font\n)
- pdfformatwarning
- pop pop pop
- } ifelse
- }
- {
- ( **** Warning: FirstChar value missing in FontDescriptor for non-base14 font\n)
- pdfformatwarning
- } ifelse
- % Stack: font-res fontname fontdesc font
-
- % If this is a small-caps font, replace the CharString
- % entries for a..z.
- exch /Flags oget 16#20000 and 0 ne
- {
- //true .copyfontdict
- dup /CharStrings 2 copy get dup length dict .copydict
- % stack: font-res fontname font font /CharStrings CharStringsdict
- 5 index /FirstChar get 97 .max
- 6 index /LastChar get 122 .min 1 exch
- {
-
- % Stack: font-res fontname font' font' /CharStrings charstrings code
- % Note that this only remaps a-z, not accented characters.
- 6 index /Widths oget 1 index 8 index /FirstChar get sub oget
- 1 string dup 0 5 -1 roll put
-
- % Stack: font-res font' font' /CharStrings charstrings code
- % width (x)
- 2 index exch dup cvn exch
- dup 0 2 copy get 32 sub put 4 -1 roll
- {
- % Stack: operand (X) width
- 0 setcharwidth exch pop
- currentfont /FontMatrix get matrix invertmatrix concat
- 0.7 dup scale 0 0 moveto show
- } /exec cvx 4 packedarray cvx put
- } for put
- } if
-
- dup /FontName get 2 index ne
- {
- //true .copyfontdict
- 2 copy exch /FontName exch put
- } if
- exch pop .completefont
-} bind executeonly def
-
-/pdffindfont { % <font-resource> <fontname> pdffindfont <font>
- % If the font isn't available, synthesize one based on
- % its descriptor.
- dup /Font resourcestatus
- {
- pop pop pdffindcachedfont
- }
- {
- 1 index /FontDescriptor knownoget {
- /SUBSTFONT where not
- {
- pdfsubstitutefont
- }
- {
- % User has defined SUBSTFONT, use the defined substitute font, do not
- % try to be clever
- pop % the dictionary containing SUBSTFONT
- pop % the FontDescriptor
- pdffindcachedfont
- }ifelse
- }
- {
- % No descriptor available, use the default algorithm.
- pdffindcachedfont
- } ifelse
- } ifelse
- exch pop
-} bind executeonly def
-
-% ---------------- Type 1 fonts ---------------- %
-
-/buildType1 % <Type1-font-resource> buildType1 <font>
- { dup /BaseFont get pdffindfont
- } bind executeonly def
-
-% Read an embedded Type 1 font.
-/readfontfilter { % <proc> readfontfilter <filter>
- 0 () /SubFileDecode filter
-} bind executeonly def
-
-% Adobe Acrobat doesn't skip space characters after eexec
-/eexec_pdf_param_dict mark
- .eexec_param_dict {} forall
- /keep_spaces //true
-.dicttomark readonly def
-
-% When Type 1 font reading procedure is executing, a copy of this dictionary is current.
-% topFontDict allows us to *attempt* to handle the case where a Type 1 font definition
-% does not start by creating it's own dictionary (i.e. a number of the keys end up in
-% the currentdict rather than the font dictionary).
-% The whole type1 stream can be executed directly. There's no need to process
-% Length1, 2, 3 keys.
-
-/readtype1dict 10 dict dup begin
- /prev_definefont /definefont load def
-
- /definefont {
- % if a font defines any keys outside it's own dictionary,
- % this attempts to cope by copying them into the font dictionary
- [
- /FontType % in PLRM order
- /FontMatrix
- /FontName
- /FontInfo
- /WMode
- /Encoding
- /FontBBox
- /UniqueID
- /XUID
- /PaintType
- /StrokeWidth
- /Metrics
- /Metrics2
- /CDevProc
- /CharStrings
- /Private
- /WeightVector
- ]
- {
- 2 copy known
- {pop}
- {
- dup where
- {
- 1 index get
- 2 index
- 3 1 roll put
- dup /MisplacedKey 0 put
- }
- {pop} ifelse
- } ifelse
- } forall
- dup /MisplacedKey known {
- ( **** Warning: Type 1 font defines some required keys outside the font dictionary.\n)
- pdfformatwarning
- } if
-
- dup /CharStrings get /.notdef known not {
- dup /CharStrings get
- /.notdef <9E35CED7FFD3622F09> put
- ( **** Warning: Type 1 font has no /.notdef entry in /CharString dictionary.\n)
- pdfformatwarning
- } if
- dup /UniqueID .knownget {
- dup dup 0 lt exch 16#ffffff gt or {
- ( **** Warning: Ignoring invalid /UniqueID = ) exch =string cvs
- concatstrings (\n) concatstrings pdfformatwarning
- dup /UniqueID undef
- } {
- pop
- } ifelse
- } if
- prev_definefont
- } bind executeonly def
-
- /undef_proc_warning {
- /Repaired //true store % flag that we have warnings
- UndefProcList exch 2 copy .knownget { 1 add } { 1 } ifelse put
- } bind executeonly def
-
- /missing-type1-procs 6 dict begin
- /-| { string currentfile exch readstring pop /-| //undef_proc_warning exec } executeonly bdef
- /RD { string currentfile exch readstring pop /RD //undef_proc_warning exec } executeonly bdef
- /|- { noaccess def /|- //undef_proc_warning exec } executeonly bdef
- /ND { noaccess def /ND //undef_proc_warning exec } executeonly bdef
- /| { noaccess put /| //undef_proc_warning exec } executeonly bdef
- /NP { noaccess put /NP //undef_proc_warning exec } executeonly bdef
- currentdict end readonly def
-
- /eexec {
- % Assume the font dictionary is directly below the file on the stack
- count 0 gt { /topFontDict 2 index cvlit store } if
- //eexec_pdf_param_dict /eexecDecode filter
-
- //missing-type1-procs begin
- /userdict .systemvar begin
- //systemdict begin
- readtype1dictcopy begin cvx stopped
-
- currentfile flushfile % Skip the trailer after return from eexec, bug 690701.
- { currentdict end //missing-type1-procs eq { exit } if } loop
- { stop } if
- } bind executeonly def
-
- /readonly-op-dict <<
- /stringtype 0
- /arraytype 0
- /packedarraytype 0
- /dicttype 0
- >> readonly def
-
- /readonly { % bug 689617
- dup type //readonly-op-dict exch known not {
- ( **** Warning: Type 1 font applies operator readonly to an invalid object type.\n)
- pdfformatwarning
- } if
- } bind executeonly def
-
- /prev_get /get load def
-
- /get {
- dup /FontName eq {
- % No warning, probably FontName is defined elsewhere; see definefont above.
- .knownget not { /Missing } if
- } {
- dup /UniqueID eq {
- % We don't want fonts to check /UniqueID and do 'restore'.
- pop pop 16#FEDCBA98 % Arbitrary and invalid value
- } {
- prev_get
- } ifelse
- } ifelse
- } bind executeonly def
-
- /prev_begin /begin load def
-
- /begin {
- dup //systemdict eq { pop 0 dict } if
- prev_begin
- } bind executeonly def
-
- { /undef_proc_warning /missing-type1-procs /readonly-op-dict }
- { currentdict exch undef } forall
-
- % Bug703454.pdf contains a number of fonts with multiple definitions
- % of a given glyph name in the CharStrings dict - i.e. two entries
- % for /a - the first of which is "correct" the second is "wrong".
- % Normal Postscript behaviour replaces the first value with the second
- % for the given key/value pair.
- % To handle this, *only* for Type 1 fonts embedded in PDFs, we
- % have a special definition of "def" which won't overwrite existing
- % values in the CharStrings dict.
- /def
- {
- 3 index /CharStrings eq
- currentdict 3 index known and
- { pop pop }
- { systemdict /def get exec }
- ifelse
- } bind executeonly def
-
-end readonly def
-
-currentdict /eexec_pdf_param_dict .undef
-
-/readtype1 { % <font-resource> <stream-dict> readtype1 <font|null>
- PDFfile fileposition 3 1 roll % pos res stream
- dup /PFB known exch % pos res pfb? stream
- //true resolvestream % pos res pfb? file
- exch {
- //false /PFBDecode filter % pos res file'
- } if
- % Some buggy embedded fonts leave extra junk on the stack,
- % so we have to make a closure that records the stack depth
- % in a fail-safe way. This code also removes the mark when
- % the implied cleartomark is not executed, i.e. Length3 == 0.
- % Also restore dictstack depth.
- %
- //systemdict begin
- //readtype1dict dup length 5 add dict copy begin % pos res file'
- /file-position 4 -1 roll def % res file'
- /stack-count count 3 sub def
- 1 index /BaseFont oget /savedFontName exch def
- /topFontDict //null def
- /readtype1dictcopy currentdict def
- cvx stopped
- { currentdict /topFontDict known not { end } { exit } ifelse } loop
- { /topFontDict //null def } if
- PDFfile file-position setfileposition
- count stack-count sub { pop } repeat
- topFontDict end end
- } bind executeonly def
-
-% ---------------- Type 3 fonts ---------------- %
-
-/buildType3 { % <Type3-font-resource> buildType3 <font>
- 8 dict begin
- /FontType 3 def
- % If the font does not contain a Resources entry, then we use
- % the resources from our current context. Page 391 of the PDF
- % 1.6 spec says that the Resources dict is optional and if not
- % present then we should use the Resources for the page.
- % However we have a test file (687989) which uses a Type3 font
- % inside a form XObject and the desired Resources are in the
- % XObject dict and not in the Page dict. So we are going to
- % the parent object to find resources instead of only going to
- % the page dict when a font does not specify its required
- % resources.
- /Resources 1 index /Resources knownoget {
- oforce
- } {
- 0 dict
- } ifelse def
- /FontBBox 1 index /FontBBox get cvx def
- /FontMatrix 1 index /FontMatrix oget def
- /CharProcs 1 index /CharProcs oget def
- 1 index /Widths knownoget {
- /Widths exch def
- 1 index /FirstChar known 2 index /LastChar known and {
- /FirstChar 1 index /FirstChar oget def
- /LastChar 1 index /LastChar oget def
- } {
- ( **** Error: Requireed entry FirstChar or LastChar is missing from Font.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- /FirstChar 0 def
- /LastChar Widths length def
- }ifelse
- } if
- /FontName 1 index /Name knownoget not { /PDFType3Untitled } if def
- /Encoding .notdefEncoding 2 index getencoding def
- % We have to define BuildChar rather than BuildGlyph:
- % there is no PDF equivalent of glyphshow, and we need
- % the character code to access the Widths.
- /BuildChar {
- % Stack: font charcode
- 1 index begin 4 dict begin
- /Font 3 -1 roll def /CharCode 1 index def
- Encoding exch get CharProcs exch knownoget {
- dup /Length get 0 eq {
- pop
- %% Detect a 0 length stream. If this occurs
- %% then we won't execute d0 or d1, and so won't adjust the
- %% character width. So, pretend we got a
- %% null d1, just so that we can adjust using the /Widths
- %% (Bug 697805)
- 0 0 0 0 0 0
- pdfopdict /d1 get exec
- }{
- {
- dup //false resolvestream
- % Stack: filepos streamdict stream
- % Don't let setgcolor set the color inside the BuildGlyph
- % procedure, because this causes an /undefined error.
- q
- %% This is (currently) needed to make sure that the current dictionary, which is
- %% 'nodict' because we did a gsave, is writeable. If we don't execute gput
- %% to make a writeable copy then it is a no access dicitonary and the 'def'
- %% below will fail. It would be nice to fix the cases of this someday, but
- %% we use 'nodict'[ to store other PDF state stuff that isn't gstate, and we
- %% probably always will, so it may well be more trouble than its worth.
- /Dummy //false gput
- Font /Resources get % Stack: filepos streamdict stream resdict
- dup length 0 eq {
- 3 -1 roll /Resources knownoget {
- exch pop
- ( **** Warning: Type 3 font has resource dictionary in glyph stream.\n)
- pdfformatwarning
- } if
- } {
- 3 -1 roll pop
- } ifelse
- exch pdfopdict
- /BuildCharDictDepth countdictstack def
- .pdfruncontext
- countdictstack BuildCharDictDepth sub
- {
- //pdfdict /.Qqwarning_issued .knownget {not}{//true} ifelse
- {
- (\n **** Warning: Type 3 glyph has unbalanced q/Q operators \(too many q's\)\n Output may be incorrect.\n)
- pdfformatwarning
- //pdfdict /.Qqwarning_issued //true .forceput
- } executeonly if
- Q
- } executeonly repeat
- Q
- } executeonly PDFfile fileposition 2 .execn % Keep pdfcount valid.
- PDFfile exch setfileposition
- } executeonly ifelse
- } executeonly
- {
- % PDF Type 3 fonts don't use .notdef
- % d1 implementation adjusts the width as needed
- 0 0 0 0 0 0
- pdfopdict /d1 get exec
- } ifelse
- end end
- } executeonly bdef
- dup currentdict Encoding .processToUnicode
- currentdict end .completefont exch pop
-} bind executeonly odef
-/.adjustcharwidth { % <wx> <wy> .adjustcharwidth <wx'> <wy'>
- % Enforce the metrics, in glyph space, to the values found in the PDF Font object
- % - force wy == 0 (assumed, and not stored in the PDF font)
- % Even though PDF1.3-1.7 specifications state that this must be 0,
- % Distiller sometimes creates Type3 fonts with non-zero wy. We set
- % it to 0 since this is apparently what Acrobat Reader 4 and 5 do.
- % PDF1.2 does not mention this restriction, it only says
- % "see setcharwidth/ setcachedevice in the PostScript Reference".
- % - get wx from the Widths array (do nothing if not present)
- pop 0
- /Widths where {
- begin
- CharCode FirstChar ge CharCode LastChar le and {
- exch pop Widths CharCode FirstChar sub get exch
- } if end
- } if
-} bind executeonly def
-
-% ---------------- TrueType fonts ---------------- %
-
-/TTfonts mark
- /Arial /Helvetica
- /Arial,Italic /Helvetica-Oblique
- /Arial,Bold /Helvetica-Bold
- /Arial,BoldItalic /Helvetica-BoldOblique
- /CourierNew /Courier
- /CourierNew,Bold /Courier-Bold
- /TimesNewRoman /Times-Roman
- /TimesNewRoman,Italic /Times-Italic
- /TimesNewRoman,Bold /Times-Bold
- /TimesNewRoman,BoldItalic /Times-BoldItalic
-.dicttomark readonly def
-
-/buildTrueType { % <TrueType-font-resource> buildTrueType <font>
- dup /BaseFont oget
- dup /font_name gput
-
- 1 index /FontDescriptor knownoget
- {
- /Flags knownoget
- {
- 4 and 0 ne
- { //true } % symbolic
- { 1 index /Encoding oknown not} % no encoding => symbolic
- ifelse
- }
- {//false}
- ifelse
- }
- {//false}
- ifelse
-
- /is_symbolic gput
- 1 index /Encoding oknown {
- StandardEncoding
- 3 index getencoding
- } {
- //null
- } ifelse
- /prebuilt_encoding gput
- //false /.render_notdef gput % set the default
-
- dup /Font resourcestatus dup { exch pop exch pop } if not
- TTfonts 2 index known and {
- dup TTfonts exch get
- QUIET not {
- (Substituting font ) print dup =only
- ( for ) print 1 index =only (.) = flush
- } if
- exch 3 1 roll pdffindfont
- //true .copyfontdict
- 2 copy exch /FontName exch put
- exch pop .completefont
- } {
- pdffindfont
- } ifelse
-} bind executeonly def
-
-% Read an embedded TrueType font.
-/readtruetype { % <font-resource> <stream-dict> readtruetype <font>
- 1 index exch
- PDFfile fileposition 3 1 roll
- //true resolvestream readfontfilter
- % Stack: filepos fontres stream
- 1 index /CIDSystemInfo oknown {
- 1 index /CIDSystemInfo get dup type /packedarraytype eq {exec}if
- dup /Registry known not {
- ( **** Warning: a CIDFont's CIDSystemInfo is missing the required Registry entry\n) pdfformatwarning
- dup /Registry (Adobe) put
- } if
- dup /Ordering known not {
- ( **** Warning: a CIDFont's CIDSystemInfo is missing the required Ordering entry\n) pdfformatwarning
- dup /Ordering (Identity) put
- } if
- dup /Supplement known not {
- ( **** Warning: a CIDFont's CIDSystemInfo is missing the required Supplement entry\n) pdfformatwarning
- dup /Supplement 0 put
- } if
- 3 1 roll
- 1 index /Subtype knownoget {
- /CIDFontType2 ne {
- ( **** Error: Subtype of a TT CID font is not /CIDFontType2\n) pdfformaterror
- 1 index /Subtype /CIDFontType2 put
- ( Output may be incorrect.\n) pdfformaterror
- } if
- } {
- ( **** Error: Subtype of a TT CID font is missing.\n) pdfformaterror
- 1 index /Subtype /CIDFontType2 put
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
-
- 1 index /BaseFont get % Use the BaseFont name for the font. Otherwise we
- % would use the name table, or a manufactured name.
- .loadttcidfont
- % Stack: filepos fontres cidfont
- } {
- % filepos fontres stream
- 1 index /FontDescriptor oget
- /Flags oget dup % only believe the symbolic flag if the non-symbolic flag is not also set!
- 4 and 0 ne
- exch 32 and 0 eq and {
- //true % symbolic
- } {
- 1 index /Encoding oknown not % no encoding => symbolic
- } ifelse
-
- 2 index /Encoding oknown {
- StandardEncoding
- 3 index getencoding
- } {
- //null
- } ifelse
-
- dup 4 index exch % filepos fontres stream is_symbolic Encoding fontres Encoding
- /prebuilt_encoding exch put % filepos fontres stream is_symbolic Encoding
- 5 index /BaseFont get % Use the BaseFont name for the font. Otherwise we
- % would use the name table, or a manufactured name.
- .loadpdfttfont
- } ifelse
- exch pop
- PDFfile 3 -1 roll setfileposition
- % Ignore both the Encoding and the Widths.
- exch pop
-} bind executeonly def
-
-% ---------------- Type 0 fonts ---------------- %
-
-% Predefine the known CMaps, but only create them on demand.
-/knownCMaps mark
- /Identity-H { /Identity-H 0 makeIdentityCMap }
- /Identity-V { /Identity-V 1 makeIdentityCMap }
-.dicttomark def
-
-/makeIdentityCMap { % <cmapname> <wmode> .makeIdentityCMap -
- .currentglobal //true .setglobal 3 1 roll
- /CIDInit /ProcSet findresource begin
- 12 dict begin
- begincmap
- /WMode exch def
- /CMapName exch def
- /CIDSystemInfo 3 dict dup begin
- /Registry (Adobe) def
- /Ordering (Identity) def
- /Supplement 0 def
- end def
- %/CMapName (see above)
- /CMapVersion 1 def
- /CMapType 1 def
- %WMode (see above)
- % The PDF documentation says that these CMaps map CIDs
- % "1 to 65,536". This is a misprint for 0 to 65,535.
- 1 begincodespacerange
- % <0001> <00ff> <0100> <ffff>
- <0000> <ffff>
- endcodespacerange
- 1 begincidrange
- % <0001> <00ff> 1 <0100> <ffff> 256
- <0000> <ffff> 0
- endcidrange
- endcmap
- CMapName currentdict /CMap defineresource
- knownCMaps CMapName 2 index put
- end % CMap
- end % CIDInit ProcSet
- exch .setglobal
-} bind executeonly def
-
-/CMap_read_dict 3 dict begin
- /defineresource % <name> <dict> <cat-name> defineresource <dict>
- {
- pop
- /.last_CMap_def 1 index store
- exch pop
- } bind executeonly def
- /CIDSystemInfo
- {
- ( **** Error: CMap has invalid syntax near CIDSystemInfo.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- /CIDSystemInfo
- } bind executeonly def % A work around a bug in Altona.Page_3.2002-09-27.pdf - a slash is missed.
- /CMapName
- {
- ( **** Error: CMap has no CMapName.\n\
- See the comment to revision 6201 in gs/doc/ps2pdf.htm#Problems .\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- /CMap1 % arbitrary, PDF defineresource tolerates non-unique names
- } bind executeonly def % A work around incorrect ToUnicode CMap generated by GS before rev. 6201.
-currentdict end readonly def
-
-% Read an embedded stream that we *hope* is a PostScript CMap. According
-% to the spec, ths isn't legal, but 'Acrobat opens it'....
-%
-/read_CMap {
- dup mark exch 0 (begincodespacerange) /SubFileDecode filter cvx exec
- cleartomark
- {currentdict dup /CMapType known not {end}{pop exit} ifelse} loop
- /CMapType 1 def
- mark exch % emulate 'begincodespacerange'
- 0 (endcmap) /SubFileDecode filter cvx /begincmap cvx exch 2 .execn
- endcmap
- currentdict end
- dup /CMapName get exch
- /CMap defineresource end
-} bind executeonly def
-
-% Read embedded CMap stream.
-% if the <wmode> parameter is null, it indicates there is no WMode, and we
-% should not add one.
-% Following Acrobat we ignore everything outside
-% begincodespacerange .. endcmap.
-/read_CMap_stream { % <info> <wmode> <name> <stream> read_CMap <CMap>
- //CMap_read_dict begin
- /CIDInit /ProcSet findresource begin
- 12 dict begin
- /o.endmapvalue /.endmapvalue load def
- /.endmapvalue
- {
- dup 65535 gt
- {
- ( **** Warning: CMap: CID out of valid range (0-65535).\n) pdfformatwarning
- pop 65535
- } if
- o.endmapvalue
- } bind def
- 4 2 roll
- dup //null eq { pop } { /WMode exch def } ifelse
- dup //null eq { pop } { /CIDSystemInfo exch def } ifelse
- /CMapType 1 def
- /.last_CMap_def currentdict def % establish binding
-
- % The stream may not be seekable, push a ReusableStream to make it seekable.
- /ReusableStreamDecode filter
-
- % Try to skip past the 'header' portion of the PDF file to the body
- % If the CMap doesn't have a begincodespacerange (eg it uses /UseCMap)
- % then this will leave us at EOF.
- dup 0 (begincodespacerange) /SubFileDecode filter flushfile
- % See if we have anything left in the file
- dup bytesavailable 0 eq
- {
- % We discarded all the file contents, so there was no begincodespacerange
- % Rewind the file to the beginning
- dup 0 setfileposition
- % And try again, this time only discarding to the 'begincmap'
- dup 0 (begincmap) /SubFileDecode filter flushfile
- }
- {
- % Everything worked as expected, because we have consumed the
- % begincodespacerange from the file, emulate it
- mark exch
- } ifelse
-
- 0 (endcmap) /SubFileDecode filter cvx /begincmap cvx exch 2 .execn
- currentdict /o.endmapvalue undef
- endcmap
- /.last_CMap_def load
- { currentdict end //CMap_read_dict eq { exit } if } loop
- dup /.last_CMap_def undef
- /CMap defineresource
-} bind executeonly def
-
-currentdict /CMap_read_dict undef
-
-/buildType0 { % <Type0-font-resource> buildType0 <font>
- dup /BaseFont get % FontName
- 1 index /Encoding oget
- dup type /nametype eq {
- dup /CMap resourcestatus {
- pop pop /CMap findresource
- } {
- knownCMaps 1 index .knownget
- { exch pop exec } { /undefined signalerror } ifelse
- } ifelse
- } {
- %% Bug #696449 Acrobat will read an embedded PostScript
- %% CMap, whcih according to the spec is not valid, it needs
- %% to be a PDF CMap stream. Here we check and see if it looks like a CMap
- %% dictionary. If it is we proceed, if its some other kind of dictionary,
- %% throw an error, if its neither, treat it as a stream and hope for the best.
- dup /Type known {
- dup /Type get /CMap eq {
- PDFfile fileposition exch
- dup /CIDSystemInfo knownoget {
- << exch { oforce } forall >>
- } {
- //null
- } ifelse exch
- dup /WMode knownoget not {//null} if exch
- dup /CMapName knownoget not {/null} if exch
- //true resolvestream
- read_CMap_stream
- exch PDFfile exch setfileposition
- } {
- PDFSTOPONERROR {
- /buildType0 cvx /syntaxerror signalerror
- } if
- } ifelse
- }{
- PDFfile fileposition exch
- //true resolvestream
- read_CMap
- exch PDFfile exch setfileposition
- } ifelse
- } ifelse % CMap
- [
- 3 index /DescendantFonts oget { exec resourcefont } forall
- ] % subfonts
- .composefontdict % composefont must insert FontInfo dictionary - see gs_cmap.ps .
- % Stack: fontres name font
- 3 copy exch pop //null .processToUnicode
- exch pop .completefont % Stack: fontres font
-
- 1 index /FontMatrix knownoget {
- dup aload pop //true {0 0 1 0 0 1} {3 -1 roll eq and} forall {
- 1 index exch makefont exch /FontName get exch
- exch pop .completefont
- } {
- pop
- } ifelse
- } if exch pop
-} bind executeonly def
-
-% ---------------- CIDFontType0/2 fonts ---------------- %
-
-% Insert metrics into a CIDFont, by saving the PDF W, W2, DW, and DW2
-% arrays and using a (currently very inefficient) CDevProc.
-% For detail, refer "PDF Reference" 2nd ed., p314 "5.6.3 CIDFonts".
-% It notes default DW is 0, but Acrobat Reader uses 1000 as default.
-% If DW is 0, currentpoint does not move by default in rendering text
-% horizontally, the result is unreadable. You can check it by Acrobat.
-
-/.pdfDefaultDW 1000 def
-/.pdfDefaultDW2 [ 880 -1000 ] def
-
-/addCIDmetrics { % <CIDFont-resource> <CIDFont> addCIDmetrics <fontdict>
- dup length 5 add dict .copydict
- dup /FID undef
- dup /UniqueID undef
- dup /XUID undef
- % Insert the widths into the font.
-
- % Stack: pdfresource newfont
-
- 1 index /DW knownoget {
- 1 index /DW 3 -1 roll put
- } {
- dup /DW .pdfDefaultDW put
- } ifelse
-
- 1 index /W knownoget {
- //false 1 index { xcheck or } forall {
- oforce_array
- } if
- dup 2 index /W 3 -1 roll put
- .pdfMakeInternalW 1 index /.internalW 3 -1 roll put
- } if
-
- 1 index /DW2 knownoget {
- 1 index /DW2 3 -1 roll put
- } {
- dup /DW2 .pdfDefaultDW2 put
- } ifelse
-
- 1 index /W2 knownoget {
- //false 1 index { xcheck or } forall {
- oforce_array
- } if
- dup 2 index /W2 3 -1 roll put
- .pdfMakeInternalW2 1 index /.internalW2 3 -1 roll put
- } if
- dup /CDevProc 1 index /CIDWProc load /exec load 3 packedarray cvx put
- exch pop
-} bind executeonly def
-
-/.pdfMakeInternalMTXArray { % <mtx_array> <item_size> .pdfConvertInternalW <mtx_array'>
- % convert /W or /W2 to internal expression
- %
- % mtx_array: original /W or /W2 array
- % item_size: number of metrics values per CID
- %
- % for detail of the metrics list format in PDF,
- % refer PDF Ref. p.317 "Glyph Metrics in CIDFonts".
- %
- % format of single entry in internal expression
- %
- % [
- % [cid_begin cid_end]
- % value_is_varied (bool)
- % [ [values for cid_begin...]
- % [values for cid_begin + 1]
- % ... ]
- % ]
- %
-
- 7 dict
- begin
- /itemSize exch def
- /M exch def % original /W or /W2
- /Msize M length def
- /Mi { M i get } def % W[i]
- /Mi1 { M i 1 add get } def % W[i + 1]
- /putMTXEntry <<
- /arraytype {
- [
- [Mi Mi Mi1 length itemSize idiv add 1 sub]
- //true
- [
- 0 itemSize Mi1 length 1 sub {
- [ exch 1 1 index itemSize add 1 sub { Mi1 exch get } for ]
- } for
- ]
- ]
- /i i 2 add def
- }
- /integertype {
- [
- [Mi Mi1]
- //false
- [[ i 2 add 1 i 1 add itemSize add { M exch get } for ]]
- ]
- /i i 2 add itemSize add def
- }
- >> def
-
- /i 0 def
-
- [ { putMTXEntry Mi1 type get exec i Msize ge { exit } if } loop ]
- end
-} executeonly def
-
-/.pdfMakeInternalW { dup length 0 gt { oforce_recursive 1 .pdfMakeInternalMTXArray } if } executeonly def
-/.pdfMakeInternalW2 { dup length 0 gt { oforce_recursive 3 .pdfMakeInternalMTXArray } if } executeonly def
-
-/.pdfGetMTXByCID { % <internalMTXArray> <cid>
- % .pdfGetMTXByCID
- % { <MTXEntry> true | false }
-
- % get values for given CID from internal format of /W or /W2
-
- exch
- {
- {
- dup 0 get {} forall % Stack: <cid> <entry> <cid_0> <cid_1>
- 3 index lt { pop pop //false exit } if
- 2 index exch sub dup 0 lt { pop pop //false exit } if
- 1 index 1 get not { pop 0 } if
- exch 2 get exch get //true exit
- } loop
- { exit } if
- } forall
- dup type /arraytype eq { exch pop //true } { pop //false } ifelse
-} executeonly def
-
-% Apply the [D]W[2] metrics to a character before displaying.
-/CIDWProc { % <w0x> <w0y> <llx> <lly> <urx> <ury>
- % <w1x> <w1y> <vx> <vy> <cid> <font> CIDWproc
- % <w0x'> ... <vy'>
- begin % push <font> to currentdict
- % <w1x> <w1y> <vx> <vy> won't be used and replaced, discard now
- 5 1 roll pop pop pop pop
-
- % get FontMatrix that applies to this CID
- % (needs to convert [D]W[2] values to glyph space)
- currentdict /FontMatrix get
- % if the currentfont is a CIDFontType 0 CIDFont,
- % we need FDArray font's FontMatrix too
- FontType 9 eq {
- currentdict 2 index .type9mapcid
- % <w0x> <w0y> <llx> <lly> <urx> <ury> <cid> <FontMatrix> (charstring) <FDArray#>
- exch pop currentdict /FDArray get exch get /FontMatrix get
- % <w0x> <w0y> <llx> <lly> <urx> <ury> <cid> <FontMatrix> <FontMatrix2>
- matrix concatmatrix
- } if
- % preserve this FontMatrix at bottom of the stack
- 8 1 roll
- % Stack: <FontMatrix> <w0x> <w0y> <llx> <lly> <urx> <ury> <cid>
-
- {
- currentdict /DW .knownget not { % no DW
- .pdfDefaultDW exit % replace <w0x> by defaultDW
- } if
-
- currentdict /.internalW .knownget not { % no W
- exit % use already-stacked DW
- } if
-
- dup length 0 eq { % W is null array
- pop % discard unusable W
- exit % use already-stacked DW
- } if
-
- % W is finite array, try to get W_cid
- 2 index .pdfGetMTXByCID { % got W, discard DW
- exch pop {} forall
- exit
- } if
-
- exit
- } loop
- 0 % <w0y'>
-
- % Stack: <FontMatrix> <w0x> <w0y> <llx> <lly> <urx> <ury> <cid> <w0x'> <w0y'>
- 9 -2 roll pop pop % discard <w0x> <w0y>
- 7 2 roll % put <w0x'> <w0y'>
-
- % Stack: <FontMatrix> <w0x'> <w0y'> <llx> <lly> <urx> <ury> <cid>
- 0 % <w1x'>
- exch % put <w1x'>
-
- % Stack: <FontMatrix> <w0x'> <w0y'> <llx> <lly> <urx> <ury> <w1x'> <cid>
- {
- currentdict /DW2 .knownget not { % no DW2, use defaultDW2
- .pdfDefaultDW2 exit
- } if
-
- currentdict /.internalW2 .knownget not { % has DW2, no W2
- exit % use already-stacked DW2
- } if
-
- dup length 0 eq { % W2 is null array
- pop % discard unusable W2
- exit % use already-stacked DW2
- } if
-
- 2 index .pdfGetMTXByCID { % got W2_cid, discard DW2
- exch pop
- exit
- } if
-
- % could not get W2_cid
- exit
-
- } loop
-
- exch pop % discard <cid>
-
- % Stack: <FontMatrix> <w0x'> <w0y'> <llx> <lly> <urx> <ury>
- % <w1x'> { [<vy'> <w1y'>] | [<w1y'> <vx'> <vy'>] }
- dup length 2 eq { % this is DW2
- aload pop
- exch 8 index 2 div % <vx'> = <w0x'> / 2
- exch
- } { % assume W2
- aload pop
- } ifelse
- % Stack: <FontMatrix> <w0x'> <w0y'> <llx> <lly> <urx> <ury> <w1x'> <w1y'> <vx'> <vy'>
-
- % now, convert each metrics valude (1000th of text space) to glyph space
- 10 -2 roll
- % Stack: <FontMatrix> <llx> <lly> <urx> <ury> <w1x'> <w1y'> <vx'> <vy'> <w0x'> <w0y'>
- 3 {
- 10 index idtransform exch 1000 div exch 1000 div
- 6 2 roll
- } repeat
- 10 2 roll
- % Stack: <FontMatrix> <w0x'> <w0y'> <llx> <lly> <urx> <ury> <w1x'> <w1y'> <vx'> <vy'>
- 11 -1 roll pop
- % Stack: <w0x'> <w0y'> <llx> <lly> <urx> <ury> <w1x'> <w1y'> <vx'> <vy'>
- end % recover currentdict
-} bind executeonly def
-
-% <string> <match> tailmatch ==> <pre> true
-% ==> <string> false
-/tailmatch {
- 2 copy length 1 index length .min
- dup 2 index length exch sub exch getinterval
- 1 index eq {
- length 1 index length exch sub
- 0 exch getinterval //true
- } {
- pop //false
- } ifelse
-} bind executeonly def
-
-/makeboldfont {
- 16 dict begin
- /strokewidth exch def
- /basecidfont exch def
- /FontMatrix [ 1 0 0 1 0 0 ] def
-
- /CIDFontName /.boldfont def
- /CIDFontType 1 def
-
- /basefont-H /.basefont-H /Identity-H [ basecidfont ] composefont def
- /basefont-V /.basefont-V /Identity-V [ basecidfont ] composefont def
-
- /CIDSystemInfo dup basecidfont exch get def
- /FontBBox [ basecidfont /FontBBox get cvx exec
- 4 2 roll basecidfont /FontMatrix get transform
- 4 2 roll basecidfont /FontMatrix get transform
- ] def
-
- /tmpstr 2 string def
- /BuildGlyph {
- gsave
- exch begin
- dup 256 idiv tmpstr exch 0 exch put
- 256 mod tmpstr exch 1 exch put
- rootfont /WMode known { rootfont /WMode get 1 eq } { //false } ifelse
- { basefont-V } { basefont-H } ifelse setfont
- strokewidth setlinewidth
- 1 setlinejoin
- newpath
- 0 0 moveto tmpstr //false charpath stroke
- 0 0 moveto tmpstr show
- currentpoint setcharwidth
- end
- grestore
- } bind def
-
- currentdict
- end
- dup /CIDFontName get exch /CIDFont defineresource
-} bind executeonly def
-
-% <CIDFont-resource> <CIDFontName> findCIDFont <CIDFont-resource> <font>
-% CIDFont-resource is not modified.
-% In various places we do:
-% "findCIDFont dup /OrigFont .knownget {exch pop} if"
-% because the CIDFont we find may have been "patched" to apply metrics from
-% the PDF file (W, W2, etc). We want to avoid applying those metrics more
-% than once, hence retrieving the original, unpatched CIDFont dictionary,
-% if it exists.
-/findCIDFont {
- {
- dup /CIDFont resourcestatus {
- pop pop dup /CIDFont findresource
- dup /Path known
- 1 index /ResourcePath known or
- { exch pop exit }
- { pop dup /CIDFont undefineresource }
- ifelse
- } if
- .remove_font_name_prefix
- dup dup length string cvs
-
- (,Bold) tailmatch {
- exch pop
- % If we're substituting a standard weight font for a
- % "Light,Bold" font, don't artificially bolden further
- dup (Light) tailmatch
- {
- pop cvn findCIDFont
- dup /OrigFont .knownget {exch pop} if
- dup /FontName .knownget
- {
- (Light) tailmatch exch pop
- }
- {
- //true
- } ifelse
-
- {
- 0.03 makeboldfont
- } if
- }
- {
- pop
- cvn findCIDFont
- dup /OrigFont .knownget {exch pop} if
- 0.03 makeboldfont
- } ifelse
- exit
- } if
- (,Italic) tailmatch {
- exch pop
- cvn findCIDFont
- dup /OrigFont .knownget {exch pop} if
- [ 1 0 0.3 1 0 0 ] makefont
- exit
- } if
- (,BoldItalic) tailmatch {
- exch pop
- % see above
- dup (Light) tailmatch
- {
- pop cvn findCIDFont
- dup /OrigFont .knownget {exch pop} if
- dup /FontName .knownget
- {
- (Light) tailmatch exch pop
- }
- {
- //true
- } ifelse
-
- {
- 0.03 makeboldfont
- } if
- }
- {
- pop
- cvn findCIDFont
- dup /OrigFont .knownget {exch pop} if
- 0.03 makeboldfont
- } ifelse
- [ 1 0 0.3 1 0 0 ] makefont
- exit
- } if
- QUIET not {
- (Can't find CID font ") print dup =string cvs print (".) = flush
- } if
- pop
-
- 1 index /CIDSystemInfo oget begin Registry (-) Ordering end
- concatstrings concatstrings
- cvn
- QUIET not {
- (Attempting to substitute CID font ) print dup ==only
- ( for ) print 1 index ==only (, see doc/Use.htm#CIDFontSubstitution.) = flush
- } if
- exch pop
- dup /CIDFont resourcestatus {
- pop pop /CIDFont { findresource } stopped
- {pop}{exit} ifelse
- } if
- QUIET not {
- (The substitute CID font ") print dup =string cvs print
- (" is not provided either. ) print
- } if
-
- PDFNOCIDFALLBACK {
- PDFSTOPONERROR {
- (Will exit with error.) = flush
- }
- {
- (Will attempt to continue, but content may be missing.) = flush
- } ifelse
- exit
- } if
-
- QUIET not {
- (attempting to use fallback CIDFont.) print
- (See doc/Use.htm#CIDFontSubstitution.) = flush
- } if
-
- PDFNOCIDFALLBACK not {
- % This previously worked by loading the substitute font, and using that
- % as a "template" to create a new CIDFont dictionary with the CIDSystemInfo
- % dict appropriate for the requested font.
- % This, however, caused problems with the CIDMap and thus broke pdfwrite.
- % Hence, we now modify the CIDFont resource .map dictionary on the fly
- % so it includes an appropriate mapping, so the subsitute font is loaded
- % from the beginning with the correct ordering and supplement settings.
- /CIDFont /Category findresource /.map get dup /CIDFallBack .knownget {
- dup type /dicttype eq {
- dup /FileType get /TrueType eq {
- currentglobal
- 4 1 roll
- dup gcheck setglobal
- dup length dict copy dup
- 6 index /CIDSystemInfo oget dup /Ordering oget exch /Supplement get
- % we have to copy the string, for VM correctness
- exch dup length string copy exch 2 array astore
- /CSI exch put 2 index exch .forceput
- exch setglobal
- {
- % This *should* not execute arbitrary Postscript, so we ought to
- % be safe running in a stopped context, in knowledge we know how
- % to clean up afterwards - this would not be safe if CIDFallBack
- % were a "real" CIDFont.
- /CIDFont findresource
- }
- % if the above fails, try just using the CIDFallBack font directly
- stopped
- {
- pop
- % First, since it didn't work, remove the entry from the CIDFont category
- % .map dictionary.
- currentglobal exch
- /CIDFont /Category findresource /.map get
- dup gcheck setglobal
- exch undef
- setglobal
-
- (Warning: falling back to Identity ordering\n) print flush
- /CIDFallBack /CIDFont findresource
- } if
- exit
- } executeonly if
- } if
- } if
-
- pop pop pop
- /CIDFallBack
-
- QUIET not {
- (The fallback CID font ") print dup =string cvs print
- (" is not provided. ) print
- ( Finally attempting to use ArtifexBullet.\n) print flush
- }if
-
- % We'll just use Identity for this, we have only one glyph anyway.
- /ArtifexBullet /CIDFont resourcestatus {
- pop pop pop
- /ArtifexBullet /CIDFont findresource
- exit
- }
- {
- pop /ArtifexBullet
- } ifelse
-
- QUIET not {
- (The CID font ") print dup =string cvs print
- (" is not provided. ) print
- PDFSTOPONERROR
- {
- (Will exit with error.) = flush
- }
- {
- (Will continue, but content may be missing.) = flush
- } ifelse
- } if
- } executeonly if
- /findresource cvx /undefined signalerror
- } executeonly loop
-} bind executeonly odef
-
-/buildCIDType0 { % <CIDFontType0-font-resource> buildCIDType0 <font>
- dup /BaseFont get findCIDFont exch pop
-} bind executeonly def
-
-/buildCIDType2 { % <CIDFontType2-font-resource> buildCIDType2 <font>
- dup /BaseFont get findCIDFont exch pop
-} bind executeonly def
-
-/processCIDToGIDMap { % <fontres> <cidfont> processCIDToGIDMap <fontres> <cidfont>
- 1 index /CIDToGIDMap knownoget {
- PDFfile fileposition 4 1 roll
- dup /Identity eq {
- pop
- } {
- //true resolvestream
- % Stack: filepos fontres font mapstream
- [
- { counttomark 1 add index 32768 string readstring not {
- counttomark 1 eq {
- exch pop dup length
- } {
- ] dup 0 exch { length add } forall
- } ifelse
- exit
- } if
- } loop
- 2 idiv
- % Stack: filepos fontres font mapstream array/string CIDCount
- dup 0 ne {
- 3 index exch /CIDCount exch put
- exch closefile exch
- dup /CIDMap 4 -1 roll put
- }{
- % If CIDCount is zero, ignore it
- pop pop closefile
- }ifelse
- } ifelse
- 3 2 roll PDFfile exch setfileposition
- } if
-} bind executeonly def
-
-% Adjust a CIDFontType0 DW[2] in the font resource.
-/adjustCIDType0 { % <font-resource> <font> adjustfont <font'>
- dup /FontType get 1 eq {
- ( **** Error: Font resource has a wrong /Subtype.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- adjustfont
- } {
- addCIDmetrics
- dup /CIDFontName get exch /CIDFont defineresource
- } ifelse
-} bind executeonly def
-
-% Adjust a CIDFontType2 DW[2] and CIDToGIDMap in the font resource.
-/adjustCIDType2 { % <font-resource> <font> adjustfont <font'>
- dup /FontType get 1 eq {
- ( **** Error: Font resource has a wrong /Subtype.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- adjustfont
- } {
- addCIDmetrics
- dup /CIDFontType get 2 eq { % OpenType CFF font converts to CIDFontType 0
- processCIDToGIDMap % that ignores CIDMap.
- } if
- dup /CIDFontName get exch /CIDFont defineresource
- } ifelse
-} bind executeonly def
-
-% ---------------- Other embedded fonts ---------------- %
-
-% Read an embedded compressed font.
-/readType1C { % <font-resource> <stream-dict> readType1C <font>
- 1 index exch
- PDFfile fileposition 3 1 roll
- dup //true resolvestream dup readfontfilter
- % Stack: pos resource streamdict stream filter
- 3 index /FontDescriptor oget /FontName oget
- 1 index
- /FontSetInit /ProcSet findresource begin //true //false ReadData
- %% We need to be careful not to corrupt the stack if something went wrong.
- %% Previously, if the dict was length 0 (an error occured) we would end up
- %% unable to recover the stack in the calling procedure.
- %% Bug #695819.
- dup length 0 ne {
- { exch pop exit } forall
- 7 1 roll
- }{
- /invalidfont signalerror
- } ifelse
- closefile closefile pop
- PDFfile 3 -1 roll setfileposition
- pop pop
-} bind executeonly def
-
-% Read an embedded CFF CIDFont.
-/readCIDFontType0C { % <font-resource> <stream-dict> readCIDFontType0C <font>
- PDFfile fileposition 3 1 roll
- dup //true resolvestream dup readfontfilter
- % Stack: pos resource streamdict stream filter
- 3 index /FontDescriptor oget /FontName oget
- 1 index
- /FontSetInit /ProcSet findresource begin //true //true ReadData pop
- closefile closefile pop
- PDFfile 3 -1 roll setfileposition
- % Some broken Adobe software produces PDF files in which
- % the FontName of the CFF font and the FontName in the
- % FontDescriptor don't match the BaseFont in the font.
- % Use the FontName, rather than the BaseFont, here.
- dup /FontDescriptor oget /FontName oget /CIDFont findresource
- addCIDmetrics dup /CIDFontName get exch /CIDFont defineresource
-} bind executeonly def
-
-% Read an embedded OpenType font.
-/readOTTOfont { % <font-resource> <stream-dict> readOTTOfont <font>
- 1 index exch % res res strdict
- PDFfile fileposition 3 1 roll % res pos res strdict
- dup //true resolvestream % res pos res strdict stream
- dup readfontfilter % res pos res strdict stream filter
- 3 index /FontDescriptor oget
- /FontName oget % res pos res strdict stream filter /name
- 1 index .init_otto_font_file % res pos res strdict stream filter /name filter'
- //true
- 6 index /CIDSystemInfo known % res pos res strdict stream filter /name filter' bool bool
- ReadData % res pos res strdict stream filter fontset
- { exch pop exit } forall % res pos res strdict stream filter font
- dup /FontType get 9 eq {
- % OpenType may contain simple CFF font, which is accesed as a CIDFont by PDF.
- % The font is converted to Type 9 CIDFont resource, which ignores CIDMap attribute.
- % The following code just shuffles GlyphDirectory to the same effect.
- 4 index /CIDToGIDMap knownoget {
- dup type /dicttype eq {
- 1 index /GlyphDirectory get exch % res pos res strdict stream filter font dir c2g
- //true resolvestream % res pos res strdict stream filter font dir c2g_file
- 256 dict begin
- 0 2 index 0 get def % copy .notdef
- 0 1 16#7fffffff {
- 1 index read not { pop exit } if % res pos res strdict stream filter font dir c2g_file cid hi
- 256 mul % res pos res strdict stream filter font dir c2g_file cid hi
- 2 index read not { pop pop exit } if % res pos res strdict stream filter font dir c2g_file cid hi lo
- add % res pos res strdict stream filter font dir c2g_file cid gid
- dup 0 ne {
- dup 4 index length lt {
- 3 index exch get % res pos res strdict stream filter font dir c2g_file cid charstr
- def % res pos res strdict stream filter font dir c2g_file
- } {
- pop pop
- } ifelse
- } {
- pop pop
- } ifelse
- } for
- closefile pop % res pos res strdict stream filter font
- dup length dict copy % res pos res strdict stream filter font'
- dup /GlyphDirectory currentdict put % res pos res strdict stream filter font'
- end
- dup /GlyphDirectory get 0 exch {
- pop .max
- } forall
- 1 index exch /CIDCount exch 1 add put
- } {
- pop
- } ifelse
- } if
- } if
- 7 1 roll % font res pos res strdict stream filter
- closefile closefile pop pop % font res pos
- PDFfile exch setfileposition % font res
- pop % font
-} bind executeonly def
-
-% ---------------- Font lookup ---------------- %
-
-% Some PDF files mis-identify font type of the embedded font streams or
-% include raw PFB font streams. Length1, Length2, Length3 may be wrong or
-% missing. Adobe Acrobat corrects these errors transparently to the user.
-%
-% We ignore the font type keys and recognize the font type by the 1st 4 bytes
-% of the font stream. The PFB stream is recognized by the 1st 2 bytes.
-
-/fonttypeprocs mark % <font-resource> -proc- <font>
- /Type0 //buildType0
- /Type1 //buildType1
- /MMType1 //buildType1
- /Type3 /buildType3 load
- /TrueType //buildTrueType
- /CIDFontType0 //buildCIDType0
- /CIDFontType2 //buildCIDType2
-.dicttomark readonly def
-
-/adjustfonttypes mark
- /Type1 //adjustfont
- /MMType1 //adjustfont
- /TrueType //adjustfont
- /CIDFontType0 //adjustCIDType0
- /CIDFontType2 //adjustCIDType2
-.dicttomark readonly def
-
-% Bind a proc and define n names
-% /name ... /name {proc} n bndef -
-/bndef
- { exch bind executeonly exch
- { dup 3 1 roll def } repeat
- pop
- } bind executeonly def
-
-% <res> run-fonttypeproc <font>
-/run-fonttypeproc {
- dup /Subtype knownoget not { 0 } if % res /subtype
- //fonttypeprocs 1 index known not {
- ( **** Error: Font /Subtype attribute is wrong or missing, /Type1 assumed.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop /Type1
- 2 copy /Subtype exch put
- } if
- //fonttypeprocs exch get exec
-} bind executeonly def
-
-% Prototype for all procedures: <res> <desc> <stream> foo <font>
-/font_tag_dict 13 dict begin
-
- % When the font stream is absent or cannot be read we load the font by the name.
- /no_stream
- { pop pop
- run-fonttypeproc
- } bind executeonly def
-
- /bad_stream
- { ( **** Error: Error reading font stream, attempting to load the font using its name\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- //no_stream exec
- } bind executeonly def
-
- <8001> % PFB
- { dup /PFB //true put
- exch pop readtype1
- } bind executeonly def
-
- (%!PS) (%!Fo) % Type1
- { exch pop readtype1
- } 2 bndef
-
- <01000401> % Type 1C
- {
- exch pop
-
- 1 index /Subtype knownoget {
- dup /CIDFontType2 eq{
- pop
- ( **** Error: Subtype of a Type 1 CID font is not /CIDFontType0\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- 1 index /Subtype /CIDFontType0 put
- readCIDFontType0C
- }
- {
- /CIDFontType0 eq {
- readCIDFontType0C
- }
- {
- readType1C
- } ifelse
- } ifelse
- } {
- readType1C
- } ifelse
- } bind executeonly def
-
- <00010000> (true) (typ1) (ttcf) % TrueType OpenType
- { exch pop readtruetype
- } 4 bndef
-
- (OTTO)
- { exch pop
- readOTTOfont
- } bind executeonly def
-
-currentdict end readonly def
-currentdict /bndef undef
-
-% Used to create a hash for the XUID, ths combines the input PDF file name and the
-% object number (currently the object number of the FontDescriptor). NB we *must*
-% use an object number, as otherwise all fonts will have the same
-% XUID and Ghostscript will think they are the same font. Ths routine must not
-% be used unless we have an object number which is believed to be uniqe to
-% a particular font instance.
-/.CRCHashFilenameAndObject % object_number (filename) CRCHasFilename integer
-{
- dup % object_number (filename) (filename)
- length % object_number (filename) length
- 0 exch % object_number (filename) hash length
- 1 sub % object_number (filename) hash length-1
- 0 1 3 -1 roll % object_number (filename) hash 0 1 length-1
- { % object_number (filename) hash index
- 2 index exch get % object_number (filename) hash char
- exch % object_number (filename) char hash
- dup 16#F8000000 and % object_number (filename) char hash top5bits
- -27 bitshift % object_number (filename) char hash top5>>27
- exch 5 bitshift % object_number (filename) char top5>>27 hash<<5
- 16#7FFFFFFF and
- xor % object_number (filename) char CRC<hash>
- xor % object_number (filename) newhash
- } for
- exch pop % object_number newhash
- dup 16#F8000000 and % object_number newhash top5bits
- -27 bitshift % object_number newhash top5>>27
- exch 5 bitshift % object_number top5>>27 newhash<<5
- 16#7FFFFFFF and
- xor % object_number CRC<newhash>
- xor % final hashed value
-}bind executeonly def
-
-% Either patch or create a new XUID based on the existing
-% XUID or UniqueID and incorporating the PDF object number
-% so we get an XUID we can use to improve cache efficiency
-% in multipage documents.
-/patch_font_XUID % <font dict> <patch> patch_font_XUID <font dict'>
-{
- dup //null eq
- {pop}
- {
- //pdfdict /InputPDFFileName .knownget {.CRCHashFilenameAndObject} if
- exch dup /.OrigUniqueIDXUID .knownget not
- {
- dup /XUID .knownget not
- {
- dup /UniqueID .knownget
- {1 array astore}{ [] } ifelse
- } if
- } if
-
- dup //null eq
- {
- pop exch pop
- }
- {
- [ 1000000 3 -1 roll 4 index exch {exch} forall ]
- exch //true .copyfontdict
- dup 3 -1 roll /XUID exch put
- exch pop
- .completefont
- } ifelse
- } ifelse
-} bind executeonly def
-
-/resourcefont % <font-resource> resourcefont <font>
-{
- dup /PSFont .knownget dup {
- pop /FID knownoget dup { pop type /fonttype eq } if
- } if {
- /PSFont get
- } {
-
- dup /Subtype get /Type0 eq {
- % if the font was defined in-line, we won't have a object number
- dup /.gs.pdfobj# .knownget not { //null } if
- } {
- % if the font was defined in-line, we won't have a object number
- dup /.gs.pdfobj# .knownget not { //null }if
- dup //null eq not {
- 1 index /FontDescriptor knownoget {
- dup /FontFile knownoget not {
- dup /FontFile2 knownoget not {
- dup /FontFile3 knownoget not {
- pop pop //null
- } {pop pop}ifelse
- } {pop pop}ifelse
- }{pop pop}ifelse
- }
- {
- pop //null
- } ifelse
- }if
- } ifelse
- 3 1 roll
-
- % In the event we have a Type 0 dictionary with a spurious
- % FontDescriptor object, remove it here to prevent confusion
- % later on.
- % Bug 691589
- dup /Subtype get /Type0 eq 1 index /FontDescriptor known and
- {
- dup /FontDescriptor undef
- }if
- dup /CIDSystemInfo .knownget
- {
- oforce_recursive
- 1 index exch /CIDSystemInfo exch put
- } if
-
- dup dup /FontDescriptor knownoget {
- % font-res font-res font-desc
- % The same font descriptor can be reused in a CID and non-CID contexts.
- % Store CID and non-CID fonts under different keys. Bug 689301
- 1 index /Subtype knownoget dup {
- pop dup /CIDFontType0 eq exch /CIDFontType2 eq or
- } if { /CIDFontObject } { /FontObject } ifelse
- % font-res font-res font-desc /key
- 2 index 1 index .knownget {
- 4 1 roll pop pop pop % font-res obj
- } {
- 4 1 roll % /key font-res font-res font-desc
-
- dup /FontFile knownoget not {
- dup /FontFile2 knownoget not {
- dup /FontFile3 knownoget not {
- //null
- } if
- } if
- } if
- % /key res res desc stream
- dup //null ne {
- PDFfile fileposition
- mark {
- 2 index //true resolvestream dup
- 4 string readstring pop
- exch closefile
- } stopped {
- cleartomark /bad_stream
- } {
- exch pop
- } ifelse
- PDFfile 3 -1 roll setfileposition
- dup length 4 lt { pop /bad_stream } if
- } {
- /no_stream
- } ifelse
- % /key res res desc stream tag
-
- //font_tag_dict 1 index known not {
- %
- % The tag is the first 4 (?) bytes frm the font stream, if we get here then
- % it didn't match any of the keys in the dictionary. There seems to be
- % a possibility that a PFB font could be undetected (because its only 2 bytes?)
- % but the main problem is CFF fonts. These lack a magic number, and the header
- % can vary in the last 3 of the 4 bytes. We've now found 7 different possible
- % values for these bytes, adding more seems pointless and isn't future proof.
- % Instead check the dictionary for its Subtype.
- %
- dup 0 2 getinterval <8001> eq {
- 0 2 getinterval % /key res res desc stream pfb_tag
- } {
- 1 index /Subtype known {
- 1 index /Subtype get
- dup /Type1C eq 1 index /CIDFontType0C eq or exch /CIDFontType1C eq or {
- pop <01000401> % discard the data we read and pretend we read the original Type1C tag
- //false
- }{
- //true
- }ifelse
- } {
- //true % no /Subtype, give up.
- }ifelse
-
- {
- (12345678>\n) dup /ASCIIHexEncode filter dup 4 -1 roll writestring closefile
- ( **** Error: unrecognized font file starts with <) exch concatstrings
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- /no_stream % /key res res desc stream unknown_tag
- }if
- } ifelse
- } if
- //font_tag_dict exch get % /key res res desc stream {proc}
- { stopped } 0 get % /key res res desc stream {proc} --stopped--
- count % /key res res desc stream {proc} --stopped-- #
- countdictstack % /key res res desc stream {proc} --stopped-- # ##
- PDFfile fileposition % /key res res desc stream {proc} --stopped-- # ## ###
- 5 array astore cvx % /key res res desc stream {{proc} --stopped-- # ## ###}
- exec
- 4 -1 roll {
- PDFSTOPONERROR not {
- PDFfile exch setfileposition
- countdictstack exch sub 0 .max { end } repeat
- count 4 add exch sub 0 .max { pop } repeat
- //null
- } {
- /resourcefont cvx /undefinederror signalerror
- } ifelse
- } {
- PDFfile exch setfileposition
- countdictstack exch sub 0 .max { end } repeat
- count 3 sub exch sub 0 .max { pop } repeat
- } ifelse
- dup //null eq {
- PDFSTOPONERROR not {
- pop
- ( **** Error: can't process embedded font stream,\n attempting to load the font using its name.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- dup run-fonttypeproc % /key res font
- } {
- /resourcefont cvx /undefinederror signalerror
- } ifelse
- } if
- 1 index % /key res font res
- 4 -1 roll 2 index % res font desc /key font
- put % Save pointer to the font.
- } ifelse
- } {
- run-fonttypeproc
- } ifelse
- % Stack: font-res font
- 1 index exch
- 1 index /Subtype get
- //adjustfonttypes exch .knownget { exec } { exch pop } ifelse
- 4 -1 roll patch_font_XUID
- dup 3 1 roll /PSFont exch put
- } ifelse
- dup checkGlyphNames2Unicode
-} bind executeonly def
-
-currentdict /font_tag_dict .undef
-currentdict /fonttypeprocs .undef
-currentdict /adjustfonttypes .undef
-
-drawopdict begin
- /d0 {
- currentcolor currentcolorspace .swapcolors setcolorspace setcolor .swapcolors
- .adjustcharwidth setcharwidth
- } bind executeonly def
- /d1 {
- 2 copy % ... llx lly urx ury | urx ury
- 0 ne exch 0 ne % ... llx lly urx ury | ury!=0 urx!=0
- 3 index 6 index eq and % ... llx lly urx ury | ury!=0 (urx!=0 && llx==urx)
- exch 2 index 5 index eq and or { % ... llx lly urx ury | (urx!=0 && llx==urx) || (ury!=0 && lly==ury)
- % The bounding box is empty and likely incorrect. Don't cache.
- pop pop pop pop
- //d0 exec
- } {
- currentcolor currentcolorspace .swapcolors setcolorspace setcolor .swapcolors
- 6 -2 roll .adjustcharwidth 6 2 roll setcachedevice
- } ifelse
- } bind executeonly def
- /Tf {
- 1 index Page /Font rget {
- dup type /dicttype eq {
- resourcefont exch
- Tf pop
- }
- {
- PDFSTOPONERROR
- {
- /typecheck signalerror
- }
- {
- % Bug 689450
- type
- ( **** Error: Tf refers to a resource key with an invalid value type: ) pdfformaterror
- .namestring pdfformaterror
- (. Assuming resource key: ) pdfformaterror
- 1 index .namestring pdfformaterror
- ( is a font name.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- Tf
- } ifelse
- }ifelse
- }
- {
- PDFSTOPONERROR
- {
- pop /undefined signalerror
- }
- {
- % Bug 689037
- ( **** Error: Tf refers to an unknown resource name: ) pdfformaterror
- 1 index .namestring pdfformaterror
- ( Assuming it's a font name.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- Tf
- } ifelse
- } ifelse
- } bind executeonly def
-end
-
-end % pdfdict
-end % GS_PDF_ProcSet
-.setglobal
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps
index 32af17e3319..e541835aeb8 100644
--- a/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% pdf_main.ps
@@ -18,207 +18,31 @@
/.setlanguagelevel where { pop 2 .setlanguagelevel } if
.currentglobal //true .setglobal
-pdfdict begin
-/GS_PDF_ProcSet dup load def % keep in pdfdict to hide it
-userdict /GS_PDF_ProcSet undef
-
-% Patch in an obsolete variable used by some third-party software.
-/#? //false def
-
-% Test whether the current output device handles pdfmark.
-/.writepdfmarks { % - .writepdfmarks <bool>
- /PdfmarkCapable /GetDeviceParam .special_op {
- exch pop
- }{
- //false
- }ifelse
- systemdict /DOPDFMARKS known or
-} bind executeonly def
-
-% For simplicity, we use a single interpretation dictionary for all
-% PDF graphics execution, even though this is too liberal.
-/pdfopdict mark
- objopdict { } forall
- drawopdict { } forall
- /endstream { exit } bind executeonly
- (%%EOF) cvn { exit } bind executeonly % for filters
- /obj { ( **** Error: Content stream is not terminated by 'endstream'.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } bind executeonly
- % PDF 1.1 operators
- /BX { /BXlevel BXlevel 1 add store } bind executeonly
- /EX { /BXlevel BXlevel 1 sub store } bind executeonly
- /PS { DOPS { cvx exec } { pop } ifelse } bind executeonly % PS disabled by default, as in pdf_draw.ps DoPS
- % PDF 1.2 operators
- /BMC {
- /BMClevel BMClevel 1 add store
- pop
- } bind executeonly
- /BDC {
- /BMClevel BMClevel 1 add store
- exch /OC eq {
- dup type /nametype eq {
- PDFfile fileposition exch % pos /Name
- Page /Properties rget {
- ocg-is-visible not {
- OFFlevels BMClevel dup put
- } if
- } if
- PDFfile exch setfileposition
- } {
- pop
- } ifelse
- } {
- pop
- } ifelse
- } bind executeonly
- /EMC {
- OFFlevels BMClevel
- 2 copy known {
- 2 copy undef
- } if
- 1 sub /BMClevel exch store
- pop
- } bind executeonly
- /MP { pop } bind
- /DP { pop pop } bind
- /- { 0 % Bug 690016
- ( **** Error: Invalid operator '-' is assumed to be the number 0.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } bind executeonly
-
- /Recursive_XObject_D 1 dict def
-
-.dicttomark readonly def
-
-
-% This dictionaty encapsulates all that is needed to generate pagelabel pdfmarks.
-%
-% This is provided by Leon Bottou for the benefit of the djvudigital device
-% which is a device developed and maintained outside of Artifex, and which is
-% not a contributed device.
-%
-% This device does not cope with the method used by pdfwrite to pass the pagelabels
-% number tree as a 'blob' of data, but requires that the page labels be passed using
-% a PAGELABEL pdfmark.
-%
-% We don't want to do that with pdfwrite because there is no mechanism in pdfmark syntax
-% to pass a tree, which means we'd have to laboriously disassemble the pdfmarks for the
-% page labels and rebuild a number tree for it. This would mean pattern matching each
-% string passed via PAGELABEL to see if it could be defined as a continuation
-% of the preceding string, uing prefixes. Its much easier for us just to pass the tree.
-%
-% Note that this code simply translates the PageLabels Number tree into a number of
-% individual PAGELABEL pdfmarks, if used for pdfwrite this would result in a number
-% tree which consists solely of leaf nodes, where each node has a string for its label.
-% This can be considerably more verbose than the shorthand possible with a Page Label
-% dictionary.
-%
-/pagelabeldict mark
- % (TEXT) .toLower (text)
- /.toLower {
- dup length 1 sub -1 0 {
- 1 index exch 2 copy get 2#00100000 or put
- } for
- } bind executeonly
- % int .cvAlpha (int in alphabetic base 26)
- /.cvAlpha {
- [ exch % construct an array of ASCII values, in reverse
- { % the remainder stays on the top of stack
- dup 0 eq { pop exit } if % quit if the value is zero
- dup 26 mod dup 0 eq { 26 add } if % so that the division is correct
- dup 64 add 3 1 roll sub 26 idiv % save the ASCII value and iterate
- } loop ]
- dup length dup string 3 1 roll
- dup -1 1 { % put the letters in a string
- 4 copy sub exch 4 -1 roll 1 sub get put
- } for pop pop
- } bind executeonly
- % int .cvRoman (int in capital Roman numerals)
- % convert a positive integer to capital Roman numerals
- % return a decimal string if >= 4000
- /.cvRoman {
- dup 255 string cvs % start with the decimal representation
- exch 4000 lt { % convert only if Roman numerals can represent this
- dup length
- [ [ () (I) (II) (III) (IV) (V) (VI) (VII) (VIII) (IX) ]
- [ () (X) (XX) (XXX) (XL) (L) (LX) (LXX) (LXXX) (XC) ]
- [ () (C) (CC) (CCC) (CD) (D) (DC) (DCC) (DCCC) (CM) ]
- [ () (M) (MM) (MMM) ] ] % Roman equivalents
- () % append the Roman equivalent of each decimal digit to this string
- 2 index -1 1 {
- 2 index 1 index 1 sub get
- 5 index 5 index 4 -1 roll sub get
- 48 sub get concatstrings
- } for
- 4 1 roll pop pop pop
- } if
- } bind executeonly
- % style printers
- /PageStyle <<
- /D { 255 string cvs } bind executeonly
- /R { .cvRoman } executeonly
- /r { .cvRoman .toLower } executeonly
- /A { .cvAlpha } executeonly
- /a { .cvAlpha .toLower } executeonly >>
- % check whether we want to generate pdfmarks
- /wantpagelabelmarks {
- % WantsPageLabels means that pagelabels will be passed
- % using .pdfpagelabels and not using pdfmarks
- /WantsPageLabels /GetDeviceParam .special_op
- {pop pop //false}{//true} ifelse
-
- %% This is truly ugly.....
- %% GSView 5 redefines pdfmark and processes it itself. However if it gets
- %% a pdfmark it cannot cope with, it simply fails. Its not prepared to cope
- %% with PAGELABEL pdfmarks, so we don't want to send it to them. There's no
- %% way for us to fix GSView 5, its long out of any kind of support, but we do
- %% try not to break it. We happen to know that GSView 5 installs a GSview
- %% dictionary in userdict, so this test simply ensures we don't emit PAGELABEL
- %% pdfmarks if that dictioanry is present.
- userdict /GSview known {pop //false} if
- } bind executeonly
- % generate pagelabel pdfmark
- /dopagelabel { % -- dopagelabel --
- << /S //null /P () /O 0 >> begin
- wantpagelabelmarks {
- Trailer /Root knownoget {
- oforce /PageLabels knownoget {
- oforce Page# 1 sub
- numogetle
- { oforce
- dup /S knownoget not { //false } if /S exch def
- dup /P knownoget not { 0 string } if /P exch def
- /St knownoget not { 1 } if exch sub /O exch def
- } if
- P Page# 1 sub O add PageStyle S knownoget { exec concatstrings } if
- mark /Label 3 -1 roll /PAGELABEL pdfmark
- } if
- } if
- } if
- end
- } bind executeonly
-.dicttomark readonly def
% ======================== Main program ======================== %
-end % pdfdict
userdict begin
-/defaultfontname /Times-Roman def
-
-% Make sure the registered encodings are loaded, so we don't run the risk
-% that some of the indices for their names will overflow the packed
-% representation. (Yes, this is a hack.)
-SymbolEncoding pop
-DingbatsEncoding pop
-
% Redefine 'run' so it recognizes PDF files.
systemdict begin
-systemdict /OLDPDF known not {/OLDPDF //false def} if
+systemdict /OLDPDF known {
+ systemdict /OLDPDF get {
+ ( **** WARNING ****\n) print
+ (The old, written in PostScript, PDF interpreter has been removed entirely.\n) print
+ (You should cease using -dOLDPF as it has no effect now.\n) print
+ (Continuing to process PDF file using the new, written in C, PDF interpreter.\n\n) print
+ } if
+} if
+
+systemdict /NEWPDF known {
+ systemdict /NEWPDF get not {
+ (The old, written in PostScript, PDF interpreter has been removed entirely.\n) print
+ (You should cease using -dNEWDPF as it has no effect now.\n) print
+ (Continuing to process PDF file using the new, written in C, PDF interpreter.\n) print
+ } if
+} if
+
% PostScript interface to the ghostpdf C-based interpreter
%
@@ -824,7 +648,8 @@ systemdict /OLDPDF known not {/OLDPDF //false def} if
/PDFNOCIDFALLBACK /NO_PDFMARK_OUTLINES /NO_PDFMARK_DESTS /PDFFitPage /Printed /UsePDFX3Profile
/UseBleedBox /UseCropBox /UseArtBox /UseTrimBox /ShowAcroForm /ShowAnnots /PreserveAnnots
/NoUserUnit /RENDERTTNOTDEF /DOPDFMARKS /PDFINFO /ShowAnnotTypes /PreserveAnnotTypes
- /CIDFSubstPath /CIDFSubstFont /SUBSTFONT /IgnoreToUnicode /NONATIVEFONTMAP /PreserveMarkedContent ] def
+ /CIDFSubstPath /CIDFSubstFont /SUBSTFONT /IgnoreToUnicode /NONATIVEFONTMAP /PreserveMarkedContent /OutputFile
+ /PreserveDocView /PreserveEmbeddedFiles ] def
/newpdf_gather_parameters
{
@@ -846,7 +671,7 @@ systemdict /OLDPDF known not {/OLDPDF //false def} if
currentdict /PDFSwitches undef
-/newpdf_pagecount
+/pdfpagecount
{
currentdict /PDFInfo known
{
@@ -881,12 +706,10 @@ currentdict /PDFSwitches undef
} ifelse
}bind def
-/newpdf_runpdfpagerange
+/runpdfpagerange
{
/PageList where {
pop
- % make sure string is NUL terminated as C expects.
- PageList 1 string dup 0 0 put concatstrings
pdfpagecount
.PDFparsePageList
dup 0 eq { % No ranges, error
@@ -923,6 +746,33 @@ currentdict /PDFSwitches undef
} ifelse
} bind def
+
+/runpdf_collection_entry
+{
+ <</PreserveDocView false>> runpdfbegin_with_params % <file> runpdfbegin -
+ PDFInfo type /dicttype eq
+ {
+ PDFInfo /Collection known
+ {
+ PDFInfo /Collection get
+ pdfclose
+ dup length 1 sub 0 2 3 -1 roll
+ {
+ 1 index exch get (r) file runpdf_collection_entry
+ } for
+ pop
+ }
+ {
+ process_trailer_attrs % - process_trailer_attrs -
+ runpdfpagerange % - runpdfpagerange <int> <int>
+ dopdfpages % <int> <int> dopdfpages -
+ runpdfend % - runpdfend -
+ } ifelse
+ } {
+ pop pop
+ }ifelse
+} bind def
+
% <file> runpdf -
/newpdf_runpdf
{
@@ -935,9 +785,14 @@ currentdict /PDFSwitches undef
pdfclose
dup length 1 sub 0 2 3 -1 roll
{
- 1 index exch get (r) file runpdf
+ 1 index exch get (r) file runpdf_collection_entry
} for
pop
+ % We need to do this, even though we called pdfclose above, in order to clean
+ % up our dictionary and restore the state. We can't use runpdfend above because
+ % if we do then we will delete all the temporary files containing the embedded
+ % PDF files.
+ runpdfend
}
{
process_trailer_attrs % - process_trailer_attrs -
@@ -950,7 +805,13 @@ currentdict /PDFSwitches undef
}ifelse
} bind def
-/newpdf_runpdfbegin
+% start a PDF file, and specify interpreter parameters to be used
+% to override any command line ones.
+% Mostly for the benefit of PDF Collections where we want to disable
+%preserving DocView information for pdfwrite.
+%
+% file <dict> runpdfbegin_with_params -
+/runpdfbegin_with_params
{
/pdfdict 10 dict def
pdfdict begin
@@ -963,25 +824,26 @@ currentdict /PDFSwitches undef
% Define these in the current dictionary, if anyone uses
% systemdict then this will be defeated so we'll add extra
% code to the systemdict definitions as well.
- /pdfpagecount /newpdf_pagecount load def
- /pdfgetpage /newpdf_pdfgetpage load def
- /pdfshowpage /newpdf_pdfshowpage load def
- /pdfshowpage_init /newpdf_pdfshowpage_init load def
- /pdfshowpage_setpage /newpdf_pdfshowpage_setpage load def
- /pdfshowpage_finish /newpdf_pdfshowpage_finish load def
- /pdfopen /newpdf_pdfopen load def
- /pdfclose /newpdf_pdfclose load def
- /dopdfpages /newpdf_dopdfpages load def
- /runpdfend /newpdf_runpdfend load def
- /runpdfpagerange /newpdf_runpdfpagerange load def
- /process_trailer_attrs /newpdf_process_trailer_attrs load def
+% /pdfpagecount /newpdf_pagecount load def
+% /pdfgetpage /newpdf_pdfgetpage load def
+% /pdfshowpage /newpdf_pdfshowpage load def
+% /pdfshowpage_init /newpdf_pdfshowpage_init load def
+% /pdfshowpage_setpage /newpdf_pdfshowpage_setpage load def
+% /pdfshowpage_finish /newpdf_pdfshowpage_finish load def
+% /pdfopen /newpdf_pdfopen load def
+% /pdfclose /newpdf_pdfclose load def
+% /dopdfpages /newpdf_dopdfpages load def
+% /runpdfend /newpdf_runpdfend load def
+% /runpdfpagerange /newpdf_runpdfpagerange load def
+% /process_trailer_attrs /newpdf_process_trailer_attrs load def
% These are also for the benefit of pdf2dsc, which assumes they
% are available.
/knownoget {2 copy known {get //true}{pop pop //false}ifelse} bind def
/pget {2 copy known {get //true}{pop pop //false}ifelse}bind def
- newpdf_gather_parameters
+ newpdf_gather_parameters % <parameter overrides dict> <parameter dict>
+ exch {2 index 3 1 roll put} forall
PDFSTOPONERROR
{
.PDFInit
@@ -1006,7 +868,13 @@ currentdict /PDFSwitches undef
}ifelse
} bind def
-/newpdf_pdfgetpage
+% -file- runpdfbegin -
+/runpdfbegin
+{
+ <<>> runpdfbegin_with_params
+} bind def
+
+/pdfgetpage
{
dup 1 sub
PDFSTOPONERROR
@@ -1029,21 +897,21 @@ currentdict /PDFSwitches undef
}ifelse
} bind def
-/newpdf_process_trailer_attrs
+/process_trailer_attrs
{
}bind def
-/newpdf_pdfshowpage_init
+/pdfshowpage_init
{
} bind def
-/newpdf_pdfshowpage_setpage
+/pdfshowpage_setpage
{
dup newpdf_device_setup
dup newpdf_set_pagesize
} bind def
-/newpdf_pdfshowpage_finish
+/pdfshowpage_finish
{
PDFSTOPONERROR
{
@@ -1065,7 +933,7 @@ currentdict /PDFSwitches undef
}ifelse
} bind def
-/newpdf_pdfshowpage
+/pdfshowpage
{
/PDFINFO where {/PDFINFO get}{//false}ifelse
{
@@ -1078,7 +946,7 @@ currentdict /PDFSwitches undef
}ifelse
} bind def
-/newpdf_runpdfend
+/runpdfend
{
% Get the accumulated count of pages processed so far
% and the number of pages in this file. Do this before
@@ -1099,7 +967,7 @@ currentdict /PDFSwitches undef
add <</PageCount 3 -1 roll >> setpagedevice
} bind def
-/newpdf_pdfopen
+/pdfopen
{
dup PDFFile //null ne
{
@@ -1133,7 +1001,7 @@ currentdict /PDFSwitches undef
} ifelse
} bind def
-/newpdf_pdfclose
+/pdfclose
{
PDFSTOPONERROR
{
@@ -1149,13 +1017,13 @@ currentdict /PDFSwitches undef
/pdfavailable
{
- .PDFAvailable OLDPDF or
+ .PDFAvailable
} bind def
% <int> <int> dopdfpages -
% First Page and then LastPage
% If PDFPageList array exists, the parameters are 1 pdfpagecount and are ignored.
-/newpdf_dopdfpages
+/dopdfpages
{
//DisablePageHandlerDevice exec
%% If we have a array of page ranges to render, use it.
@@ -1288,304 +1156,6 @@ currentdict /PDFSwitches undef
} bind odef
currentdict /runpdfstring .undef
-/runpdfbegin { % <file> runpdfbegin -
- /OLDPDF where {/OLDPDF get not} {//true} ifelse
- {
- newpdf_runpdfbegin
- }
- {
- userdict begin
- % It turns out that the PDF interpreter uses memory more
- % effectively if it is run under at least one level of save.
- % This is counter-intuitive, and we don't understand why it happens,
- % but the improvement is significant.
- /PDFTopSave save def
- <<
- /ProcessDSCComment //null
- /ProcessComment //null
- %% Bug #696487, allow dict stack to grow without limit, as these PDF
- %% files have stupidly deep gsave nesting and we need a dictionary per gsave
- %% at the moment.
- %% Remove ths if bug #696511 is ever completed (move ExtGstate parameters into gstate)
- /MaxDictStack -1
- %% Bug #696567, same customer as above. Ths time they have a file with a page whch has
- %% 447000 ExtGState references (all of which contain no gstate!) Because we allocate
- %% these on the stack, allow the stack to grow indefinitely in order to accomodate
- %% such stupid files. Also move these lines from the end of the routine, so that
- %% the increases are in place before we call odfopen, which will build the
- %% resources and needs this definition in place.
- /MaxOpStack -1
- >> setuserparams
-
- //DisablePageHandlerDevice exec
-
- 0 setobjectformat
- /Page# //null def
- /Page //null def
- /DSCPageCount 0 def
- /PDFSave //null def
- //pdfdict /GS_PDF_ProcSet get begin
- //pdfdict begin
- pdfopen begin
- /CumulativePageCount currentpagedevice /PageCount get def
- } ifelse
-} bind executeonly def
-
-
-/runpdfpagerange { % - runpdfpagerange <firstpage#> <lastpage#>
- /OLDPDF where {/OLDPDF get not} {//true} ifelse
- {
- newpdf_runpdfpagerange
- }
- {
- /PortfolioPage where {
- pop
- PortfolioPage cvi dup pdfpagecount add % a b+1
- /PortfolioPage dup load % a b+1 /P ()
- ( ) 1 index copy pop
- dup 3 index exch cvs pop % a b+1 /P (b+1)
- store
- 1 sub % a b
- /FirstPage where { pop FirstPage} { 1 } ifelse
- /LastPage where { pop LastPage} {2000000000} ifelse % a b fp lp
- 2 index 2 index lt { % b < fp
- 1e10
- } {
- 3 index 2 index gt { % a > fp
- 1
- } {
- 1 index 4 index sub 1 add
- } ifelse
- } ifelse % a b fp lp f
- 3 index 2 index lt { % b < bp
- 3 index 5 index sub 1 add % b-a+1=count
- } {
- 4 index 2 index gt {
- 0
- } {
- 1 index 5 index sub 1 add
- } ifelse
- } ifelse % a b fp lp f l
- 6 2 roll pop pop pop pop
-
- QUIET not {
- 1 index 1 index gt {
- (Skipping the subfile.) = flush
- } {
- (Processing pages ) print 1 index =only ( through ) print dup =only
- (.) = flush
- } ifelse
- } if
- } {
- /PageList where {
- pop PageList
- (even) anchorsearch {
- pop length 0 gt {
- /runpdfpagerange cvx /syntaxerror signalerror
- } if
- /PDFPageList pdfpagecount 1 add array def
- 2 2 pdfpagecount {
- PDFPageList exch 1 put
- } for
- QUIET not {
- (Processing even-numbered pages\n) print (1 through ) print pdfpagecount =only
- (.) = flush
- } if
- } {
- (odd) anchorsearch {
- pop length 0 gt {
- /runpdfpagerange cvx /syntaxerror signalerror
- } if
- /PDFPageList pdfpagecount 1 add array def
- 1 2 pdfpagecount {
- PDFPageList exch 1 put
- } for
- QUIET not {
- (Processing odd-numbered pages\n) print (1 through ) print pdfpagecount =only
- (.) = flush
- } if
- } {
- %% validate string contents, check for digit comma or minus
- dup
- {
- dup 44 eq not {
- dup 45 eq not {
- dup 48 lt 1 index 57 gt or {
- /runpdfpagerange cvx /syntaxerror signalerror
- } if
- } if
- } if
- pop
- }
- forall
- /PDFPageList pdfpagecount 1 add array def
- {
- (,) search {
- %% We now have (post) (,) (pre)
- exch pop %% get rid of the (,), leave the (post) as the string for the next iteration, deal with the section up to the comma
- (-) search {
- %% Now we have (end) (-) (start)
- exch pop %% get rid of the minus (end) (start)
- 0 exch {48 sub exch 10 mul add} forall
- %% Make sure the start of the range is inside the number of available pages
- dup pdfpagecount le {
- exch
- %% deal with a trailing '-' by replacing it with the number of pages in the file
- dup length 0 eq {
- pop pdfpagecount
- }{
- 0 exch {48 sub exch 10 mul add} forall
- } ifelse
- 1 exch %% start 1 end
- %% Make sure the end of the range is inside the number of available pages
- dup pdfpagecount gt {pop pdfpagecount} if
- {PDFPageList exch 1 put} for
- } {
- %% start of range invalid, drop this range.
- pop pop
- }ifelse
- }{
- %% no minus signs, must be a simple page number
- 0 exch {48 sub exch 10 mul add} forall
- %% ensure its in the valid range of pages
- dup pdfpagecount le {
- PDFPageList exch 1 put
- } {
- pop
- } ifelse
- } ifelse
- }{
- %% no commas separating pages, just the original string (), deal with its as a section, then exit the loop
- (-) search {
- %% Now we have (end) (-) (start)
- exch pop %% get rid of the minus (end) (start)
- 0 exch {48 sub exch 10 mul add} forall
- %% Make sure the start of the range is inside the number of available pages
- dup pdfpagecount le {
- exch
- %% deal with a trailing '-' by replacing it with the number of pages in the file
- dup length 0 eq {
- pop pdfpagecount
- }{
- 0 exch {48 sub exch 10 mul add} forall
- } ifelse
- 1 exch %% start 1 end
- %% Make sure the end of the range is inside the number of available pages
- dup pdfpagecount gt {pop pdfpagecount} if
- {PDFPageList exch 1 put} for
- } {
- %% start of range invalid, drop this range.
- pop pop
- }ifelse
- }{
- %% no minus signs, must be a simple page number
- 0 exch {48 sub exch 10 mul add} forall
- %% ensure its in the valid range of pages
- dup pdfpagecount le {
- PDFPageList exch 1 put
- } {
- pop
- } ifelse
- } ifelse
- exit %% done all the sections.
- } ifelse
- } loop
- QUIET not {
- (Processing pages ) print PageList =only
- (.) = flush
- } if
- } ifelse
- } ifelse
- 1 pdfpagecount
- }{
- /FirstPage where {
- pop FirstPage dup pdfpagecount gt {
- (\nRequested FirstPage is greater than the number of pages in the file: ) print
- pdfpagecount = flush
- } if
- } {
- 1
- } ifelse
- /LastPage where {pop LastPage pdfpagecount .min } { pdfpagecount } ifelse
- 1 index 1 index gt {
- ( No pages will be processed \(FirstPage > LastPage\).) = flush
- } {
- QUIET not {
- (Processing pages ) print 1 index =only ( through ) print dup =only
- (.) = flush
- } if
- } ifelse
- } ifelse
- }ifelse
- }ifelse
-} bind executeonly def
-
-/dopdfpages { % firstpage# lastpage# dopdfpages -
- /OLDPDF where {/OLDPDF get not} {//true} ifelse
- {
- newpdf_dopdfpages
- }
- {
- << /PDFScanRules //true >> setuserparams % set scanning rules for PDF vs. PS
- << /RenderTTNotdef systemdict
- /RENDERTTNOTDEF get >> setuserparams % Should we render TT /.notdef
- 1 exch
- {
- %% If we have a array of pages to render, use it.
- /PDFPageList where {
- pop dup PDFPageList exch get 1 eq
- }
- {//true} ifelse
-
- {
- dup /Page# exch store
- QUIET not { (Page ) print dup //== exec flush } if
- pdfgetpage
- dup //null ne {
- pdfshowpage
- } {
- PDFSTOPONERROR {
- /dopdfpages cvx /syntaxerror signalerror
- } {
- pop
- ( **** Error: Page #) pdfformaterror Page# 10 string cvs pdfformaterror
- ( not found.\n) pdfformaterror
- } ifelse
- } ifelse
- }{
- pop
- }ifelse
- } for
- % Indicate that the number of spot colors is unknown in case the next page
- % imaged is a PS file.
- currentpagedevice /PageSpotColors known { << /PageSpotColors -1 >> setpagedevice } if
- << /PDFScanRules //null >> setuserparams % restore scanning rules for PS
- } ifelse
-} bind executeonly def
-
-/runpdfend {
- /OLDPDF where {/OLDPDF get not} {//true} ifelse
- {
- newpdf_runpdfend
- }
- {
- RepairedAnError
- {
- printrepairederror
- } {
- Repaired { printrepaired } if
- } ifelse
- currentdict pdfclose
- end % temporary dict
- end % pdfdict
- end % GS_PDF_ProcSet
- PDFTopSave restore
- end % userdict
- 2 vmreclaim % couldn't hurt
- //EnablePageHandlerDevice exec
- } ifelse
-} bind executeonly def
-
currentdict /DisablePageHandlerDevice undef
currentdict /EnablePageHandlerDevice undef
@@ -1649,29 +1219,7 @@ currentdict /EnablePageHandlerDevice undef
} ifelse
} bind executeonly def
-% Copy selected subfiles to temporary files and return the file names
-% as a PostScript names to protect them from restore.
-% Currently, all PDF files in the Portfolio are extracted and returned.
-%
-% - pdf_collection_files [ /temp_file_name ... /temp_file_name
-/pdf_collection_files {
- mark
- Trailer /Root knownoget {
- dup /Collection oknown {
- /Names knownoget {
- /EmbeddedFiles knownoget {
- pdf_collection_names
- } if
- } if
- } {
- pop
- } ifelse
- } if
-} bind executeonly def
-
/runpdf { % <file> runpdf -
- /OLDPDF where {/OLDPDF get not} {//true} ifelse
- {
dup type /filetype eq
{
dup
@@ -1690,53 +1238,10 @@ currentdict /EnablePageHandlerDevice undef
{
( **** Error: Attempt to process something other than a file object in runpdf.\n) pdfformaterror
} ifelse
- }
- {
- %% Get the PDF filename (it *must* be a file even if it came from stdin it gets
- %% copied to a temporary file) and store it in pdfdict. We will use this for
- %% hashing fonts to detect if fonts with the same name are from different files.
- %%
- dup currentglobal exch //true setglobal .getfilename exch setglobal /InputPDFFileName exch //pdfdict 3 1 roll .forceput
- //runpdfbegin exec
- //pdf_collection_files exec
- dup mark eq {
- pop
- process_trailer_attrs
- //runpdfpagerange exec
- //dopdfpages exec
- //runpdfend exec
- } {
- //runpdfend exec
- ]
- (1 ) 10 string copy exch
- {
- dup type /filetype eq {
- //runpdfbegin exec
- dup /PortfolioPage exch def
- process_trailer_attrs
- //runpdfpagerange exec
- //dopdfpages exec
- //runpdfend exec
- closefile
- } {
- .namestring dup (r) file
- //runpdfbegin exec
- /PortfolioPage 2 index def
- process_trailer_attrs
- //runpdfpagerange exec
- //dopdfpages exec
- //runpdfend exec
- deletefile
- } ifelse
- } forall
- pop
- } ifelse
- } ifelse
} bind executeonly odef
-currentdict /pdf_collection_files .undef
-
end % systemdict
+
% Redefine the procedure that the C code uses for running piped input.
% It is OK to use { (%stdin) run } here, because a startjob cannot occur.
/.runstdin {
@@ -1744,3281 +1249,9 @@ end % systemdict
} bind executeonly def
end % userdict
-pdfdict begin
-
-% ======================== File parsing ======================== %
-
-% Read the cross-reference and trailer sections.
-
-% I believe the definitions here are only used when parsing the trailer
-% dictionary and cross-reference table. So, following on from bug 697351
-% we will validate the operands to /R here, because the trailer and xref
-% are comparatively small. Note that the bug does not expose a problem
-% here, but we probably ought to validate the operands. Of course, if
-% they are invalid, the PDF file is probably unreadable anyway.
-
-/traileropdict mark
- (<<) cvn { /dictlevelcount dictlevelcount 1 add store mark } bind executeonly
- (>>) cvn { { .dicttomark } stopped {
- ( **** Warning: File has unbalanced >> in trailer.\n) pdfformatwarning
- } if
- /dictlevelcount dictlevelcount 1 sub def
- dictlevelcount 0 eq { exit } if
- } bind executeonly
- ([) cvn { mark } bind executeonly % ditto
- (]) cvn dup load
-% /true true % see .pdfexectoken in pdf_base.ps
-% /false false % ibid.
-% /null null % ibid.
- /R {
- 1 index type /integertype eq 1 index type /integertype eq and {
- /resolveR cvx 3 packedarray cvx
- } {
- ( **** Error: indirect object reference \(R\) encountered with invalid arguments.) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- } bind executeonly % see Objects below
-.dicttomark readonly def
-
-% After reading entry count: skip whitespace, exit on a digit
-% (presumably the object offset, otherwise throw /syntaxerror
-/xref-char-dict <<
- 0 {} % \000
- 9 1 index % \t
- 10 1 index % \r
- 12 1 index % \f
- 13 1 index % \n
- 32 1 index % ' '
-
- 48 { exit } bind % '0'
- 49 1 index % '1'
- 50 1 index % '2'
- 51 1 index % '3'
- 52 1 index % '4'
- 53 1 index % '5'
- 54 1 index % '6'
- 55 1 index % '7'
- 56 1 index % '8'
- 57 1 index % '9'
- 116 { % 't'railer
- PDFfile 7 string .peekstring not { () } if
- dup /trailer eq {
- % Empty xref section
- pop exit
- } {
- ( **** Warning: Invalid string \() exch concatstrings
- (\) follows xref section header.\n) concatstrings
- pdfformatwarning
- /setxrefentry cvx /syntaxerror signalerror
- } ifelse
- } bind
->> readonly def
-
- % Read original version (pre PDF 1.5) of the xref table.
- % Note: The position is the location of 'xref'. The current PDFfile
- % position is just after the 'XREF'.
-/readorigxref % <pos> readorigxref <trailerdict>
- {
- pop % We do not need the position.
-
- % First we search this (and any Previous) trailers, looking for
- % the /Size of the xref. We use ths to initialise our storage
- % of xref and similar objects. This avoids us havign to continually
- % resize these objescts which is very wasteful, and leads to us
- % spending much time in memory amanagement.
- % Bug #696454
- PDFfile fileposition
- /dictlevelcount 0 def
- /TrailerSizeError //false def
- /TrailerSize 0 def
-
- {
- % Throw away the 'xref' data up to the trailer dictionary
- PDFfile 0 (trailer) /SubFileDecode filter flushfile
- % Now read the trailer dictionary
- PDFfile traileropdict .pdfrun
-
- dup /Size known {
- % If we have a /Size then use it and exit this loop
- /Size get /TrailerSize exch def
- exit
- }{
- dup /Prev known {
- % We don't have a Size, but we have a Previous, set up to read it.
- /Prev get PDFfile exch setfileposition
- }{
- % No size and no Prev with a Size. Fall back to resizing the xref as we go.
- pop
- (*** Warning: No trailer dictionary with a Size detected, xref processing will be dynamic and slower) pdfformatwarning
- /TrailerDict 0 def
- exit
- } ifelse
- }ifelse
- }loop
-
- % Initialise the objects with the detected Size.
- TrailerSize growPDFobjects
- PDFfile exch setfileposition
- 0 % Initialize xref table error counter
- //false % Have we seen at least one section entry in this xref ? Bug #694342
- { PDFfile token pop % first object # or trailer
- dup /trailer eq {
- %% check to see if we have seen at least an empty section for this xref
- pop {exit}
- {
- %% we have not seen any section entries in an xref, not even an empty section (xref 0 0)
- %% Bug 694342, treat this as an error and rebuild the xref.
- /setxrefentry cvx /syntaxerror signalerror
- } ifelse
- }
- {
- %% remove the boolean telling us if we have a section or not, leaving the first object number
- exch pop
- } ifelse
- PDFfile token pop % entry count
-
- % remaining must be whitespace only (otherwise this xref Size was invalid.
- { PDFfile (0) .peekstring not { pop exit } if
- 0 get //xref-char-dict exch .knownget {
- exec
- } {
- ( **** Warning: xref subsection header has extra characters.\n)
- pdfformatwarning
- /setxrefentry cvx /syntaxerror signalerror
- } ifelse
- PDFfile read { pop } { exit } ifelse
- } loop
- % This section might be adding new objects:
- % ensure that Objects and Generations are big enough.
- % stack: <err count> <first obj> <entry count>
- 2 copy add
- TrailerSize gt {
- TrailerSizeError not {
- /TrailerSizeError //true def
- PDFSTOPONERROR not {
- (**** Warning: Discovered more entries in xref than declared in trailer /Size\n) pdfformatwarning
- } {
- /readorigxref cvx /rangecheck signalerror
- } ifelse
- } if
- % We now know that the /Size was wrong. We could read the whole table
- % resizing on every section, but if there are a lot of sections we
- % end up spending lots of time in memory management (Bug #696454) so
- % instead add 64k to the first object number in the section. This will
- % waste some memory, but is faster in ths case.
- 1 index 65534 add dup /TrailerSize exch def
- growPDFobjects
- } if
- { % stack: <err count> <obj num>
- % Read xref line
- PDFfile 20 string readstring pop % always read 20 chars.
- token pop % object position
- exch token pop % generation #
- exch token pop % n or f
- exch % stack: <err count> <obj#> <loc> <gen#> <tag> <remainder of line>
- % check to make sure trailing garbage is just white space
- //false 1 index { 32 gt or } forall {
- 6 -1 roll 1 add 6 1 roll % bump error count on garbage
- dup (\n) search {
- exch pop exch pop
- } {
- (\r) search {
- exch pop exch pop
- } if
- } ifelse
- length
- PDFfile fileposition exch sub PDFfile exch setfileposition
- } if
- pop % Stack: <err count> <obj#> <loc> <gen#> <tag>
- dup /n eq { % xref line tag is /n
- pop % pop dup of line tag
- 1 index 0 eq {
- ( **** Warning: considering '0000000000 XXXXX n' as a free entry.\n)
- pdfformatwarning
- } {
- 0 3 1 roll % Set ObjectStream object number = 0
- //false setxrefentry % Save xref entry, don't change existing entries
- 3 -1 roll pop % Remove ObjectStream object onumber
- } ifelse
- }
- { % xref line tag was not /n
- /f ne % verify that the tag was /f
- { /setxrefentry cvx /syntaxerror signalerror
- } {
- % Bug #703214 has a invalid initial xref table. The table entries are correct
- % but the subsection begins 1 7 instead of 0 7, which means the initial entry is
- % declared as object 1 instead of object 0. The file is incrementally updated
- % many times and every object *except* object 1 is redefined. Object 1 is
- % therefore defined as free and having an offset of 0. Acrobat can open this
- % without complaint! Because the PDF header is a comment line it is skipped
- % so Acrobat must simply be ignoring the free flag. We can't easily detect
- % this, but we can check for the generation number being the canonical
- % head of the free list. If it is, and the object number we have is not
- % zero, then pretend its not free.......
- dup 65535 eq {
- 2 index 0 ne {
- 0 3 1 roll
- //false setxrefentry
- 3 -1 roll pop
- } if
- }if
- }ifelse
- } ifelse
- pop pop % pop <obj location> and <gen num>
- % stack: <err count> <obj num>
- 1 add % increment object number
- } repeat
- pop % pop <obj #>
- //true % We have seen at least one entry in an xref section Bug #694342
- } loop
- 0 ne {
- ( **** Warning: length of some xref entries is not equal to 20 bytes.\n)
- pdfformatwarning
- } if
- PDFfile traileropdict .pdfrun
- } bind executeonly def
-
-currentdict /xref-char-dict undef
-
- % This dicitonary is used to read the xref dictionary. It should work for
- % reading any dictionary. dictlevelcount must contain 0.
-/xrefopdict mark
- (<<) cvn { /dictlevelcount dictlevelcount 1 add def mark } bind executeonly
- (>>) cvn { .dicttomark /dictlevelcount dictlevelcount 1 sub def
- dictlevelcount 0 eq { exit} if } bind executeonly
- ([) cvn { mark } bind executeonly % ditto
- (]) cvn dup load
-% /true true % see .pdfexectoken in pdf_base.ps
-% /false false % ibid.
-% /null null % ibid.
- /R { /resolveR cvx 3 packedarray cvx } bind executeonly % see Objects below
-.dicttomark readonly def
-
-% Get a variable length positive integer value from a stream. A value
-% of zero is returned if the count is zero.
-/getintn { % <stream> <count> getintn int
- 0 exch { 256 mul 1 index read pop add } repeat
- exch pop % Discard stream
-} bind executeonly def
-
-% This array contains handlers for processing the different types of
-% entries in the XRef stream.
-% Stack: <Xrefdict> <xref stream> <Index array> <pair loc> <obj num>
-% <field 2> <field 3>
-% The handlers leave the stack unchanged.
-/xref15entryhandlers [
- { % XRef entry type 0 - free or f type xref entry
-% (free ) print
-% (obj num: ) print 2 index pdfstring cvs print ( ) print
-% (loc: ) print 1 index pdfstring cvs print ( ) print
-% (gen: ) print dup === flush
- } bind executeonly % Do nothing for free xref entries
- % XRef entry type 1 - normal or n type xref entry
- { % field 2 = obj loc, field 3 = gen num
-% (normal ) print
-% (obj num: ) print 2 index pdfstring cvs print ( ) print
-% (loc: ) print 1 index pdfstring cvs print ( ) print
-% (gen: ) print dup === flush
- 0 3 1 roll % set stream number = 0
- //false setxrefentry
- 3 -1 roll pop % remove stream number
- } bind executeonly
- % XRef entry type 2 - compressed object type xref entry
- { % field 2 = object stream num, field 3 = index into object stream
-% (Compressed objects: ) print
-% (obj num: ) print 2 index pdfstring cvs print ( ) print
-% (field 2: ) print 1 index pdfstring cvs print ( ) print
-% (field 3: ) print dup === flush
- 0 //false setxrefentry pop % set generation number = 0
- } bind executeonly
-] def
-
- % Read the PDF 1.5 version of the xref table.
- % Note: The position is the location of the start of the dictionary object
- % In PDF 1.5, the XRef dictionary also serves as the trailer dictionary
-/readpdf15xref % <pos> readpdf15xref <trailerdict>
- {
- /Classic-xref //false store
- PDFfile exch setfileposition % move to start of object
- % Get object number, revision, and 'obj' and discard
- //false PDFfile token {
- type /integertype eq {
- PDFfile token {
- type /integertype eq {
- PDFfile token {
- /obj eq or
- } if
- } if
- } if
- } if
- } if
- not {
- /readpdf15xref cvx /syntaxerror signalerror
- } if
- % Get the XRef dicitionary
- /dictlevelcount 0 def PDFfile xrefopdict .pdfrun
- % Verify that we have an XRef dictionary
- dup /Type get /XRef ne {
- /readpdf15xref cvx /syntaxerror signalerror
- } if
- % Ensure that we we have room in the objects array, etc.
- dup /Size get 1 index /Index .knownget {
- %% if we have a /Index, remember to add the starting index on to the size
- dup 0 get 3 -1 roll add exch
- %% Get the staring index and number of entries from the Index array
- %% add them, and see if the result is larger than the starting index plus
- %% Size entry (yes they are *supposed* to be consistent.....)
- %% Bug #696365
- dup 0 get exch 1 get add 2 copy gt {
- pop
- }{
- exch pop
- } ifelse
- } if
- growPDFobjects
- % Create a stream for the XRef data
- PDFfile token pop pop % Skip over 'stream'
- dup stream //false resolvestream
- % Stack: <XRefdict> <xref stream>
- % The Index array defines the ranges of object numbers in the
- % XRef stream. Each value pair is consists of starting object
- % number and the count of consecutive objects.
- % Get the Index array, if present
- 1 index /Index .knownget not { % If no Index array ...
- [ 0 3 index /Size get ] % Default = [ 0 Size ]
- } if
- % Loop through the Index array
- 0 2 2 index length 1 sub {
- % Get start and end of object range
- 2 copy get % Start of the range
- dup 3 index 3 index 1 add get % Number of entries in range
- % Loop through the range of object numbers
- add 1 sub 1 exch { % Form end of range, set increment = 1
- % Stack: <Xrefdict> <xref stream> <Index array> <pair loc> <obj num>
- % Get xref parameters. Note: The number of bytes for each parameter
- % is defined by the entries in the W array.
- 4 index /W get aload pop % Get W array values
- % The first field indicates type of entry. Get first field value.
- % If the num. of bytes for field 1 is 0 then default field value is 1
- 3 -1 roll dup 0 eq { pop 1 } { 6 index exch getintn } ifelse
- % Get the handler for the xref entry type. We will execute the
- % handler after we get the other two field values.
- xref15entryhandlers exch get
- 3 -1 roll 6 index exch getintn % Get second field
- 3 -1 roll 6 index exch getintn % Get third field
- 3 -1 roll exec % Execute Xref entry handler
- pop pop pop % Remove field values and obj num
- } for % Loop through Xref entries
- pop % Remove Index array pair loc
- } for % Loop through Index array entries
- pop pop % Remove Index array and xref stream
- } bind executeonly def
-
-% Read the cross-reference table.
-% <pos> is the position either from the startxref statement or the /Prev
-% entry in the prior trailer dictionary.
-/readxref % <pos> readxref <trailerdict>
- {
- PDFoffset add PDFfile exch
- % Check that the given location is within the file.
- dup PDFfilelen gt {
- ( **** Warning: Specified xref location is beyond end of file.\n)
- pdfformatwarning
- /readxref cvx /invalidaccess signalerror
- } if
- setfileposition
- % In some PDF files, this position actually points to
- % white space before the xref line. Skip over this here.
- {
- PDFfile fileposition PDFfile read pop 32 gt { exit } if pop
- } loop
- dup % Make copy of the file position (before last char was read).
- PDFfile exch setfileposition
- % The PDF specification says that the 'xref' must be on a line
- % by itself. The code here formerly used readline and linene to
- % check this. However, Acrobat Reader only requires the line to
- % begin with 'xref', and there are enough applications producing
- % non-compliant PDF files that we have to do this too.
- PDFfile pdfstring 0 4 getinterval readstring pop
- (xref) eq
- {
- readorigxref % 'xref' -> original xref table
- % if hybrid-reference PDF, also fetch the entries
- % found in the XRef stream pointed by /XRefStm
- dup /XRefStm knownoget {
- %% Bug #695883 the test file has an XRefStm which points beyond the end of the file.
- %% We check that here and simply fall back to thje classic xref if this error occurs.
- dup PDFfilelen lt{
- PDFSTOPONERROR not {
- mark exch {readpdf15xref pop} stopped
- {
- ( **** Error: This hybrid file's XRefStm does not point to a valid stream.\n Ignoring error, output may be incorrect.\n) pdfformaterror
- } if
- cleartomark
- } {
- readpdf15xref pop
- } ifelse
- } {
- ( **** Error: This hybrid file's XRefStm points beyond the end of file.\n Ignoring error, output may be incorrect.\n) pdfformaterror
- pop
- }ifelse
- } if
- }
- { readpdf15xref } % otherwise assume PDF 1.5 xref stream
- ifelse
- } bind executeonly def
-
-% Open a PDF file and read the header, trailer, and cross-reference.
-/pdfopen { % <file> pdfopen <dict>
- /OLDPDF where {/OLDPDF get not} {//true} ifelse
- {
- newpdf_pdfopen
- }
- {
- % Color space substitution in PDF is handled somewhat differently
- % than in PostScript. A given device color space will be substituted
- % if the corresponding "Default..." entry exists in the Page's
- % Resource dictionary (which might be inhereted); there is no
- % UseCIEColor to enable/disable color mapping.
- %
- % This behavior is achieved by always setting UseCIEColor to true
- % in the page device dictionary. If the value of this parameter was
- % originally false (i.e.: the output device does not perform color
- % space substitution by default), the instances DefaultGray,
- % DefaultRGB, and DefaultCMYK of the (local) ColorSpace category
- % are redefined to be DeviceGray, DeviceRGB, and DeviceCMYK,
- % respectively. This is not done if UseCIEColor is true by default,
- % as in that case color substitution is presumably desired even
- % if the file does not request it.
- currentpagedevice /UseCIEColor .knownget dup { pop } if not
- { .currentglobal //false .setglobal
- /DefaultGray { /DeviceGray } cvlit /ColorSpace defineresource pop
- /DefaultRGB { /DeviceRGB } cvlit /ColorSpace defineresource pop
- /DefaultCMYK { /DeviceCMYK } cvlit /ColorSpace defineresource pop
- .setglobal
- }
- if
- pdfopenfile begin
- pdfopencache
- currentdict end
- } ifelse
-} bind executeonly def
-
-/process_trailer_attrs { % - process_trailer_attrs -
- writeoutputintents
- .writepdfmarks {
- % Copy bookmarks (outline) to the output.
- Trailer /Root knownoget {
- /Outlines knownoget {
- /NO_PDFMARK_OUTLINES where {pop NO_PDFMARK_OUTLINES not}{//true}ifelse
- {
- dup /First known {
- 100 dict exch %% dictionary for detecting circular references
- /First get dup type /packedarraytype eq { %% << >> {} or << >>
- dup 0 get dup %% << >> {} object_num object_num
- 3 index 3 1 roll %% << >> {} << >> object_num object_num
- put
- oforce
- } if
-
- dup type /dicttype eq {
- {
- dup
- /Next known {
- dup /Next get %% << >> <</Next...>> {} or << >>
- dup type /packedarraytype eq {
- dup 0 get %% << >> <</Next....>> {} object_num
- dup 4 index exch known {
- (\n **** ERROR: Circular reference detected in Outlines,\n) pdfformaterror
- ( terminating Outline processing.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- %% << >> <</Next....>> {} object_num
- pop pop dup /Next undef %% << >> <<.....>>
- writeoutline exit
- } if
- %% << >> <</Next....>> {} object_num
- dup 3 index 3 1 roll put %% << >> <</Next....>> {}
- oforce
- } if
- exch writeoutline %% << >> </Next object>
- dup type /dicttype eq not
- {pop exit} if
- } {
- writeoutline exit
- }ifelse
- } loop
- pop
- }
- {pop pop} ifelse
- }{
- pop
- }ifelse
- } {
- pop
- }ifelse
- } if
- } if
- count /pdfemptycount exch def
- Trailer /Info {knownoget} stopped {
- ( **** Error: Unable to read Info dictionary from Trailer, Info will not be preserved.\n) pdfformaterror
- count pdfemptycount sub {pop} repeat
- /emitProducer where {/emitProducer //false put} if
- }
- {
- {
- %
- % Bug #700820, if the Info dictionary isn't a dictionary, then don't try to use it....
- %
- dup type /dicttype eq {
- mark exch
- { /Author /Creator /Title /Subject /Keywords
- % /Producer is Ghostscript; /CreationDate is now; /ModDate is also now.
- } {
- 2 copy knownoget { 3 -1 roll } { pop } ifelse
- } forall
- pop
- dup mark ne { {/DOCINFO pdfmark} stopped {cleartomark} if } { pop } ifelse
- }{
- pop
- ( **** Error: The Info dictionary is not a dictionary, Info will not be preserved.\n) pdfformaterror
- count pdfemptycount sub {pop} repeat
- /emitProducer where {/emitProducer //false put} if
- } ifelse
- } if
- } ifelse
- } if
- % Initialize OC groups
- Trailer /Root knownoget {
- /OCProperties knownoget {
- % By default, OCGs are 'on'; mark only 'off' OCGs.
- % If, contrary to the spec, BaseState is OFF, mark all OCGs
- % and unmark ON ones. Bug 691491.
- dup /OCGs knownoget not { {} } if exch
- /D knownoget {
- dup /BaseState knownoget { /OFF eq } { //false } ifelse {
- ( **** Warning: Default viewing OC config dictionary has /BaseState /OFF\n)
- pdfformatwarning
- 1 index {
- oforce dup type /dicttype eq {
- /OFF 0 put
- } {
- pop
- } ifelse
- } forall
- /ON knownoget {
- { oforce dup type /dicttype eq {
- /OFF undef
- } {
- pop
- } ifelse
- } forall
- } if
- } {
- /OFF knownoget {
- { oforce dup type /dicttype eq {
- /OFF 0 put
- } {
- pop
- } ifelse
- } forall
- } if
- } ifelse
- } if
- pop
- } if
- } if
-
- % Enumerate all AcroForm fields and link all separate widgets
- % to the parent field.
- Trailer /Root knownoget {
- /AcroForm knownoget {
- %% If we don't have a NeedAppearances entry, treat as if true.
- %% We know Acrobat always regenerates all annotations.
- dup /NeedAppearances knownoget not { //true } if {
- /NeedAppearances //true def
- dup
- /Fields knownoget {
- { oforce
- %% Make sure the entry from the Fields array is a dictionary
- %% Bug #692447.pdf has an array of nulls.
- dup type /dicttype eq {
- link_widget_annots
- }if
- pop
- } forall
- } if
- pop
- } {
- pop
- } ifelse
- } if
- } if
-
- % Use OutputIntent ICC profile
- systemdict /UsePDFX3Profile .knownget {
- dup //false eq {
- pop
- } {
- dup //true eq { pop 0 } if
- dup type /integertype eq {
- Trailer /Root oget /OutputIntents knownoget {
- dup length 2 index le % i [] bool
- 2 index 0 lt or {
- pop pop
- (Source file has no OutputIntent with this number.\n)
- } {
- exch oget dup type /dicttype ne { pop << >> } if
- /DestOutputProfile knownoget {
- [ /ICCBased 3 -1 roll ] ICCBased-resolve
- 1 get .set_outputintent
- ()
- } {
- (This OutputputIntents dictionary has no profile.\n)
- } ifelse
- } ifelse
- } {
- pop (File has no /OutputIntents attribute\n)
- } ifelse
- } {
- pop (UsePDFX3Profile must be a boolean or an integer.\n)
- } ifelse
- dup () eq {
- pop
- } {
- ( **** ) stderrprint stderrprint
- } ifelse
- } ifelse
- } {
- % If the user told us to use a named OutputIntent
- systemdict /UseOutputIntent .knownget {
- cvn
- Trailer /Root oget /OutputIntents knownoget {
- {
- dup /OutputConditionIdentifier get cvn
- dup /Custom eq {
- pop
- dup /Info get cvn
- }if
- 2 index eq {
- %% Found the required OutputIntent
- /DestOutputProfile knownoget {
- [ /ICCBased 3 -1 roll ] ICCBased-resolve
- 1 get .set_outputintent
- ()
- } if
- pop
- exit
- }{
- pop
- } ifelse
- }
- forall
- pop
- }{
- pop
- }ifelse
- } if
- }ifelse
- Trailer /Root knownoget { /PageLabels knownoget {
- %% Currenlty only the pdfwrite device can handle PageLabels
- %% because we deal with these using putparams, not pdfmarks
- %% This is because the pdfmark syntax can't handle all the
- %% possible page label formats in a PDF file!
- /WantsPageLabels /GetDeviceParam .special_op {
- pop pop
- .pdfpagelabels
- } {
- pop
- } ifelse
- } if
- } if
-} bind executeonly def
-
-% Verify that each entry in the xref table is pointing at an object with
-% the correct object number and generation number.
-/verify_xref % - verify_xref -
-{ PDFfilelen
- 1 1 Objects length 1 sub % stack: filesize 1 1 <number of objects - 1>
- { % Check if the object is free (i.e. not used). The values in
- % Generations is the generation number plus 1. If the value in
- % Generations is zero then the object is free.
- % Stack: <filesize> <obj num>
- Generations 1 index get % Get the genration number
- 0 ne { % Skip if object number is free
- ObjectStream 1 index get % Check if object is in objectstream
- 0 eq { % We only check objects not in an objectstream
- { % Use stop context since we may get an error if object is invalid
- dup Objects exch get % Get the object location
- PDFoffset add dup 3 index ge % Compare object location to file size
- { pop //true } % Rebuild if location not in file
- { PDFfile exch setfileposition % Go to the object location
- //true % Stack: <filesize> <obj num> <true>
- PDFfile token pop % Read object number from file
- 2 index eq { % Verify object number
- PDFfile token pop % Read generation number from file
- Generations 3 index % Get specified generaton number
- get 1 sub % Gen numbs are stored with 1 added.
- eq { % Verify generation number
- PDFfile token pop
- /obj eq { % Verify 'obj' text
- pop //false % We have valid object, do not rebuild
- } if
- } if
- } if
- } ifelse
- } //.internalstopped exec
- { //true } if % If we stop then we need to rebuild
- % Stack: <filesize> <obj num> <need rebuild flag>
- {
- ( **** Warning: File has an invalid xref entry: )
- pdfformatwarning
- pdfstring cvs pdfformatwarning
- (. Rebuilding xref table.\n) pdfformatwarning
- search_objects
- exit
- } if % If the entry is invalid
- } {
- % The object is in an object stream. We currently do not rebuild
- % objects in an object stream. So If we find one, then abort the
- % verification of the xref table entries.
- pop exit % Pop object number and then exit loop
- } ifelse % If not in an object stream
- } if % If object entry is not free
- pop % Remove object number
- } for
- pop % Remove the size of the file
-} bind odef
-
-/pdfopencache { % - pdfopencache -
- % Create and initialize some caches.
- /PageCount pdfpagecount def
- /PageNumbers PageCount 65534 .min dict def
- /PageIndex PageCount 65534 .min array def
-} bind executeonly def
-
-/pdfopenfile { % <file> pdfopenfile <dict>
- //pdfdict readonly pop % can't do it any earlier than this
- 32 dict begin
- /LocalResources 0 dict def
- /DefaultQstate //null def % establish binding
- /Printed where { pop } {
- % Guess whether the output device is a printer.
- /Printed currentpagedevice /OutputFile known def
- } ifelse
- % If the file name has an odd number of '%', it is either a request for
- % separate pages, or is invalid. In either case some marks can be omitted.
- currentpagedevice /OutputFile .knownget {
- //false exch {
- 37 eq xor
- } forall {
- /NO_PDFMARK_OUTLINES //true def
- /NO_PDFMARK_DESTS //true def
- } if
- } if
- /PSLevel1 where { pop } { /PSLevel1 //false def } ifelse
- % NB: PDFfile is used outside of the PDF code to determine that a
- % PDF job is being processed; to not change or hide this key.
- cvlit /PDFfile exch def
- /PDFsource PDFfile def
- /Repaired //false def
- /emitProducer //true def
- /RepairedAnError //false def
- /StreamRunAborted //false def
- /NeedAppearances //false def
- /ICCProfileNError //false def
- currentglobal //true .setglobal globaldict begin
- /UndefProcList 0 dict def
- end .setglobal
- PDFfile dup 0 setfileposition
- 0 () /SubFileDecode filter % to avoid file closure
- pdfstring readstring pop
- (%PDF-) search not {/pdfopen cvx /syntaxerror signalerror} if
- length /PDFoffset exch def pop
- % some badly formed PDF's (Visioneer) have something other than EOL
- % after the version number. If we get an error, shorten the string
- % and try again.
- //false exch % error encountered
- { { cvr } stopped
- { exch pop //true exch 0 1 index length 1 sub dup 0 eq
- { pop 0 exit } if % exit if string now empty
- getinterval % trim character from right end and retry
- }
- { exch {
- ( **** Warning: PDF version number not followed by EOL.\n)
- pdfformatwarning
- }
- if exit
- }
- ifelse
- } loop
-
- /Classic-xref //true def
- /PDFversion exch def
- % Read the last cross-reference table.
- count /pdfemptycount exch def
- /Trailer << >> def % Initialize to an emptry dict.
- {initPDFobjects findxref readxref}
- PDFSTOPONERROR not {
- //.internalstopped exec {
- recover_xref_data % Read failed. Attempt to recover xref data.
- search_trailer % Search for the primary trailer
- //false % search_trailer sets up /Trailer, so don't run the code to do that...
- } {
- //true
- } ifelse
- } {
- exec //true
- } ifelse
-
- {
- /Trailer exch def % Save trailer dict after first xref table
- % Read any previous cross-reference tables. When we are done,
- % verify that the entries in the xref tables are valid if NoVerifyXref
- % is not defined.
- /PrevArray [] def % Empty array, we use this to detect circular /Prev entries in xref (see below)
- % For some reqason, leaving this on the stack messes up seom files.
- Trailer
- { /Prev knownoget not { % If no previous xref table then ...
- Classic-xref {
- /NoVerifyXref where { pop } { verify_xref } ifelse
- } if
- exit
- } if
-
- %% This code is used to detect circular references in xref tables. Every time
- %% we detect a /Prev in the xref, we check the given offset of the /Prev xref
- %% against a list of all previously encountered /Prev offsets. If we find that
- %% we have previously seen this one, we raise an error, stop processing the xref
- %% but carry on with the PDF file (unless PDFSTOPONERROR is true).
- //false exch PrevArray %% Used to determine if the looop found a circular ref
- { %% //false offset 'array entry'
- 1 index eq {
- exch pop //true exch %% We've seen this offset before, pop the false and replace with true
- exit %% //true offset
- } if
- } forall
-
- exch %% [...] offset bool
- {
- (\n **** Error: Circular /Prev entry while reading xref.\n Aborting xref read, output may be incorrect.\n)
- pdfformaterror
- PDFSTOPONERROR {
- /readxref cvx /syntaxerror signalerror
- } if
- pop exit %% [...] and then exit this loop
- } if
-
- PrevArray dup %% offset [...] [...]
- length 1 add array %% offset [...] [ ]
- dup 3 1 roll %% offset [ ] [...] [ ]
- copy pop %% offset [... ]
- dup dup length 1 sub %% offset [... ] [... ] index
- 3 index %% offset [... ] [... ] index offset
- put /PrevArray exch def
-
- { readxref }
- PDFSTOPONERROR not {
- //.internalstopped exec {
- recover_xref_data % Read failed. Attempt to recover xref data.
- /PrevArray where {/PrevArray undef} if %% remove the array we were using to detect circular references
- exit % Exit loop since recover gets all obj data.
- } if % If readxref stopped
- } {
- exec
- } ifelse
- % The PDF spec. says that each trailer dict should contain the required
- % entries. However we have seen a PDF file that only has a Prev entry in
- % the initial trailer dict. Acrobat complains but it accepts these files.
- % To work with these files, we are copying any entries which we find in
- % a previous trailer dict which are not present in the initial dict.
- dup {
- Trailer 2 index known {
- pop pop % discard if key already present
- } {
- Trailer 3 1 roll put % add key if not present
- } ifelse
- } forall
- } loop % Loop to previous trailer
- /PrevArray where {/PrevArray undef} if %% remove the array we were using to detect circular references
- } if
-
- /NumObjects Objects length def % To check that obj# < NumObjects
-
- % Scan numbers in the range 2147483648..4294967295 in Encrypt dictionary
- % as unsigned integers for compatibility with Acrobat Reader. Bug 689010.
- << /PDFScanUnsigned //true >> setuserparams
- { Trailer /Encrypt knownoget {
- pop
- pdf_process_Encrypt % signal error
- } if
- } stopped
- << /PDFScanUnsigned //false >> setuserparams
- { stop } if
-
- % Check for recursion in the page tree. Bug 689954, MOAB-06-01-2007
- % Make sure that the operand stack is cleaned up in case there's
- % an error and we ignore it (bug #700953)
- /StackMarkVerifyPageTree
- verify_page_tree
- /StackMarkVerifyPageTree ClearToKey
- currentdict end
- } bind executeonly def
-
-%% Executing token on a file will close the file if we reach EOF while
-%% processing. When repairing broken files (or searching for startxref
-%% and the xref offset) we do *NOT* want this to happen, because that
-%% will close PDFfile and we don't have the filename to reopen it.
-/token_no_close { %% -file- token_no_close <any> true | false
- dup type /filetype eq {
- <<
- /EODCount 2 index bytesavailable %% fix data length at underlying bytes
- /EODString () %% make sure filter passes that many bytes, no EOD
- /CloseSource //false %% Be sure, tell the filter not to close the source file
- >>
- /SubFileDecode filter dup %% -filter- -filter-
- token { %% -filter- <any> true | false
- %% token returned a value
- exch %% <any> filter
- closefile %% <any>
- //true %% <any> true
- }{
- %% token didn't find a value
- closefile %% -
- //false %% false
- } ifelse
- } {
- token
- } ifelse
-} bind executeonly def
-
-% Look for the last (startxref) from the current position
-% of the file. Return the position after (startxref) if found or -1 .
-/find-startxref { % <file> find_eof <file> <position>
- -1
- { 1 index dup 0 (startxref) /SubFileDecode filter flushfile
- bytesavailable 9 lt { exit } if
- pop dup fileposition
- } loop
-} bind executeonly def
-
-% Search for the last 'startxfer' and read a following token, which
-% must be a number. Don't pay any attention to %%EOF because it's
-% often mangled.
-% There seems to be no limit on the amount of garbage that can be
-% appended to the PDF file. Current record (60K) belongs to
-% PDF-Out (v 2.0 - 35). We start the search from the last 1024
-% bytes and continue from the beginning of the file.
-/findxref { % - findxref <xrefpos>
- PDFfile dup dup dup 0 setfileposition bytesavailable
- dup /PDFfilelen exch def
- % Find the last %%EOF string (within 1024 bytes)
- 1024 sub PDFoffset .max
- setfileposition find-startxref % file pos|-1 % search the last 1024 bytes
- dup 0 le {
- pop
- dup PDFoffset setfileposition find-startxref % search from the beginnibg
- dup 0 le {
- ( **** Error: Cannot find a 'startxref' anywhere in the file.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- /findxref cvx /syntaxerror signalerror
- } if
- } if
- 2 copy setfileposition
- pop token_no_close not { //null } if
- dup type /integertype ne {
- ( **** Error: invalid token after startxref.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- /findxref cvx /syntaxerror signalerror
- } if
-} bind executeonly def
-
-/stderrfile (%stderr) (w) file def
-/stdoutfile (%stdout) (w) file def
-
-/stderrprint { % <string> stderrprint -
- //stderrfile dup 3 -1 roll writestring flushfile
-} bind executeonly def
-
-/stdoutprint { % <string> stderrprint -
- //stdoutfile dup 3 -1 roll writestring flushfile
-} bind executeonly def
-
-/pdfformaterror { % <string> pdfformaterror -
- stdoutprint
- /Repaired //true store
- /RepairedAnError //true store
-} bind executeonly def
-
-/pdfformatwarning { % <string> pdfformaterror -
- QUIET not {stdoutprint}{pop}ifelse
- /Repaired //true store
- PDFSTOPONWARNING {/warning cvx /undefined signalerror} if
-} bind executeonly def
-
-/knownoget_safe
-{ 2 copy knownoget { 3 1 roll pop pop //true } { pop pop //false } ifelse
-} odef
-
-/printProducer {
- Trailer /Info { knownoget_safe } stopped { pop pop //false } if
-
- {
- /emitProducer where {/emitProducer get}{//true} ifelse
- {
- /Producer knownoget not { //null } if
- }{
- pop //null
- } ifelse
- } {
- //null
- } ifelse
-
- dup //null eq {
- pop
- } {
- ( **** The file was produced by: \n **** >>>> ) stderrprint
- % Handle a Unicode Producer.
- (\376\377) anchorsearch {
- pop dup length 2 idiv string 0 1 2 index length 1 sub {
- % Stack: origstr newstr i
- 1 index exch 3 index 1 index 2 mul 1 add get put
- } for exch pop
- } if
- stderrprint
- ( <<<<\n) stderrprint
- } ifelse
-} bind executeonly def
-% The UndefProcList collects noisy warnings.
-% This gets rid of many multiple warnings from pdf_font.ps
-/printCollectedWarnings {
- UndefProcList length 0 gt {
- (\n **** Embedded font uses undefined procedure\(s\): ) stderrprint
- UndefProcList {
- exch .namestring stderrprint ( ) stderrprint
- =string cvs stderrprint ( times, ) stderrprint
- } forall
- (\n) stderrprint
- } if
-} bind executeonly def
-
-/printrepaired {
- QUIET not
- {
- printCollectedWarnings
- (\n **** This file had errors that were repaired or ignored.\n)
- stdoutprint
- printProducer
- ( **** Please notify the author of the software that produced this\n)
- stdoutprint
- ( **** file that it does not conform to Adobe's published PDF\n)
- stdoutprint
- ( **** specification.\n\n)
- stdoutprint
- } if
-} bind executeonly def
-
-/printrepairederror {
- QUIET not
- {
- printrepaired
- ( **** The rendered output from this file may be incorrect.\n)
- stdoutprint
- } if
-} bind executeonly def
-
-% Write the outline structure for a file. Uses linkdest (below).
-% omit links to pages that don't exist.
-/writeoutline % <outlinedict> writeoutline -
- { mark
- 0 2 index /First knownoget
- { { exch 1 add exch /Next knownoget not { exit } if } loop }
- if
- % stack: dict mark count
- dup 0 eq
- { pop 1 index }
- { 2 index /Count knownoget { 0 lt { neg } if } if
- /Count exch 3 index
- }
- ifelse
- {
- dup /A knownoget {
- dup /URI known {
- /A mark 3 2 roll % <<>> /A [ <<action>>
- { oforce } forall
- .dicttomark
- 3 2 roll
- }
- {
- dup /S knownoget {
- %% Because we process GoTo Destinations into absolute references in the PDF file
- %% we need to resolve the /D or /Dest. However, we must *not* do this for
- %% GoToR Destinations because (obviously) those are in a different file and
- %% we cannot resolve them into absolute references. We don't need to anyway
- %% because that file must already have a named destination.
- dup /GoTo eq {
- pop
- dup /D knownoget {
- exch pop exch dup length dict copy dup /Dest 4 -1 roll put
- } if
- }{
- dup /GoToR eq {
- pop /A mark % <<..action dict..>> /A [
- 3 2 roll % /A [ <<..action dict..>>
- { oforce } forall
- .dicttomark
- 3 2 roll
- }{
- dup /Launch eq {
- pop /A mark % <<..action dict..>> /A [
- 3 2 roll % /A [ <<..action dict..>>
- { oforce } forall
- .dicttomark
- 3 2 roll
- }{
- /Named eq {
- /N knownoget { % Assume /S /Named
- namedactions exch .knownget { exec } if
- } if
- } if
- } ifelse
- } ifelse
- } ifelse
- } if
- } ifelse
- } if
- linkdest
- } stopped
- {
- cleartomark % ignore this link
- ( **** Warning: Outline has invalid link that was discarded.\n)
- pdfformatwarning
- } {
- /Title knownoget {
- {/Title exch /OUT pdfmark} stopped {cleartomark} if
- } {
- cleartomark
- ( **** Warning: Outline without /Title attribute was discarded.\n)
- pdfformatwarning
- } ifelse
- }
- ifelse
- /First knownoget
- { { dup writeoutline /Next knownoget not { exit } if } loop }
- if
- } bind executeonly def
-
-% Close a PDF file.
-/pdfclose % <dict> pdfclose -
- { begin
- PDFfile closefile
- end
- } bind executeonly def
-
-% ======================== Page accessing ======================== %
-
-% Get a (possibly inherited) attribute of a page.
-/pget % <pagedict> <key> pget <value> -true-
- % <pagedict> <key> pget -false-
- {
- 2 copy knownoget
- { exch pop exch pop //true }
- {
- %% Check to see if there's a Parent
- 1 index
- 3 1 roll
- exch /Parent knownoget
- {
- %% If there is a Parent, check to see if this dictionary has a stored object number
- 3 -1 roll /.gs.pdfobj# .knownget {
- %% if it does, check the Parent as wwell
- 1 index /.gs.pdfobj# .knownget {
- %% Both have object numbers, are they the same (ie its self-referencing)
- eq {
- pop pop
- //false
- }{
- exch pget
- }ifelse
- }{
- pop exch pget
- }ifelse
- } {
- exch pget
- }ifelse
- }
- % finally see if the key is (misplaced) in the Root Catalog dict
- { exch pop dup Trailer /Root oget exch knownoget dup {
- 3 -1 roll ( **** Error: The /) pdfformaterror 50 string cvs pdfformaterror
- ( key is missing from the Page tree.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }
- { exch pop }
- ifelse
- }
- ifelse
- }
- ifelse
- } bind executeonly def
-
-/parent_obj_get { % /ResourceName pagedict /ObjType LocalResourceDir
- /ParentResources .knownget {
- dup 2 index .knownget {
- % Found ObjType directory
- 4 index .knownget {
- 0 get 5 1 roll pop pop pop pop
- } {
- parent_obj_get % not found -- check it's parent.
- } ifelse
- } {
- parent_obj_get % not found -- check it's parent.
- } ifelse
- } {
- pop pop 0
- } ifelse
-} bind executeonly def
-
-/obj_get { % /ResourceName pagedict /ObjType obj_get
- % success: /ResourceName objnumber
- % fail: /ResourceName /ResourceName 0
- LocalResources 1 index knownoget {
- dup 4 index .knownget {
- 0 get 5 1 roll pop pop pop pop
- } {
- pop pop pop 0
- } ifelse
- } {
- % Not in LocalResources. Try Page Resources.
- 1 index /Resources pget {
- 1 index knownoget {
- dup 4 index known {
- 3 index get
- 0 get 4 1 roll pop pop pop
- }{
- % Not in Page Resources, recursively try ParentResources as a last resort
- pop % page Resources
- LocalResources parent_obj_get
- }ifelse
- }{
- % No Page Resources, recursively try ParentResources as a last resort
- LocalResources parent_obj_get
- } ifelse
- } {
- % No Page Resources, recursively try ParentResources as a last resort
- pop pop pop 0
- }ifelse
- }ifelse
-}bind executeonly def
-
-% Get the value of a resource on a given page.
-/rget { % <resname> <pagedict> <restype> rget <value> -true-
- % <resname> <pagedict> <restype> rget -false-
- LocalResources 1 index knownoget {
- 3 index knownoget
- } {
- //false
- } ifelse {
- exch pop exch pop exch pop //true
- } {
- 1 index /Resources pget {
- 1 index knownoget { 3 index knownoget } { //false } ifelse
- } {
- //false
- } ifelse {
- 4 1 roll pop pop pop //true
- } {
- countdictstack array dictstack
- //false 5 1 roll
- dup length 1 sub -1 4 { % false /Name <<>> /Type [<<gstate>>] i
- 1 index exch get % false /Name <<>> /Type [] <<gstate>>
- /FormResDict .knownget { % false /Name <<>> /Type [] <<res>>
- 2 index knownoget { % false /Name <<>> /Type [] <<type_dict>>
- 4 index knownoget { % false /Name <<>> /type [] <<res_dict>>
- ( **** Warning: resource was found only in an external (parent) context.\n) pdfformatwarning
- //true 7 2 roll % <<res_dict>> true false /Name <<>> /Type []
- pop exit
- } if
- } if
- } if
- } for
- pop pop pop pop
- } ifelse
- } ifelse
-} bind executeonly def
-
-% Get the total number of pages in the document.
-/pdfpagecount % - pdfpagecount <int>
- {
- Trailer /Root knownoget {
- /Pages knownoget {
- dup /Count knownoget {
- dup type /integertype eq { dup 0 le } { //true } ifelse {
- pop
- dup /Kids knownoget {
- pop
- ( **** Warning: Invalid Page count.\n) pdfformatwarning
- % find the last page and use that as the Count
- 1 1 999999999 {
- dup pdffindpage?
- exch pop
- //null eq { exit } { pop } ifelse
- } for
- 1 sub % decrement to last page that we were able to find
- 2 copy /Count exch put
- } {
- 0 % return 0 and keep 0 page count.
- ( **** Warning: PDF document has no pages.\n) pdfformatwarning
- } ifelse
- } if
- exch pop
- } {
- dup /Type oget /Page eq {
- << exch 1 array astore /Kids exch /Count 1 /Type /Pages >>
- Trailer /Root oget /Pages 3 -1 roll put
- 1
- ( **** Warning: No /Pages node. The document /Root points directly to a page.\n)
- pdfformatwarning
- } {
- ( **** Warning: Page count not found; assuming 1.\n)
- pdfformatwarning
- pop 1
- } ifelse
- } ifelse
- } {
- 0
- }ifelse
- }{
- 0
- } ifelse
- } bind executeonly def
-
-% Check for loops in the 'page tree' but accept an acyclic graph.
-% - verify_page_tree -
-/verify_page_tree {
- % Run the verification inside a 'stopped' context. Bug #700953
- % has a peculiarly constructed page tree, and a huge number of
- % pages, which recurses to a depth beyond the level we can cope
- % with on the exec stack. If we ignore that error then we can
- {
- Trailer /Root knownoget {
- /Pages knownoget {
- 10 dict begin
- /Count pdfpagecount def
- /verify_page_tree_recursive {
- Count 0 gt {
- dup 1 def
- dup /Kids knownoget {
- { oforce
- dup //null ne {
- currentdict 1 index known {
- ( **** Error: there's a loop in the Pages tree. Giving up.\n) pdfformaterror
- /verify_page_tree cvx /syntaxerror signalerror
- } if
- verify_page_tree_recursive
- } {
- pop
- } ifelse
- } forall
- } {
- /Count Count 1 sub def
- }ifelse
- currentdict exch undef
- } {
- pop
- ( **** Error: Too many pages in Page tree.\n) pdfformaterror
- } ifelse
- } def
- verify_page_tree_recursive
- end
- } if
- } if
- } stopped
- {
- %% Specific check for syntax error, in this case assume we found a loop in the Pages tree.
- %% (see above). Otherwise, just try to process the file anyway.
- $error /errorname get /syntaxerror eq {
- /verify_page_tree cvx /syntaxerror signalerror
- } {
- ( **** Error: Something went wrong while checking for recursion in the Page tree. Giving up checking.\n This PDF file may not terminate, if there is a loop in the Pages tree.\n) pdfformaterror
- } ifelse
- } if
-} bind executeonly def
-
-/pdffindpage? { % <int> pdffindpage? 1 null (page not found)
- % <int> pdffindpage? 1 noderef (page found)
- % <int> pdffindpage? 0 null (Error: page not found)
- Trailer /Root oget /Pages get
- { % We should be able to tell when we reach a leaf
- % by finding a Type unequal to /Pages. Unfortunately,
- % some files distributed by Adobe lack the Type key
- % in some of the Pages nodes! Instead, we check for Kids.
- dup oforce /Kids knownoget not { exit } if
- exch pop //null
- 0 1 3 index length 1 sub {
- 2 index exch get
- dup oforce
- dup //null eq {
- PDFSTOPONERROR {
- /pdffindpage? cvx /syntaxerror signalerror
- } {
- ( **** Error: Ignoring a null node in the Page tree.\n) pdfformaterror
- pop pop
- } ifelse
- } {
- dup /Kids known { /Count oget } { pop 1 } ifelse
- % Stack: index kids null noderef count
- dup 5 index ge { pop exch pop exit } if
- 5 -1 roll exch sub 4 1 roll pop
- } ifelse
- } for exch pop
- % Stack: index null|noderef
- dup //null eq { pop pop 1 //null exit } if
- } loop
-} bind executeonly def
-
-% Find the N'th page of the document by iterating through the Pages tree.
-% The first page is numbered 1.
-/pdffindpageref { % <int> pdffindpage <objref>
- dup pdffindpage?
- % Stack: index countleft noderef
- dup //null ne {
- 1 index 1 ne { pop pop /pdffindpage cvx /rangecheck signalerror } if
- exch pop
- PageIndex 2 index 1 sub 65533 .min 2 index oforce put
- PageNumbers 1 index oforce 3 index dup 65534 le
- { put }
- { pop pop pop } % don't store more than 65534 pagenumbers
- ifelse
- } {
- exch pop % return the //null
- }
- ifelse
- exch pop % pop the page number, return the object or null
-} bind executeonly def
-/pdffindpage { % <int> pdffindpage <pagedict>
- pdffindpageref oforce
-} bind executeonly def
-
-% Find the N'th page of the document.
-% The first page is numbered 1.
-/pdfgetpage % <int> pdfgetpage <pagedict>
- { PageIndex 1 index 1 sub dup 65533 lt
- { get }
- { pop pop //null }
- ifelse
- dup //null ne
- { exch pop oforce }
- { pop pdffindpage }
- ifelse
- } bind executeonly def
-
-% Find the page number of a page object (inverse of pdfgetpage).
-/pdfpagenumber % <pagedict> pdfpagenumber <int>
- { % We use the simplest and stupidest of all possible algorithms....
- PageNumbers 1 index .knownget
- { exch pop
- }
- { 1 1 PageCount 1 add % will give a rangecheck if not found
- { dup pdfgetpage oforce 2 index eq { exit } if pop
- }
- for exch pop
- }
- ifelse
- } bind executeonly def
-
-% Arrange the four elements that define a rectangle into a 'normal' order.
-/normrect_elems % <x1> <y1> <x2> <y2> normrect_elems <llx> <lly> <urx> <ury>
-{
- 4 { % Bug 693919
- dup type dup /integertype ne exch /realtype ne and {
- ( **** Error: replacing malformed number ') pdfformaterror pdfstring cvs pdfformaterror
- (' with 0.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- 0
- } if
- 4 1 roll
- } repeat
- exch 4 1 roll % <x2> <x1> <y1> <y2>
- 2 copy gt { exch } if % <x2> <x1> <lly> <ury>
- 4 2 roll 2 copy lt { exch } if % <lly> <ury> <urx> <llx>
- 4 1 roll exch % <llx> <lly> <urx> <ury>
-} bind executeonly def
-
-% Arrange a rectangle into a 'normal' order. I.e the lower left corner
-% followed by the upper right corner.
-/normrect % <rect> normrect <rect>
-{
- aload pop normrect_elems 4 array astore
-} bind executeonly def
-
-/fix_empty_rect_elems % </Name> <x1> <y1> <x2> <y2> fix_empty_rect_elems <x1> <y1> <x2'> <y2'>
-{ dup 3 index eq { //true } { 1 index 4 index eq } ifelse {
- pop pop pop pop
- ( **** Warning: File has an empty ) pdfformaterror pdfstring cvs pdfformaterror
- (. Using the current page size instead.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- 0 0 currentpagedevice /PageSize get aload pop
- } {
- 5 -1 roll pop
- } ifelse
-} bind executeonly def
-
-/boxrect % <llx> <lly> <urx> <ury> boxrect <x> <y> <w> <h>
- { exch 3 index sub exch 2 index sub
- } bind executeonly def
-/resolvedest { % <name|string|other> resolvedest <other|null>
- dup type /nametype eq {
- Trailer /Root oget /Dests knownoget {
- exch knownoget not { //null } if
- } {
- pop //null
- } ifelse
- } {
- dup type /stringtype eq {
- Trailer /Root oget /Names knownoget {
- /Dests knownoget {
- exch nameoget
- } {
- pop //null
- } ifelse
- } {
- pop //null
- } ifelse
- } if
- } ifelse
-} bind executeonly def
-
-% Procedures to do the necessary transformations of view destinations
-% <PDF2PS_matrix> <rot> <view> -- <view'>
-/viewdestprocs 8 dict dup begin
- /Fit { exch pop exch pop } bind executeonly def
- /FitH {
- aload length 2 lt {
- 1 array astore
- 3 1 roll pop pop
- }{
- 0 4 -1 roll 1 and 0 eq { exch } if
- 4 -1 roll transform exch pop
- 2 array astore
- } ifelse
- } bind executeonly def
- /FitV {
- aload length 2 lt {
- 1 array astore
- 3 1 roll pop pop
- }{
- 0 4 -1 roll 1 and 0 ne { exch } if
- 4 -1 roll transform pop
- 2 array astore
- } ifelse
- } bind executeonly def
- /FitB /Fit load def
- /FitBH /FitH load def
- /FitBV /FitV load def
- /XYZ {
- dup length dup 4 gt {
- pop /viewdestprocs cvx /rangecheck signalerror
- }{
- dup 4 eq {
- pop aload pop
- } {
- dup 3 eq {
- pop aload pop //null
- } {
- dup 2 eq {
- pop aload pop //null //null
- } {
- dup 1 eq {
- pop aload pop //null //null //null
- } {
- pop /viewdestprocs cvx /rangecheck signalerror
- } ifelse
- } ifelse
- } ifelse
- } ifelse
- } ifelse
- 3 1 roll
- 2 copy 7 -1 roll 1 and 0 ne { exch } if 4 2 roll % odd rotation switches x<->y
- 2 { dup //null eq { pop 0 } if exch } repeat % replace nulls with 0
- 7 -1 roll transform % transform coordinates
- 2 { 3 -1 roll //null eq { pop //null } if exch } repeat % put the nulls back
- 3 -1 roll
- 4 array astore
- } bind executeonly def
- /FitR {
- exch pop
- aload pop
- 2 { 5 index transform 4 2 roll } repeat normrect_elems
- 5 array astore
- exch pop
- } bind executeonly def
-end readonly def
-
-/linkdest { % <link|outline> linkdest
- % ([/Page <n>] /View <view> | ) <link|outline>
- dup /NewWindow knownoget {
- /NewWindow exch 3 -1 roll
- } if
- dup /F knownoget {
- /File exch 3 -1 roll
- } if
- dup /Dest knownoget
- {
- resolvedest
- dup type /dicttype eq { /D knownoget not { //null } if } if
- dup //null eq
- { pop }
- { dup 0 oget
- //false % don't have a page# and transformation matrix (yet)
- 1 index type /dicttype eq {
- 1 index /Type knownoget {
- /Page eq {
- pop % the "false" flag
- dup pdf_cached_PDF2PS_matrix exch
- dup /Rotate pget not { 0 } if cvi 90 idiv exch
- pdfpagenumber /CumulativePageCount where {pop CumulativePageCount}{0}ifelse add
- //true % now we have a page# and a transformation matrix
- } if
- } if
- } if
- % stack: <link|outline> <dest> ( <PDF2PS_matrix> <rot> <page#> true | <page> false )
- {
- /Page exch 6 2 roll
- % stack: [/Page <page#>] <link|outline> <dest> <PDF2PS_matrix> <rot>
- 3 -1 roll dup length 1 sub 1 exch getinterval /View 4 1 roll
- % stack: [/Page <page#>] <link|outline> /View <PDF2PS_matrix> <rot> <view>
- //viewdestprocs 1 index 0 get get exec
- 3 -1 roll
- } {
- dup type /integertype eq {
- /CumulativePageCount where {pop CumulativePageCount}{0}ifelse add
- /Page exch 1 add 4 2 roll
- } {
- pop
- } ifelse
- dup length 1 sub 1 exch getinterval /View exch 3 -1 roll
- } ifelse
- }
- ifelse
- }
- if
-} bind executeonly def
-
-
-%% Used to recursively check dictionaries for any /.gs.pdfobj# keys
-%% and remove them if so
-%% -any- /Removepdfobj# -any-
-
-/Removepdfobj#
-{
- dup type /dicttype eq {
- dup /.gs.pdfobj# known {
- dup /.gs.pdfobj# undef
- } if
- dup {Removepdfobj# 2 index 3 1 roll put} forall
- } if
-}bind executeonly def
-
-% <pagedict> mark ... -proc- <page#> <error>
-/namedactions 8 dict dup begin
- /FirstPage { 1 /CumulativePageCount where {pop CumulativePageCount}{0}ifelse add //false } bind executeonly def
- /LastPage { pdfpagecount /CumulativePageCount where {pop CumulativePageCount}{0}ifelse add //false } bind executeonly def
- /NextPage { counttomark 2 add index pdfpagenumber 1 add dup pdfpagecount gt exch /CumulativePageCount where {pop CumulativePageCount}{0}ifelse add exch} bind executeonly def
- /PrevPage { counttomark 2 add index pdfpagenumber 1 sub dup 1 lt exch /CumulativePageCount where {pop CumulativePageCount}{0}ifelse add exch} bind executeonly def
-end readonly def
-% <pagedict> <annotdict> -proc- -
-
-% **** The following procedure should not be changed to allow clients
-% **** to directly interface with the constituent procedures. GSview
-% **** and some Artifex customers rely on the pdfshowpage_init,
-% **** pdfshowpage_setpage, pdfshowpage_finish so all logic should be
-% **** implemented in one of those three procedures.
-/pdfshowpage % <pagedict> pdfshowpage -
- { dup /Page exch store
- pdfshowpage_init % <pagedict>
- pdfshowpage_setpage % <pagedict>
- pdfshowpage_finish % -
- } bind executeonly def
-
-/pdfpagecontents % <pagedict> pdfpagecontents <contents>
- { } bind executeonly def
-
-/pdfshowpage_init % <pagedict> pdfshowpage_init <pagedict>
- { /DSCPageCount DSCPageCount 1 add store
- } bind executeonly def
-
-/get_media_box { % <pagedict> get_media_box <box> <bool>
- /MediaBox pget {
- oforce_array
- dup length 4 eq {
- //true
- }
- {
- pop
- ( **** Error: Page has an invalid /MediaBox attribute. Using the current page size.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- [ 0 0 currentpagedevice /PageSize get aload pop ]
- //false
- }ifelse
- }
- {
- ( **** Error: Page has no /MediaBox attribute. Using the current page size.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- [ 0 0 currentpagedevice /PageSize get aload pop ] //false
- } ifelse
-} bind executeonly def
-
-/get_any_box { % <pagedict> get_any_box <box name> <box>
- //systemdict /UseBleedBox .knownget dup { and } if {
- dup /BleedBox pget {
- /BleedBox exch
- } if
- } if
- //systemdict /UseTrimBox .knownget dup { and } if {
- dup /TrimBox pget {
- /TrimBox exch
- } if
- } if
- dup type /arraytype ne {
- //systemdict /UseArtBox .knownget dup { and } if {
- dup /ArtBox pget {
- /ArtBox exch
- } if
- } if
- } if
- dup type /arraytype ne {
- //systemdict /UseCropBox .knownget dup { and } if {
- dup /CropBox pget {
- /CropBox exch
- } if
- } if
- } if
- dup type /arraytype ne {
- /MediaBox exch get_media_box pop
- } {
- oforce_elems % <<pdict>> /SomeBox x0 y0 x1 y1
- %% Complicated stuff. We need to use the 'Box' we identified (if any), but we
- %% need to clamp the boundaries of the 'Box' to the MediaBox. This appears to
- %% be what Acrobat does. The complication arises because the Box values don't
- %% have to be sensibly positive, its permissible to have the MediaBox set up
- %% so that it extends down and left instead of up and right. We take care of the
- %% content when we st up the CTM, but we do need to make sure that we clamp
- %% the BoundingBox, and that means we need to take direcitonality into account...
-
- 6 -1 roll get_media_box { % /SomeBox x0 y0 x1 y1 [MediaBox]
- aload pop % /SomeBox x0 y0 x1 y1 X0 Y0 X1 Y1
-
- %% Start with the width, get the X0 and X1 values of the MediaBox
- 3 index % /SomeBox x0 y0 x1 y1 X0 Y0 X1 Y1 X0
- 2 index % /SomeBox x0 y0 x1 y1 X0 Y0 X1 Y1 X0 X1
- gt {
- %% Media extends to left
- 4 -1 roll % /SomeBox x0 y0 x1 y1 Y0 X1 Y1 X0
- 8 -1 roll % /SomeBox y0 x1 y1 Y0 X1 Y1 X0 x0
- .min % /SomeBox y0 x1 y1 Y0 X1 Y1 mX0
- 7 1 roll % /SomeBox mX0 y0 x1 y1 Y0 X1 Y1
- exch % /SomeBox mX0 y0 x1 y1 Y0 Y1 X1
- 5 -1 roll % /SomeBox mX0 y0 y1 Y0 Y1 X1 x1
- .max % /SomeBox mX0 y0 y1 Y0 Y1 mX1
- 5 1 roll % /SomeBox mX0 mX1 y0 y1 Y0 Y1
- }{
- %% Media extends to right
- 4 -1 roll % /SomeBox x0 y0 x1 y1 Y0 X1 Y1 X0
- 8 -1 roll % /SomeBox y0 x1 y1 Y0 X1 Y1 X0 x0
- .max % /SomeBox y0 x1 y1 Y0 X1 Y1 mX0
- 7 1 roll % /SomeBox mX0 y0 x1 y1 Y0 X1 Y1
- exch % /SomeBox mX0 y0 x1 y1 Y0 Y1 X1
- 5 -1 roll % /SomeBox mX0 y0 y1 Y0 Y1 X1 x1
- .min % /SomeBox mX0 y0 y1 Y0 Y1 mX1
- 5 1 roll % /SomeBox mX0 mX1 y0 y1 Y0 Y1
- } ifelse
-
- %% Now deal with the height
- 2 copy % /SomeBox mX0 mX1 y0 y1 Y0 Y1 Y0 Y1
- gt {
- %% Media extends down
- exch % /SomeBox mX0 mX1 y0 y1 Y1 Y0
- 4 -1 roll % /SomeBox mX0 mX1 y1 Y1 Y0 y0
- .min % /SomeBox mX0 mX1 y1 Y1 mY0
- 3 1 roll % /SomeBox mX0 mX1 mY0 y1 Y1
- .max % /SomeBox mX0 mX1 mY0 mY1
- }{
- %% Media extends up
- exch % /SomeBox mX0 mX1 y0 y1 Y1 Y0
- 4 -1 roll % /SomeBox mX0 mX1 y1 Y1 Y0 y0
- .max % /SomeBox mX0 mX1 y1 Y1 mY0
- 3 1 roll % /SomeBox mX0 mX1 mY0 y1 Y1
- .min % /SomeBox mX0 mX1 mY0 mY1
- } ifelse
- exch % /SomeBox mX0 mX1 mY1 mY0
- 3 1 roll % /SomeBox mX0 mY0 mX1 mY1
- } {
- pop
- } ifelse
- 4 array astore % /SomeBox [mX0 mY0 mX1 mY1]
- } ifelse
-} bind executeonly def
-
-% Compute the matrix that transforms the PDF->PS "default" user space
-/pdf_PDF2PS_matrix { % <pdfpagedict> -- matrix
- matrix currentmatrix matrix setmatrix exch
- % stack: savedCTM <pdfpagedict>
- dup get_any_box
- % stack: savedCTM <pdfpagedict> /Trim|Crop|Art|MediaBox <Trim|Crop|Art|Media Box>
- oforce_elems normrect_elems fix_empty_rect_elems 4 array astore
- //systemdict /PDFFitPage known {
- PDFDEBUG { (Fiting PDF to imageable area of the page.) = flush } if
- currentpagedevice /.HWMargins get aload pop
- currentpagedevice /PageSize get aload pop
- % Adjust PageSize and .HWMargins for the page portrait/landscape orientation
- 2 copy gt % PageSize_is_landscape
- 7 index aload pop 3 -1 roll sub 3 1 roll exch sub exch
- 10 index /Rotate pget not { 0 } if cvi 90 idiv 1 and 0 ne { exch } if
- gt % Box_is_landscape
- xor % PageSize_is_landscape(or square) xor'ed with Box_is_lanscape suggests rotate
- 2 index 2 index eq not and { % don't rotate if Page is square
- 1 index 0 translate 90 rotate % add in a rotation
- PDFDEBUG { ( Rotating the page for best fit) = flush } if
- 2 copy ne {
- % rotate the .HWMargins
- 2 copy lt {
- 6 2 roll 4 -1 roll 6 -2 roll
- } {
- 6 2 roll 4 1 roll 6 -2 roll
- } ifelse
- % rotate the page dimensions
- exch
- } if
- } if
- 3 -1 roll sub 3 1 roll exch sub exch
- % stack: savedCTM <pdfpagedict> <Crop|Media Box> Xmin Ymin Xmax Ymax
- PDFDEBUG { ( Translate up by [ ) print 3 index =print (, ) print 2 index =print ( ]) = flush } if
- 3 index 3 index translate % move origin up to imageable area
- 2 index sub exch 3 index sub exch 4 2 roll pop pop
- % stack: savedCTM <pdfpagedict> [Box] XImageable YImageable
- 2 index aload pop 2 index sub exch 3 index sub exch 4 2 roll pop pop
- 5 index /Rotate pget not { 0 } if cvi 90 idiv 1 and 0 ne { exch } if
- % stack: savedCTM <pdfpagedict> [Box] XImageable YImageable XBox YBox
- 4 copy
- 3 -1 roll exch div 3 1 roll div .min
- % stack: savedCTM <pdfpagedict> [Box] XImageable YImageable XBox YBox scale
- PDFDEBUG { ( Scale by ) print dup = flush } if
- 5 -4 roll
- % stack: savedCTM <pdfpagedict> [Box] scale XImageable YImageable XBox YBox
- 3 index 2 index 6 index mul sub 2 div 3 index 2 index 7 index mul sub 2 div
- PDFDEBUG { ( Centering translate by [ ) print 1 index =print (, ) print dup =print ( ]) = flush } if
- translate pop pop pop pop
- } {
- //systemdict /NoUserUnit .knownget not { //false } if {
- 1
- } {
- 1 index /UserUnit knownoget {
- /PassUserUnit /GetDeviceParam .special_op {
- exch pop dup {
- [ /UserUnit 4 -1 roll .pdfputparams pop pop 1 exch
- } if
- }{
- //false
- }ifelse
-
- not {
- PDFDEBUG { (Scaling due to UserUnit by ) print dup = flush } if
- } if
- } {
- /PassUserUnit /GetDeviceParam .special_op {
- exch pop {
- [ /UserUnit 1 .pdfputparams pop pop
- } if
- 1
- }{
- 1
- } ifelse
- } ifelse
- } ifelse
- } ifelse
- % stack: savedCTM <pdfpagedict> [Box] scale
- dup scale
- % Rotate according to /Rotate
- aload pop boxrect
- {
- { pop pop }
- { -90 rotate pop neg 0 translate }
- { 180 rotate neg exch neg exch translate }
- { 90 rotate neg 0 exch translate pop }
- }
- 5 index /Rotate pget not { 0 } if cvi
- PDFDEBUG { dup 0 ne { (Rotating by ) print dup =print ( degrees.) = flush } if } if
- 90 idiv 3 and get exec
- % Now translate to the origin given in the Crop|Media Box
- exch neg exch neg translate
- % stack: savedCTM <pdfpagedict>
- pop
- matrix currentmatrix exch setmatrix
-} bind executeonly def
-
-% Cache the matrix that transforms the PDF->PS "default" user space
-% into <pdfpagedict> under the key //PDF2PS_matrix_key, then return it
-/PDF2PS_matrix_key (PDF->PS matrix) cvn def
-/pdf_cached_PDF2PS_matrix { % <pdfpagedict> -- <PDF2PS_matrix>
- dup //PDF2PS_matrix_key .knownget {
- exch pop
- } {
- dup dup pdf_PDF2PS_matrix //PDF2PS_matrix_key exch put
- //PDF2PS_matrix_key get
- } ifelse
-} bind executeonly def
-currentdict /PDF2PS_matrix_key undef
-
-/.pdfshowpage_Install { % <pagedict> [<prevproc>] .pdfshowpage_Install -
- 0 get exec
- pdf_cached_PDF2PS_matrix concat
-} bind executeonly def
-
-/pdfshowpage_setpage { % <pagedict> pdfshowpage_setpage <pagedict>
- 6 dict begin % for setpagedevice
- % Stack: pdfpagedict
- % This comment is no longer true, and is maintained here for history only:
- %
- % UseCIEColor is always true for PDF; see the comment in runpdf above
- %
- % We now test the page to see if it defines any Default* colour spaces and
- % only set UseCIEColor if it does. This prevents a spurious warning from
- % pdfwrite about not using UseCIEColor with pdfwrite.
- %
- pdfshowpage_detect_cspacesub {
- /UseCIEColor //true def
- } if
-
- % Only lock in Orientation if we need to for pdfmarks
- .writepdfmarks { /Orientation 0 def } if
- currentpagedevice
- % Stack: pdfpagedict currentpagedevicedict
- 1 index get_any_box
- % Stack: pdfpagedict currentpagedevicedict /BoxName [box]
- oforce_elems normrect_elems fix_empty_rect_elems boxrect 4 2 roll pop pop
- 3 index /Rotate pget not { 0 } if cvi 90 idiv 1 and 0 ne { exch } if
- % stack: pdfpagedict currentpagedevicedict boxwidth boxheight
- //systemdict /PDFFitPage known {
- % Preserve page size,
- % but choose portrait/landscape depending on box width:height ratio
- % (if box width == height, select portrait orientation)
- gt
- 1 index /PageSize get aload pop
- 2 copy gt
- 4 -1 roll ne { exch } if
- } {
- % Set the page size.
- //systemdict /NoUserUnit .knownget not { //false } if not {
- 3 index /UserUnit knownoget {
- /PassUserUnit /GetDeviceParam .special_op {
- exch pop dup {
- [ /UserUnit 4 -1 roll .pdfputparams pop pop
- } if
- }{
- //false
- }ifelse
- not {
- dup 4 -1 roll mul 3 1 roll mul
- } if
- } {
- /PassUserUnit /GetDeviceParam .special_op {
- exch pop {
- [ /UserUnit 1 .pdfputparams pop pop
- } if
- }if
- } ifelse
- } if
- } ifelse
- 2 array astore /PageSize exch def
- % Determine the number of spot colors used on the page. Note: This searches
- % the pages resources. It may be high if a spot color is in a resource but
- % is not actually used on the page.
- currentpagedevice /PageSpotColors known {
- /PageSpotColors 2 index countspotcolors def
- /SeparationColorNames userdict 1 index get def
- } if
- % If the user told us to use a named OutputIntent
- systemdict /UseOutputIntent .knownget {
- cvn
- % Check to see if this page has such an OutputIntent
- 2 index /OutputIntents knownoget {
- {
- dup /OutputConditionIdentifier get cvn
- dup /Custom eq {
- pop
- dup /Info get cvn
- }if
- 2 index eq {
- %% Found the required OutputIntent
- /DestOutputProfile knownoget {
- [ /ICCBased 3 -1 roll ] ICCBased-resolve
- 1 get .set_outputintent
- ()
- } if
- pop
- exit
- }{
- pop
- } ifelse
- }
- forall
- pop
- }{
- pop
- }ifelse
- } if
-
- % Let the device know if we will be using PDF 1.4 transparency.
- % The clist logic may need to adjust the size of bands.
- 1 index pageusestransparency /PageUsesTransparency exch def
- dup /Install .knownget {
- % Don't let the Install procedure get more deeply
- % nested after every page.
- dup type dup /arraytype eq exch /packedarraytype eq or {
- dup length 4 eq {
- dup 2 get /.pdfshowpage_Install load eq {
- 1 get 0 get % previous procedure
- } if
- } if
- } if
- } {
- { }
- } ifelse 1 array astore
- 2 index exch /.pdfshowpage_Install load /exec load
- 4 packedarray cvx
- % Stack: pagedict currentpagedict installproc
- /Install exch def
- % Stack: pagedict currentpagedict
- % If the Overprint device flag is not /disable, check usage of OP/op
- /PageUsesOverprint //false def % assume we don't need OP simulation
- dup /Overprint get /disable ne
- % If the device suppports SpotColors (DeviceN device) we don't need simulation
- 1 index /PageSpotColors known
- not and
- /HighLevelDevice /GetDeviceParam .special_op {
- exch pop
- }{
- //false
- }ifelse
- not and % Only if not HighLevelDevice
- {
- % Overprint is /enable, so the device might need the overprint compositor
- % if it does not support spot colors, thus check if overprint is used so
- % overprint simulation can be done with the pdf14 compositor
- 1 index countspotcolors pop
- 1 index pageusesoverprint
- 1 index /ProcessColorModel get /DeviceCMYK eq {
- PageSpotColors 0 gt % count of colorants NOT including CMYK
- and
- } if
- /PageUsesOverprint exch def % the page needs OP simulation so set device param.
- } if
- pop currentdict end setpagedevice
-} bind executeonly def
-
-/.free_page_resources { % - .free_page_resources -
- Page /Resources pget {
- /Shading knownoget {
- { dup type /dicttype eq {
- dup /.shading_dict known {
- dup /.shading_dict undef
- } if
- } if
- pop pop
- } forall
- } if
- } if
-} bind executeonly def
-
-/pdfshowpage_finish { % <pagedict> pdfshowpage_finish -
- save /PDFSave exch store
- /PDFdictstackcount countdictstack store
- /PDFexecstackcount count 2 sub store
- (before exec) VMDEBUG
-
- % set up color space substitution (this must be inside the page save)
- pdfshowpage_setcspacesub
-
- .writepdfmarks {
-
- % Pagelabel
- pagelabeldict begin dopagelabel end
- % Copy the boxes.
- % Copy the boxes.
- { /CropBox /BleedBox /TrimBox /ArtBox } {
- 2 copy pget {
- % .pdfshowpage_Install transforms the user space do same here with the boxes
- oforce_elems
- 2 { Page pdf_cached_PDF2PS_matrix transform 4 2 roll } repeat
- normrect_elems 4 index 5 1 roll fix_empty_rect_elems 4 array astore
- mark 3 1 roll {/PAGE pdfmark} stopped {cleartomark} if
- } {
- pop
- } ifelse
- } forall
- } if % end .writepdfmarks
-
- % Display the actual page contents.
- 9 dict begin
- /BXlevel 0 def
- /BMClevel 0 def
- /OFFlevels 0 dict def
- /BGDefault currentblackgeneration def
- /UCRDefault currentundercolorremoval def
- %****** DOESN'T HANDLE COLOR TRANSFER YET ******
- /TRDefault currenttransfer def
- matrix currentmatrix 2 dict
- 2 index /CropBox pget {
- oforce_elems normrect_elems boxrect
- 4 array astore 1 index /ClipRect 3 -1 roll put
- } if
- dictbeginpage setmatrix
- /DefaultQstate qstate store
-
- count 1 sub /pdfemptycount exch store
- % If the page uses any transparency features, show it within
- % a transparency group. The scan was performed during pdfshowpage_setpage
- % and the result was set in the pagedevice dictionary. Use it rather than
- % scanning again IF it is present. If the pdfshowpage_setup was not called
- % (eg GSView 5) then it will not be present, so we must rescan.
- currentdict /PageUsesTransparency .knownget not {dup pageusestransparency} if
- dup /PDFusingtransparency exch def {
- % If the current device isn't CMYK, or if it is a device that supports transparency
- % we don't need the special handling of Overprint transparency, so disable the checking.
-
- 4 dict begin % working directory to simplify
- currentpagedevice dup /Colors get
- /devColors exch def % put into our convenience dict
- dup /HaveTransparency .knownget not { //false } if
- /devSupportsTrans exch def % put into our convenience dict
- dup /Overprint get
- /SimOP exch def % put into our convenience dict
- SimOP /simulate eq
- exch /PageUsesOverprint .knownget not { //false } if
- and % both Overprint==/simulate and PageUsesOverprint
- {
- % Determine if the device needs the special pdf14 compositor push
- devColors 4 eq PageSpotColors 0 gt and % CMYK device, but device has spot colors
- devColors 4 lt % RGB or Gray device
- or
- } {
- //false % Overprint is not /simulate or PageUseOverprint is false
- } ifelse
- % Determine if the device needs SMask for Overprint
- SimOP /simulate eq {
- //true % we will need setupOPrtans for Compatible BM
- } {
- SimOP /enable eq
- devColors 4 ge % CMYK device
- and
- } ifelse
- devSupportsTrans not and % If device supports transparency (e.g. pdfwrite) then no setupOPtrans
- end % pop the convenience dict
- /setup_trans exch
- { /setupOPtrans } { /setupSMtrans } ifelse
- load def
-
- % Show the page within a PDF 1.4 device filter.
- { -1 } { 0 } ifelse
- .pushpdf14devicefilter {
- /DefaultQstate qstate store % device has changed -- reset DefaultQstate
- % If the page has a Group, enclose contents in transparency group.
- % (Adobe Tech Note 5407, sec 9.2)
- dup /Group knownoget {
- 1 index /CropBox pget {
- /CropBox exch
- } {
- 1 index get_media_box pop /MediaBox exch
- } ifelse
- oforce_elems normrect_elems fix_empty_rect_elems 4 array astore .beginpagegroup
- showpagecontents
- .endtransparencygroup
- } {
- showpagecontents
- } ifelse
- } stopped {
- % abort the transparency device
- .abortpdf14devicefilter
- /DefaultQstate qstate store % device has changed -- reset DefaultQstate
- stop
- } if
- { } settransfer % identity transfer during popdevice (put_image)
- .poppdf14devicefilter % NB: reset to DefaultQstate will also restore transfer function
- /DefaultQstate qstate store % device has changed -- reset DefaultQstate
- } {
- /setup_trans { pop pop } def % no-op this if the page doesn't use transparency
- % NB: original will be restored from PDFsave
- % The page doesn't use transparency, but if Overprint is /simulate, we may need to
- % push a pdf14devicefilter to handle the overprint simulation using the pdf14 device.
- currentpagedevice
- dup /Overprint get /simulate eq
- 1 index /PageSpotColors known
- not and
- exch /PageUsesOverprint .knownget not { //false } if
- and
- {
- % Show the page within a PDF 1.4 device filter for overprint_simulation.
- -1 .pushpdf14devicefilter {
- /DefaultQstate qstate store % device has changed -- reset DefaultQstate
- showpagecontents
- } stopped {
- % abort the transparency device
- .abortpdf14devicefilter
- /DefaultQstate qstate store % device has changed -- reset DefaultQstate
- stop
- } if
- { } settransfer % identity transfer during popdevice (put_image)
- .poppdf14devicefilter % NB: reset to DefaultQstate will also restore transfer function
- /DefaultQstate qstate store % device has changed -- reset DefaultQstate
- } {
- showpagecontents
- } ifelse
- } ifelse
- .free_page_resources
- % todo: mixing drawing ops outside the device filter could cause
- % problems, for example with the pnga device.
- endpage
- end % scratch dict
- % Some PDF files don't have matching q/Q (gsave/grestore) so we need
- % to clean up any left over dicts from the dictstack
-
- PDFdictstackcount //false
- { countdictstack 2 index le { exit } if
- currentdict /n known not or
- end
- } loop {
- StreamRunAborted not {
- (\n **** Error: File has unbalanced q/Q operators \(too many q's\)\n Output may be incorrect.\n)
-
- //pdfdict /.Qqwarning_issued .knownget
- {
- {
- pop
- }
- {
- currentglobal //pdfdict gcheck .setglobal
- //pdfdict /.Qqwarning_issued //true .forceput
- .setglobal
- pdfformaterror
- } executeonly ifelse
- } executeonly
- {
- currentglobal //pdfdict gcheck .setglobal
- //pdfdict /.Qqwarning_issued //true .forceput
- .setglobal
- pdfformaterror
- } executeonly ifelse
- } executeonly if
- } executeonly if
- pop
- count PDFexecstackcount sub { pop } repeat
- (after exec) VMDEBUG
- Repaired % pass Repaired state around the restore
- RepairedAnError
- PDFSave restore
- currentglobal //pdfdict gcheck .setglobal
- //pdfdict /.Qqwarning_issued //false .forceput
- .setglobal
- /RepairedAnError exch def
- /Repaired exch def
-} bind executeonly odef
-
-% Display the contents of a page (including annotations).
-/showpagecontents { % <pagedict> showpagecontents -
- dup % Save the pagedict for the Annotations
-
- % We do a 'save' here in order to allow us to restore at the end of the page, before
- % we run the annotations. There are two reasons for this; firstly so that the graphics state
- % at the time we run the annotations is the same as when we ran the page, secondly in order
- % to empty the font cache before we run the annotations.
- %
- % Bug #700096 an annotation uses Helvetica but doesn't embed it, however the page *does*
- % use an embedded Helvetica, which is subset and not prefixed as such. For this file to
- % render correctly we must not use the font from the page, but must find a replacement.
- % However the file for Bug #695897 has a page which uses two versions of the same font,
- % one embedded, one not. In order for *that* file to render correctly we *must* use the
- % embedded font as a substitute for the missing font. So we divorce the fonts used
- % for the page from the fonts used for Annotations, this allows both files to work as
- % expected.
- %
- % We also need a countdictstack, so that we can check the dictionaries on the dictioanry
- % stack after we run the page contents, and 'end' an extra ones before we try to restore
- % otherwise we might try to restore back to a point before one of those dictionaries existed.
- %
- save
- countdictstack
- 3 -1 roll
- count 1 sub /pdfemptycount exch store
- /Contents knownoget not { 0 array } if
- dup type /arraytype ne { 1 array astore } if {
- oforce dup type /dicttype eq {
- //false resolvestream pdfopdict .pdfrun
- } {
- (**** Error: The Page /Contents array contains an element which is not a stream\n This page will not display correctly\n\n)
- pdfformaterror
- pop exit
- }ifelse
- } forall
- % check for extra garbage on the ostack and clean it up
- count pdfemptycount sub dup 0 ne {
- ( **** Error: File did not complete the page properly and may be damaged.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- { pop } repeat
- } {
- pop
- } ifelse
-
- % Top of the stack should ow be the count of dictionaries on the stack at the time
- % we did a save. If there are more than there were then, end dictionaries until
- % we get back to the sme number.
- {
- countdictstack 1 index le {exit}if
- end
- } loop
- % discard the count of dictionaries
- pop
- % and restore the state. This will take us back to a point before any fonts
- % used on the page were defined, so the annotations won't inherit any of
- % them.
- restore
-
- % Draw the annotations
- //systemdict /ShowAnnots .knownget not { //true } if {
- /Annots knownoget {
- dup type /arraytype eq {
- {
- /AnnotDrawCheck exch % marker to clean up stack on error
- {oforce} stopped
- {
- ( **** Error: Unable to draw an annotation.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- count -1 0 { % make sure we don't go past the top of the stack
- pop % remove the counter
- /AnnotDrawCheck eq {exit} if % remove object and check if its the marker, exit if it is
- } for
- }
- {
- exch pop
- dup //null ne {
- .writepdfmarks
- %%
- %% We don't want to preserve annotations with ps2write, because we don't convert them
- %% back into pdfmarks on output.
- %%
- /ForOPDFRead /GetDeviceParam .special_op {
- exch pop
- }{
- //false
- }ifelse
- not
- and
- //systemdict /PreserveAnnots .knownget not {//true} if and {
- mark exch {preserveannot} PDFSTOPONERROR {exec}{stopped {(Error: Ignoring invalid annotation, output may be incorrect.\n) pdfformaterror} if} ifelse {cleartomark} stopped
- {(Error: Failed to clean up after annotation, output may be incorrect.\n) pdfformaterror}if
- }{
- mark exch {drawannot} PDFSTOPONERROR {exec}{stopped {(Error: Ignoring invalid annotation, output may be incorrect.\n) pdfformaterror} if} ifelse {cleartomark} stopped
- {(Error: Failed to clean up after annotation, output may be incorrect.\n) pdfformaterror}if
- } ifelse
- } {
- pop
- } ifelse
- } ifelse
- } forall
- }
- {
- ( **** Error: Annotation array is not an array, ignoring it.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop
- } ifelse
- } if
- } if
- % default AcroForm to true to match Acrobat.
- //systemdict /ShowAcroForm .knownget { //true eq } { //true } ifelse {
- Trailer /Root oget /AcroForm knownoget { draw_acro_form } if
- } if
-} bind executeonly def
-
-/processcolorspace { % - processcolorspace <colorspace>
- % The following is per the PLRM3.
- currentdevice 1 dict dup /ProcessColorModel dup put .getdeviceparams
- exch pop exch pop
- dup type /nametype ne { cvn } if
- dup { setcolorspace } //.internalstopped exec { pop /DeviceRGB } if
-} bind executeonly def
-
-% returns true if OP or op is true in an ExtGState
-/pageusesoverprint { % <pagedict> pageusesoverprint <bool>
- dup //false exch {
- 4 dict 1 index resourceusesoverprint { pop not exit } if
- %% Check the current dictionary and its Parent (if any) to see
- %% if they both have stored object numbers. If they do then
- %% check the numbers, don't allow self-references.
- dup /Parent knownoget not { pop exit }
- {
- exch /.gs.pdfobj# .knownget
- {
- 1 index /.gs.pdfobj# .knownget {
- eq {
- pop exit
- }if
- }{
- pop
- }ifelse
- }if
- } ifelse
- } loop
- % Also check for transparency in the annotation (if not in resources).
- { pop //true } { annotsuseoverprint } ifelse
-} bind def
-
-% Check if Overprint (OP/op) is specified in an ExtGState dict
-/extgstateusesoverprint { % <gstate dict> extgstateusesoverprint <bool>
- //false exch % Assume no overprint
- dup //null eq {
- pop % bug 692050
- } {
- { % establish loop context
- dup /OP knownoget { { pop not exit } if } if
- dup /op knownoget { { pop not exit } if } if
- pop exit
- } loop
- } ifelse
-} bind def
-
-% Check if overprint is used in a Pattern
-/patternusesoverprint { % <Pattern dict> patternusesoverprint <bool>
- //false exch % Assume no overprint
- {
- 4 dict 1 index resourceusesoverprint { pop not exit } if
- dup /ExtGState knownoget { extgstateusesoverprint { pop not exit } if } if
- pop exit
- } loop
-} bind def
-
-% Check the Resources of a page or Form. Check for loops in the resource chain.
-/resourceusesoverprint { % <dict> <dict> resourceusesoverprint <bool>
- { % Use loop to provide an exitable context.
- /Resources knownoget not { 0 dict } if
- 2 copy .knownget {
- { % Some circular references may be missed because scanning stops
- % when the 1st overprint is found.
- ( **** File has circular references in resource dictionaries.\n)
- pdfformaterror
- } if
- pop //false exit
- } if
- 2 copy //true put % In the current chain.
- dup /ExtGState knownoget {
- //false exch
- { exch pop oforce extgstateusesoverprint { pop //true exit } if
- } forall
- { pop //true exit } if
- } if
- dup /Pattern knownoget {
- //false exch
- { exch pop oforce patternusesoverprint { pop //true exit } if
- } forall
- { pop //true exit } if
- } if
- 2 copy //false put % Visited but not in the current chain.
- pop //false exit
- } loop
- exch pop
-} bind def
-
-% Check if the annotations on a page use overprint
-/annotsuseoverprint { % <page dict> annotsuseoverprint <bool>
- //false exch % Assume no overprint
- /Annots knownoget { % Get Annots array
- dup type /arraytype eq {
- {
- oforce
- dup //null ne {
- /AP knownoget { % Get appearance dict for the annoation
- /N knownogetdict { % Get the /N (i.e. normal) appearance stream
- 4 dict exch resourceusesoverprint { not exit } if
- } if
- } if % If AP dict known
- } {
- pop
- } ifelse
- } forall % For all annots on the page
- } {
- ( **** Error: Annotation array is not an array, ignoring it.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop
- }
- ifelse
- } if
-} bind def
% ------ Transparency support ------ %
-% Determine whether a page might invoke any transparency features:
-% - Non-default BM, ca, CA, or SMask in an ExtGState
-% - Image XObject with SMask
-% Note: we deliberately don't check to see whether a Group is defined,
-% because Adobe Illustrator 10 (and possibly other applications) define
-% a page-level group whether transparency is actually used or not.
-% Ignoring the presence of Group is justified because, in the absence
-% of any other transparency features, they have no effect.
-%
-% Transparency is a 1.4 feature however we have seen files that claimed
-% to be PDF 1.1 with transparency features. Bugs 689288, 691273.
-/pageusestransparency { % <pagedict> pageusestransparency <bool>
- NOTRANSPARENCY {
- pop //false
- } {
- dup //false exch {
- 4 dict 1 index resourceusestransparency { pop not exit } if
- %% Check the current dictionary and its Parent (if any) to see
- %% if they both have stored object numbers. If they do then
- %% check the numbers, don't allow self-references.
- dup /Parent knownoget not { pop exit }
- {
- exch /.gs.pdfobj# .knownget
- {
- 1 index /.gs.pdfobj# .knownget {
- eq {
- pop exit
- }if
- }{
- pop
- }ifelse
- }if
- } ifelse
- } loop
- % Also check for transparency in the annotation (if not in resources).
- { pop //true } { annotsusetransparency } ifelse
- } ifelse
-} bind executeonly def
-
-% Check if transparency is specified in an ExtGState dict
-/extgstateusestransparency { % <gstate dict> extgstateusestransparency <bool>
- //false exch % Assume no transparency
- dup //null eq {
- pop % bug 692050
- } {
- { % establish loop context
- dup /BM knownoget {
- dup /Normal ne exch /Compatible ne and { pop not exit } if
- } if
- dup /ca knownoget { 1 ne { pop not exit } if } if
- dup /CA knownoget { 1 ne { pop not exit } if } if
- dup /SMask knownoget { /None ne { pop not exit } if } if
- pop exit
- } loop
- } ifelse
-} bind executeonly def
-
-% Check if transparency is used in a Pattern
-/patternusestransparency { % <Pattern dict> patternusestransparency <bool>
- dup //null eq NOTRANSPARENCY or
- { pop //false }
- { //false exch % Assume no transparency
- {
- 4 dict 1 index resourceusestransparency { pop not exit } if
- dup /ExtGState knownoget { extgstateusestransparency { pop not exit } if } if
- pop exit
- } loop
- }
- ifelse
-} bind executeonly def
-
-% Check the Resources of a page or Form. Check for loops in the resource chain.
-/resourceusestransparency { % <dict> <dict> resourceusestransparency <bool>
- { % Use loop to provide an exitable context.
- /Resources knownoget not { 0 dict } if
- 2 copy .knownget {
- { % Some circular references may be missed because scanning stops
- % when the 1st transparency is found.
- ( **** Warning: Found circular references in resource dictionaries while checking for transparency.\n)
- pdfformatwarning
- } if
- pop //false exit
- } if
- 2 copy //true put % In the current chain.
- dup /ExtGState knownoget {
- //false exch
- { exch pop oforce extgstateusestransparency { pop //true exit } if
- } forall
- { pop //true exit } if
- } if
- dup /Pattern knownoget {
- //false exch
- { exch pop oforce patternusestransparency { pop //true exit } if
- } forall
- { pop //true exit } if
- } if
- dup /XObject knownoget {
- dup type /dicttype eq {
- //false exch
- {
- exch pop oforce
- dup //null ne {
- dup type /dicttype eq {
- dup /Subtype get
- dup /Image eq {
- 1 index /SMask oknown { pop pop not exit } if
- 1 index /SMaskInData knownoget {
- 0 ne { pop pop not exit } if
- } if
- } if
- /Form eq {
- dup /Group known {pop pop //true exit}{
- 3 index exch resourceusestransparency { not exit } if
- } ifelse
- } {
- pop
- } ifelse
- } {
- pop
- ( **** Warning: Ignoring non-dictionary /XObject attribute while checking for transparency.\n)
- pdfformatwarning
- } ifelse
- } {
- pop
- } ifelse
- } forall
- { pop //true exit } if
- } {
- ( **** Warning: Ignoring non-dictionary /XObject while checking for transparency.\n)
- pdfformatwarning
- pop
- } ifelse
- } if
- dup /Font knownoget {
- //false exch
- {
- exch pop oforce
- dup type /dicttype eq {
- dup /Subtype knownoget {
- /Type3 eq
- {
- 3 index exch resourceusestransparency
- { pop //true exit } if
- }
- {pop} ifelse
- }
- {
- pop
- }ifelse
- }
- { % probably a name object
- pop
- }ifelse
- } forall
- { pop //true exit } if
- } if
- 2 copy //false put % Visited but not in the current chain.
- pop //false exit
- } loop
- exch pop
-} bind executeonly def
-
-% Check if the annotations on a page use transparency
-/annotsusetransparency { % <page dict> annotsusetransparency <bool>
- //false exch % Assume no transparency
- /Annots knownoget { % Get Annots array
- dup type /arraytype eq {
- {
- /AnnotTransparencyCheck exch % marker to clean up stack on error
- {oforce} stopped
- {
- ( **** Error: Unable to check an annotation for use of transparency.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- count -1 0 { % make sure we don't go past the top of the stack
- pop % remove the counter
- /AnnotTransparencyCheck eq {exit} if % remove object and check if its the marker, exit if it is
- } for
- }
- {
- exch pop % remove the 'on error' marker
- dup type /dicttype eq {
- dup //null ne {
- dup /Subtype knownoget {
- /Highlight eq { % Highlight annotation is always implemented
- pop pop //true exit % as transparency.
- } if
- } if
- dup /AP knownoget { % Get appearance dict for the annoation
- /N knownogetdict { % Get the /N (i.e. normal) appearance stream
- 4 dict exch resourceusestransparency { pop pop //true exit } if
- } if
- } if % If AP dict known
- dup /BM knownoget {
- pop pop pop //true exit
- } if
- dup /CA knownoget {
- 1 le {
- pop pop //true exit
- } if
- } if
- /ca knownoget {
- 1 le {
- pop //true exit
- } if
- } if
- } {
- pop
- } ifelse
- } {
- ( **** Error: Annotation entry is not a dictionary, ignoring it.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop
- } ifelse
- } ifelse
- } forall % For all annots on the page
- }
- {
- ( **** Error: Annotation array is not an array, ignoring it.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop
- }
- ifelse
- } if
-} bind executeonly def
-
-% Add a color name to our spot color list. Ignore /All and /None
-/putspotcolor { % <name> <spotcolordict> putspotcolor -
- % The 'name' could be a string. If so then convert to a name.
- exch dup type /stringtype eq { cvn } if
- dup dup /None eq exch /All eq or { pop pop } { 0 put } ifelse
-} bind executeonly def
-
-% Determine which spot colors are used within a color space Note: This
-% dict will include all colors used in Separation or DeviceN color spaces.
-% Thus it may include Cyan, Magenta, Yellow, and Black.
-% <colorspace> <spotcolordict> colorspacespotcolors -
-/colorspacespotcolors {
- % Make sure we have an array, and that it is has enough info
- exch dup type /arraytype eq
- {
- % If we have an Indexed color space then get the base space.
- dup 0 oget % <<>> [csp] /Type
- dup /Indexed eq {
- pop 1 oget % <<>> [base]
- 2 copy exch colorspacespotcolors
- } {
- dup /Pattern eq {
- 1 index length 1 gt { % only uncolored patterns have colorspace
- pop 1 oget % <<>> [base]
- 2 copy exch colorspacespotcolors
- } {
- pop
- } ifelse
- } {
- % Stack: <spotcolordict> <colorspace> <colorspacetype>
- dup /Separation eq exch /DeviceN eq or {
- dup 1 oget dup type /arraytype eq {
- { oforce 2 index putspotcolor } forall
- } {
- 2 index putspotcolor
- } ifelse
- } if
- } ifelse
- } ifelse
- } if
- pop pop
-} bind executeonly def
-
-% Check the Resources of a page, form, or annotation. Determine which spot
-% colors are used within the resource Note: The spot color dict will include
-% all colors used in Separation or DeviceN color spaces. Thus it may include
-% Cyan, Magenta, Yellow, and Black. We also pass a dict that is used to check
-% for loops in the resource list.
-% <spotcolordict> <loopdict> <page/form/annot dict>
-% resourcespotcolors <spotcolordict> <loopdict>
-/resourcespotcolors {
- { % Use loop to provide an exitable context.
- % Exit if no Resources entry
- /Resources knownoget not { exit } if
- % Exit if we have already seen this dict
- 2 copy known { pop exit } if
-
- % Save the Resources dict into our loop checking dict.
- 2 copy 0 put
-
- % Scan resources that might contain a color space.
- dup /ColorSpace knownoget {
- { exch pop oforce 3 index colorspacespotcolors } forall
- } if
- dup /Pattern knownoget {
- { exch pop oforce
- dup /Shading knownoget {
- exch pop
- /ColorSpace oget 3 index colorspacespotcolors
- } {
- 4 copy exch pop resourcespotcolors pop pop pop
- } ifelse
- } forall
- } if
- dup /Shading knownoget {
- { exch pop
- oforce /ColorSpace
- { oget } stopped
- {
- pop pop
- ( **** Error: invalid color space in shading, output may be incorrect.\n) pdfformaterror
- }
- { 3 index colorspacespotcolors}
- ifelse
- } forall
- } if
- /XObject knownoget {
- dup type /dicttype eq {
- { exch pop oforce
- dup type /dicttype eq {
- dup //null ne {
- dup /Subtype oget
- dup /Form eq {
- pop resourcespotcolors
- } {
- /Image eq {
- /ColorSpace knownoget {
- 2 index colorspacespotcolors
- } if
- } {
- pop
- } ifelse
- } ifelse
- } {
- pop
- } ifelse
- } {
- pop
- } ifelse
- } forall
- } {
- pop % Just ignore here, already reported by resourceusestransparency.
- } ifelse
- } if
- exit
- } loop
-} bind executeonly def
-
-% Determine which spot colors are used within the annotations. Note: This
-% dict will include all colors used in Separation or DeviceN color spaces.
-% Thus it may include Cyan, Magenta, Yellow, and Black.
-% <spotcolordict> <loopdict> <annotsarray>
-% annotsspotcolors <spotcolordict> <loopdict>
-/annotsspotcolors {
- dup type /arraytype eq {
- { oforce
- dup //null ne {
- /AP knownoget { % Get appearance dict for the annoation
- /N knownogetdict { % Get the /N (i.e. normal) appearance stream
- resourcespotcolors
- } if % If normal appearance streamknown
- } if % If AP dict known
- } {
- pop
- } ifelse
- } forall
- }
- {
- ( **** Error: Annotation array is not an array, ignoring it.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop
- } ifelse
-} bind executeonly def
-
-% Determine spot colors are used within a page. We are creating a dict to
-% hold the spot color names as keys. Using a dict avoids having to worry
-% about duplicate entries. The keys in the dict contain the spot color
-% names. However the values have no meaning. Note: This dict will include
-% all colors used in Separation or DeviceN color spaces specified in the
-% page's resources. Thus it may include Cyan, Magenta, Yellow, and Black.
-% There is no attempt to verify that these color spaces are actually used
-% within the object streams for the page.
-/pagespotcolors { % <pagedict> pagespotcolors <spotcolordict>
- dup
- % Create a dict to hold spot color names.
- 0 dict exch
- % Create a dict to be used to check for reference loops.
- 4 dict exch
- % Check for color spaces in the Resources
- resourcespotcolors
- % now check upwards in the object hierarchy in case of inherited resources
- 2 index
- {
- /Parent knownoget
- {
- dup /Pages known not { pop exit } if % not a valid Page Tree ancestor
- dup 4 1 roll
- resourcespotcolors
- 3 -1 roll
- }
- {
- exit
- } ifelse
- } loop
- % Also check for color spaces in the annotations.
- 3 -1 roll
- /Annots knownoget { annotsspotcolors } if
- pop % Discard reference loop dict
-} bind executeonly def
-
-% Determine how many (if any) spot colors are used by a page.
-% Note: This count does not include Cyan, Magenta, Yellow, or Black
-/countspotcolors { % <pagedict> countspotcolors <count>
- pagespotcolors % Get dict with all spot colors
- % Remove CMYK from the spot color count.
- [ /Cyan /Magenta /Yellow /Black ]
- {
- dup 2 index exch known {
- 1 index exch undef
- } {
- pop
- } ifelse
- } forall
- dup length dup
- userdict exch /PageSpotColors exch put % save it in a known place
- exch
- userdict /SeparationColorNames 2 index
- [ exch { pop } forall ]
- put % and save the SpotColorNames array in a known place
- pop % done with spot color dict
-} bind executeonly def
-
-% ------ ColorSpace substitution support ------ %
-
-%%
-%% <pagedict> pdf_colorspace_detect_cspacesub <boolean>
-%%
-/pdf_colorspace_detect_cspacesub {
- //false exch
- /Resources knownoget {
- /ColorSpace knownoget {
- dup /DefaultGray knownoget {
- resolvecolorspace csncomp 1 eq {
- pop pop //true
- } if
- } {
- dup /DefaultRGB knownoget {
- resolvecolorspace csncomp 3 eq {
- pop pop //true
- } if
- } {
- /DefaultCMYK knownoget {
- resolvecolorspace csncomp 4 eq {
- pop //true
- } if
- } if
- } ifelse
- } ifelse
- } if
- } if
-} bind executeonly def
-
-%% <loopdict> <Objectdict> <calling obj_num> pdfform_detect_cspacesub <boolean>
-%%
-/pdf_object_detect_cspacesub {
- %% use loop operator for an exitable context
- %% we need this to detect recursion/looping
- {
- exch %% <loopdict> <calling obj_num> <Objectdict>
- dup pdf_colorspace_detect_cspacesub {
- pop pop //true exit
- }{ %% <loopdict> <calling obj_num> <Objectdict>
- /Resources knownoget { %% <loopdict> <calling obj_num> <Resourcesdict>
- 2 index 1 index known {
- %% We've already seen this object, ignore it and exit
- pop pop //false exit
- }{
- 2 index 1 index //null put
- } ifelse
-
- /XObject knownoget { %% <loopdict> <calling obj_num> <XObjectdict>
- //false exch %% <loopdict> <calling obj_num> <XObjectdict> false
- %% We have files where the XObject Resource is not a dictionary
- dup type /dicttype eq { %% <loopdict> <calling obj_num> <XObjectdict> false
-
- %% check each Xobject entry in the dictionary,
- %% forall purs a key/value pair on the stack for us.
- %%
- { %% <loopdict> <calling obj_num> <XObjectdict> false key value
- exch pop %% <loopdict> <calling obj_num> <XObjectdict> false value
-
- %% If this is an indirect reference, check if its the smae object
- %% as the current one. If its not indirect, make the object number 0
- %% for comparison purposes.
- dup type /packedarraytype eq {
- dup 0 get dup 4 index
- eq
- } {
- 0 //false
- }ifelse
-
- %% <calling obj_num> <XObjectdict> false value <form object or 0 if not indirect> <boolean>
- not {
- %% swap object number and value, and dereference value
- exch oforce
- %% Apparently we have files where the content of the XObject Resource dictionary is null
- dup //null ne {
- %% and files where the indivudal XObjects are not dictionaries
- dup type /dicttype eq {
- dup /Subtype get /Form eq {
- exch
- 4 index 3 1 roll pdf_object_detect_cspacesub {
- pop //true exit
- } if
- } {
- pop pop
- }ifelse
- }{
- pop pop
- } ifelse
- }{
- pop pop
- }
- ifelse
- }{
- pop pop
- } ifelse
- } forall
- }{
- pop
- }ifelse
- } {
- %% No forms, so can't be any Default* spaces
- //false
- }ifelse
- } {
- //false
- } ifelse
- } ifelse
- %% Remove the calling object ID, return our boolean
- exch pop exit
- } loop
- %% remove and discard the loopdict
- exch pop
-} bind executeonly def
-
-%
-% <pagedict> pdfshowpage_detect_cspacesub <pagedict> <boolean>
-%
-% this is used simply to detect whether the current page has any
-% Default* color spaces defined. If it does then we want pdfshowpage_setpage
-% to set UseCIEColor to true so that the Default* space is used. If the
-% page doesn't use any Default* spaces, then we *don't* want to set
-% UseCIEColor as that will confuse a warning in pdfwrite about
-% not using UseCIEColor with pdfwrite.
-%
-/pdfshowpage_detect_cspacesub {
- dup 0 1 dict 3 1 roll pdf_object_detect_cspacesub
-
- /HighLevelDevice /GetDeviceParam .special_op {
- exch pop not exch pop
- }if
-} bind executeonly def
-
-%
-% <pagedict> pdfshowpage_setcspacesub <pagedict>
-%
-% Set up color space substitution for a page. Invocations of this procedure
-% must be bracketed by the save/restore operation for the page, to avoid
-% unintended effects on other pages.
-%
-% If any color space substitution is used, and the current color space is a
-% device dependent color space, make sure the current color space is updated.
-% There is an optimization in the setcolorspace operator that does
-% nothing if both the current and operand color spaces are the same. For
-% PostScript this optimization is disabled if the UseCIEColor page device
-% parameter is true. This is not the case for PDF, as performance suffers
-% significantly on some PDF files if color spaces are set repeatedly. Hence,
-% if color space substitution is to be used, and the current color space
-% is a device dependent color space, we must make sure to "transition" the
-% current color space.
-%
-/pdfshowpage_setcspacesub {
- //false
- /DefaultGray 2 index /ColorSpace //rget exec {
- resolvecolorspace dup csncomp 1 eq {
- dup type /nametype eq { 1 array astore } if
- /DefaultGray exch /ColorSpace defineresource pop
- pop //true
- } {
- pop
- ( **** Error: ignoring invalid /DefaultGray color space.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- } if
-
- /DefaultRGB 2 index /ColorSpace //rget exec {
- resolvecolorspace dup csncomp 3 eq {
- dup type /nametype eq { 1 array astore } if
- /DefaultRGB exch /ColorSpace defineresource pop
- pop //true
- } {
- pop
- ( **** Error: ignoring invalid /DefaultRGB color space.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- } if
-
- /DefaultCMYK 2 index /ColorSpace //rget exec {
- resolvecolorspace dup csncomp 4 eq {
- dup type /nametype eq { 1 array astore } if
- /DefaultCMYK exch /ColorSpace defineresource pop
- pop //true
- } {
- pop
- ( **** Error: ignoring invalid /DefaultCMYK color space.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- } if
-
- { % if using color space substitution, "transition" the current color space
- currentcolorspace dup length 1 eq { % always an array
- 0 get
- dup /DeviceGray eq 1 index /DeviceRGB eq or 1 index /DeviceCMYK eq or {
- /Pattern setcolorspace setcolorspace
- } {
- pop
- } ifelse
- } {
- pop
- } ifelse
- } if
-} bind executeonly def
-
-% Write OutputIntents to device if the device handles it
-/writeoutputintents {
- currentdevice 1 dict dup /OutputIntent //null put readonly
- .getdeviceparams
- mark ne { pop pop
- % device supports OutputIntent parameter
- % Make sure we don't have a badly broken PDF file!
- Trailer /Root knownoget {
- /OutputIntents knownoget {
- dup type /arraytype eq {
- { % process all output profiles present
- oforce
- dup length dict .copydict
- dup /DestOutputProfile knownoget {
- PDFfile fileposition exch
- mark exch { oforce } forall .dicttomark
- //true resolvestream
- [ { counttomark 1 add index
- 64000 string readstring
- not { exit } if
- } loop
- ] exch closefile
- 0 1 index { length add } forall .bytestring
- 0 3 2 roll {
- 3 copy putinterval
- length add
- } forall pop
- exch PDFfile exch setfileposition
- 1 index /DestOutputProfile 3 2 roll put
- } if
- % Convert to string array because it's easier for the device
- [ 1 index /OutputCondition knownoget not { () } if
- 2 index /OutputConditionIdentifier knownoget not { () } if
- 3 index /RegistryName knownoget not { () } if
- 4 index /Info knownoget not { () } if
- 5 index /DestOutputProfile knownoget not { () } if
- ]
- [ /OutputIntent 3 2 roll /.pdfputparams where
- { pop .pdfputparams }
- { currentdevice //null //false counttomark 1 add 3 roll .putdeviceparamsonly }
- ifelse
- pop pop
- pop % done with this OutputIntent dictionary
- } forall
- } {
- pop
- ( **** Error: /OutputIntent is of an incorrect type, ignoring OutputIntent.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- } if % OutputIntents known
- % tell device there are no more OutputIntents
- [ /OutputIntent [ ] /.pdfputparams where
- { pop .pdfputparams }
- { currentdevice //null //false counttomark 1 add 3 roll .putdeviceparamsonly }
- ifelse
- pop pop
- } if
- } if
-} bind executeonly def
-
-% These functions can be used in error handling. It is not always possible to
-% use the PostScript sequence 'mark ..... cleartomark' to clean up behind a
-% sequence of operations, because processing the PDF might leave a mark
-% object on the stack. There are a number of ways to address that problem; one
-% is to count the objects on the stack at the time and store that value in a
-% convenient dictionary, presented here is an alternative. Instead of using a
-% mark object, we can use a specific name object as if it were a mark object
-% and use the two routines below to count the number of objects on the stack
-% up to a specific key, and to clear the stack back to a named key.
-
-%
-% /key CountToKey false | int true
-%
-% Counts the operand stack backwards until it encounters
-% a specific name key on the stack. Returns true and the count
-% of objects on the stack after that key, or false if the key
-% was not found on the stack. Consumes the key passed
-% to CountToKey. Throws a typecheck if the operand is not
-% a name type.
-%
-/CountToKey
-{
- dup type /nametype eq {
- //false
- 0 1 count 5 sub
- {
- dup 3 add index
- 3 index eq
- {
- 3 1 roll pop pop //true exit
- }
- {pop} ifelse
- } for
-
- {
- //true
- }
- {
- pop //false
- } ifelse
- }
- {
- /CountToKey cvx /typecheck signalerror
- }ifelse
-}bind readonly def
-
-%
-% /key ClearToKey -
-%
-% Clears the operand stack backwards until it encounters
-% the name object passed as an operand. If the name object
-% is not present on the stack then it will clear the entire
-% stack. Like cleartomark this removes the 'key' from the stack.
-%
-/ClearToKey
-{
- 0 1 count 4 sub
- {
- pop
- dup 3 1 roll eq {exit} if
- } for
- pop
-}bind readonly def
-
-/NestedPatterns <<>> def
-
-end % pdfdict
-
-
systemdict /ALLOWPSTRANSPARENCY get
{
/.setopacityalpha
@@ -5061,19 +1294,7 @@ systemdict /ALLOWPSTRANSPARENCY get
%% is not required once the initislisation is complete and functions are bound, we undefine
%% the ones that aren't needed at runtime.
[
-/.pdfawidthshow /.pdfwidthshow /.currentblackptcomp /.setblackptcomp
-/.setfillcolor /.setfillcolorspace /.setstrokecolor /.setstrokecolorspace /.currentrenderingintent /.setrenderingintent
-/.currenttextrenderingmode /.settextspacing /.currenttextspacing /.settextleading /.currenttextleading
-/.settextrise /.currenttextrise /.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling
-/.settextlinematrix /.currenttextlinematrix /.currenttextmatrix /.settextmatrix /.pushextendedgstate
-/.popextendedgstate
-
-/.pdfinkpath /.pdfFormName /.settextspacing /.currenttextspacing /.settextleading /.currenttextleading
-/.settextrise /.currenttextrise /.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling
-/.setPDFfontsize /.currentPDFfontsize /.setdistillerparams /.currentpoint_valid
-
-% undefining these causes errors/incorrect output
-%/.settextrenderingmode
+/.setdistillerparams
] systemdict .undefinternalnames
% The following are split out allowing control via ALLOWPSTRANSPARENCY command line param
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps
deleted file mode 100644
index a00356c7c1c..00000000000
--- a/Master/tlpkg/tlgs/Resource/Init/pdf_ops.ps
+++ /dev/null
@@ -1,2129 +0,0 @@
-% Copyright (C) 2001-2022 Artifex Software, Inc.
-% 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.
-%
-% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
-%
-
-% Definitions for most of the PDF operators.
-
-.currentglobal //true .setglobal
-
-% Define pdfmark. Don't allow it to be bound in.
-% Also don't define it in systemdict, because this leads some Adobe code
-% to think this interpreter is a distiller.
-% (If this interpreter really is a distiller, don't do this.)
-systemdict /pdfmark known not
- { userdict /pdfmark { cleartomark } bind executeonly put } if
-
-systemdict /pdfdict where { pop } { /pdfdict 325 dict put } ifelse
-userdict /GS_PDF_ProcSet 256 dict dup begin
-
-% ---------------- Abbreviations ---------------- %
-
-/bdef { bind def } bind def
-
-% ---------------- Graphics state stack ---------------- %
-
-% PDF adds a number of parameters to the graphics state.
-% We implement this by pushing and popping a dictionary
-% each time we do a PDF gsave or grestore.
-% The keys in this dictionary are as follows:
-% self % identifies the dictionary as one of ours
-% ClipRect % (optional)
-% Show
-% TextSaveMatrix % matrix at time of BT (iff within BT/ET)
-% (The following correspond directly to PDF state parameters.)
-% AlphaIsShape
-% FillConstantAlpha
-% FillColor
-% FillColorSpace
-% FillOverprint
-% SoftMask
-% StrokeConstantAlpha
-% StrokeColor
-% StrokeColorSpace
-% StrokeOverprint
-% TextSpacing
-% TextHScaling
-% Leading
-% TextFont
-% TextLineMatrix
-% TextMatrix
-% TextRise
-% TextRenderingMode
-% WordSpacing
-% (The following is cached information derived from other graphics state params)
-% FontMatrixNonHV % TextFont.FontMatrix alters horz/vert glyph advance vector direction
-
-/nodict 1 dict def
-nodict /self { //nodict } executeonly put % to avoid recursion in dumps
-nodict readonly pop
-
-/dictbeginpage { % <initialdict> dictbeginpage -
- 20 dict copy dup begin
- 1 packedarray cvx executeonly /self exch def
- graphicsbeginpage textbeginpage
-} bind executeonly def
-/endpage { % - endpage -
- showpage end
-} bind executeonly def
-
-/graphicsbeginpage {
- initgraphics
- //true .setaccuratecurves
- currentdict /ClipRect knownoget { aload pop rectclip } if
- % inigraphics sets the gstate colorspace and color correctly
- % *but* pdfwrite's transparency handling can get upset if we
- % don't explicitly set color and space here.
- currentcolor currentcolor currentcolorspace dup
- .setfillcolorspace .setstrokecolorspace
- .setfillcolor .setstrokecolor
- //false op //false OP 0 OPM
- 1 ca 1 CA //null SMask //false AIS /Compatible BM //true TK
-} bind executeonly def
-
-% We must allow /Show to be set, otherwise a text operation can
-% end up in infinite recursion with showfirst calling Show, and
-% Show calling showfirst.
-/gput_always_allow
-1 dict dup begin
- /Show 0 def
-end def
-
-/gput % <value> <key> gput -
- {
- dup //gput_always_allow exch known not currentdict /n known and {
- pop pop
- ( **** Error: Ignoring changes to the graphic state after operator 'W'.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } {
- exch currentdict //nodict eq { /self dup load end 5 dict begin def } if
- def
- } ifelse
- } bind executeonly def
-currentdict /gput_always_allow .undef
-
-/q {
- %% Special case, if we get a 'q' while accumulating clip/eoclip then
- %% we need to make sure we close the current dictionary, and reopen it after
- %% performing the gsave, so that the redefinition of 'n' in particular is correct
- currentdict /n known {
- currentdict %% copy the dicitonary for the accumulation
- end %% and close it (NB *before* the gsave!)
- gsave //nodict begin %% execute gsave and start 'nodict' just like normal
- begin %% reopen the accumulation dictionary.
- %% when we execute 'n' this will close and we'll go back
- %% to the regular 'nodict' opened above. This could cause some
- %% odd interactions with 'Q' for unbalanced files.....
- } {
- %% ugly hackery to work around badly broken PDF file in Bug #695897. The file has nested BT/ET
- %% sections, and delimits them with q/Q. The problem is that our code to deal with nested
- %% text sections looks in the current dictionary for TextSaveMatrix, and a 'q' makes a brand
- %% new empty dictionary, so it defeats it.
- %% I tried copying the TextSaveMatrix from the parent state into this one, but that then causes
- %% other problems because we end up apllying the TextSaveMatrix when we shouold not. Attempting
- %% to clear the TextSaveMatrix from all saved states on ET then caused it not to be defined at
- %% times when we needed it.....
- %% This is all terribly flaky, but defining a new matrix inside gsaves that tells us that we had
- %% were already in a text block allows us to detect and cope with the nested BT's and leaving the
- %% original TextSaveMatrix behind allows the matching ET not to throw an error, as well as coping
- %% with the various other problems listed above. Its not pretty though.
- currentdict /TextSaveMatrix known {
- currentdict /TextSaveMatrix get matrix copy
- gsave //nodict begin
- /qTextSaveMatrix gput
- }{
- gsave //nodict begin
- }ifelse
- } ifelse
- PDFusingtransparency { .pushextendedgstate } if
-} bind executeonly def
-
-% Some PDF files have excess Q operators!
-/Q {
- //false
- { currentdict /n known { end pop //true } { exit } ifelse
- } loop {
- ( **** Error: Encountered a 'Q' before finishing 'W' mode.\n)
- pdfformaterror
- ( Output may be incorrect..\n) pdfformaterror
- } if
- currentdict /self .knownget {
- exec //nodict eq {
- end
- PDFusingtransparency { .popextendedgstate } if
- % Restore graphics state, but do not modify path. Paths are not part
- % of the PDF graphics state; see 4.4.1 of PDF reference 3rd ed.
- % Collecting the path with one ctm and re-playing it with another ctm
- % transforms the path exactly as PDF needs.
- {.getpath} stopped {
- ( **** Error: unable to preserve current path, probable degenerate CTM, output may be incorrect.\n) pdfformaterror
- grestore newpath
- }{
- grestore newpath { exec } forall
- } ifelse
- //false
- } {
- //true
- } ifelse
- } {
- //true % formaterror -- not a gsave dict
- } ifelse
- {
- (\n **** Error: File has unbalanced q/Q operators \(too many Q's\)\n Output may be incorrect.\n)
-
- //pdfdict /.Qqwarning_issued .knownget
- {
- {
- pop
- }
- {
- currentglobal //pdfdict gcheck .setglobal
- //pdfdict /.Qqwarning_issued //true .forceput
- .setglobal
- pdfformaterror
- } executeonly ifelse
- } executeonly
- {
- currentglobal //pdfdict gcheck .setglobal
- //pdfdict /.Qqwarning_issued //true .forceput
- .setglobal
- pdfformaterror
- } executeonly ifelse
- } executeonly if
-} bind executeonly odef
-
-% Save PDF gstate
-/qstate { % - qstate <qstate>
- gstate
-} bind executeonly def
-
-% Set PDF gstate
-/setqstate { % <qstate> setqstate -
- { matrix setmatrix //false upath } stopped {
- pop setgstate newpath
- } {
- % Save the CTM, set identity during the uappend, then set the CTM
- exch setgstate matrix currentmatrix matrix setmatrix
- exch newpath uappend setmatrix
- } ifelse
-} bind executeonly def
-
-% ---------------- Color setting ---------------- %
-
-/nullpatternproc { pop } bind executeonly def
-/nullpattern mark
- /PatternType 1 /PaintType 1 /TilingType 3 /BBox [0 0 1 1]
- /XStep 1 /YStep 1 /PaintProc //nullpatternproc
-.dicttomark readonly def
-
-/PDFsetpattern {
- % Since multiple patterns may share
- % same data stream, we need to ensure
- % that the stream is at 0 position.
- % Making this consistently with resolveshading,
- % which applies ReusableStreamDecode filter
- % to the PS stream, which represents the
- % PDF stream in dynamics.
-
- dup /Shading knownoget {
- dup /ShadingType oget 4 ge {
- /DataSource knownoget {
- dup type /filetype eq {
- 0 setfileposition
- } {
- pop
- } ifelse
- } if
- } {
- pop
- } ifelse
- } if
-
- % Associate pattern instance with the default qstate for the context.
- % A single pattren object can be reused in several contexts.
- dup DefaultQstate .knownget {
- exch pop
- } {
- % But don't update read-only initial null pattern.
- dup /PaintProc .knownget { //nullpatternproc ne } { //true } ifelse {
- dup dup /Matrix knownoget not { { 1 0 0 1 0 0 } } if
-
- gsave
- .currentfillconstantalpha
- .currentstrokeconstantalpha
- DefaultQstate setqstate
- .setstrokeconstantalpha
- .setfillconstantalpha
- makepattern
- grestore
-
- dup 3 1 roll
- DefaultQstate exch put
- } if
- } ifelse
-} bind executeonly def
-
-/CSdict mark
- /DeviceGray { 0 } bind executeonly
- /DeviceRGB { [0 0 0] cvx } bind executeonly
- /DeviceCMYK { [0 0 0 1] cvx } bind executeonly
- /CIEBasedA { 0 } bind executeonly
- /CIEBasedABC { [0 0 0] cvx } bind executeonly
- /CalGray { 0 } bind executeonly
- /CalRGB { [0 0 0] cvx } bind executeonly
- /Lab {[0 0 0] cvx } bind executeonly
- /ICCBased { [ 1 index 1 oget /N get { 0 } repeat ] cvx } bind executeonly
- /Separation { 1 } bind executeonly
- /DeviceN { % What is the correct value??
- [ 1 index 1 get length { 1 } repeat ] cvx
- } bind executeonly
- /Indexed { 0 } bind executeonly
- /Pattern { //nullpattern matrix makepattern } bind executeonly
-.dicttomark readonly def
-
-/ri {//.renderingintentdict exch .knownget { .setrenderingintent } if } bind executeonly def
-/g {/DeviceGray .setfillcolorspace .setfillcolor } bind executeonly def
-/G {/DeviceGray .setstrokecolorspace .setstrokecolor} bind executeonly def
-/rg {/DeviceRGB .setfillcolorspace .setfillcolor} bind executeonly def
-/RG {/DeviceRGB .setstrokecolorspace .setstrokecolor} bind executeonly def
-/k {/DeviceCMYK .setfillcolorspace .setfillcolor} bind executeonly def
-/K {/DeviceCMYK .setstrokecolorspace .setstrokecolor} bind executeonly def
-/cs {dup dup type /nametype ne { 0 get } if
- dup /ICCBased eq {
- 1 index 1 get /OrigN .knownget not {1 index 1 get /N get} if mark
- 4 2 roll
- //CSdict exch get exec exch .setfillcolorspace exec {.setfillcolor} stopped
- {
- cleartomark
- [//null /DeviceGray //null /DeviceRGB /DeviceCMYK] exch
- {get} stopped
- {
- ( **** Error: Unable to set an ICCBased colour space, and cannot set an alternate from the number of components.\n) print
- /setcolorspace cvx /undefined signalerror
- }
- {
- dup //null eq {
- ( **** Error: Unable to set an ICCBased colour space, and cannot set an alternate from the number of components.\n) print
- /setcolorspace cvx /undefined signalerror
- }{
- ICCProfileNError flush not {
- ( **** Warning : Error setting an ICCBased colour space, using /N to set an alternate device space.\n) print
- ( Output may be incorrect.\n) print
- } if
- setcolorspace
- /ICCProfileNError where {/ICCProfileNError //true put} if
- } ifelse
- }ifelse
- }{
- cleartomark pop
- }
- ifelse
- } {
- //CSdict exch get exec exch .setfillcolorspace exec .setfillcolor
- } ifelse
-} bind executeonly def
-/CS {dup dup type /nametype ne { 0 get } if
- dup /ICCBased eq {
- 1 index 1 get /OrigN .knownget not {1 index 1 get /N get} if mark
- 4 2 roll
- //CSdict exch get exec exch .setstrokecolorspace exec {.setstrokecolor} stopped
- {
- cleartomark
- [//null /DeviceGray //null /DeviceRGB /DeviceCMYK] exch
- {get} stopped
- {
- ( **** Error: Unable to set an ICCBased colour space, and cannot set an alternate from the number of components.\n) print
- /setcolorspace cvx /undefined signalerror
- }
- {
- dup //null eq {
- ( **** Error: Unable to set an ICCBased colour space, and cannot set an alternate from the number of components.\n) print
- /setcolorspace cvx /undefined signalerror
- }{
- ICCProfileNError flush not {
- ( **** Warning : Error setting an ICCBased colour space, using /N to set an alternate device space.\n) print
- ( Output may be incorrect.\n) print
- } if
- setcolorspace
- /ICCProfileNError where {/ICCProfileNError //true put} if
- } ifelse
- }ifelse
- }{
- cleartomark pop
- }
- ifelse
- } {
- //CSdict exch get exec exch .setstrokecolorspace exec .setstrokecolor
- } ifelse
-} bind executeonly def
-/sc {.setfillcolor} bind executeonly def
-/SC {.setstrokecolor} bind executeonly def
-/sc* {.setfillcolor} bind executeonly def
-/SC* {.setstrokecolor} bind executeonly def
-/sc*_and_set {
- dup type /dicttype eq
- {
- dup /Type known
- {
- dup /Type get /Pattern eq {PDFsetpattern} if
- }
- {
- dup /PatternType known {PDFsetpattern} if
- } ifelse
- } if
- .setfillcolor
-} bind executeonly def
-/SC*_and_set {
- dup type /dicttype eq
- {
- dup /Type known
- {
- dup /Type get /Pattern eq {PDFsetpattern} if
- }
- {
- dup /PatternType known {PDFsetpattern} if
- } ifelse
- } if
- .setstrokecolor
-} bind executeonly def
-/sc1 {.setfillcolor} bind executeonly def
-/SC1 {.setstrokecolor} bind executeonly def
-/sc1_and_set {
- dup type /dicttype eq
- {
- dup /Type known
- {
- dup /Type get /Pattern eq {PDFsetpattern} if
- }
- {
- dup /PatternType known {PDFsetpattern} if
- } ifelse
- } if
- .setfillcolor
-} bind executeonly def
-/SC1_and_set {
- dup type /dicttype eq
- {
- dup /Type known
- {
- dup /Type get /Pattern eq {PDFsetpattern} if
- }
- {
- dup /PatternType known {PDFsetpattern} if
- } ifelse
- } if
- .setstrokecolor
-} bind executeonly def
-/csput {dup dup type /nametype ne { 0 get } if //CSdict exch get exec exch 2 copy .setfillcolorspace exec .setfillcolor .setstrokecolorspace exec .setstrokecolor} bind executeonly def
-/csset {dup dup type /nametype ne { 0 get } if //CSdict exch get exec exch} bind executeonly def
-
-% ---------------- Color setting ---------------- %
-
-
-% ---------------- Overprint/transparency setting ---------------- %
-
-/op { .setfilloverprint
-} bind executeonly def % NB pdf_draw:gsparamdict handled /OP with no /op
-/OP { .setstrokeoverprint
-} bind executeonly def
-/OPM {
- /.setoverprintmode where { pop dup .setoverprintmode .swapcolors .setoverprintmode .swapcolors } { pop } ifelse
-} bind executeonly def
-/ca { .setfillconstantalpha } bind executeonly def
-/CA { .setstrokeconstantalpha } bind executeonly def
-/SMask {
- dup type /booleantype eq {
- .currentSMask type /dicttype eq {
- .currentSMask /Processed 2 index .forceput
- } executeonly
- {
- .setSMask
- }ifelse
- } executeonly
- {
- .setSMask
- }ifelse
-
- %% This is some craziness to do with annotations and graphics states
- %% the original nodict can't be written to, and we haven't (I think) done
- %% a gsave, so we haven't copied it to /self, if we don't do that here
- %% then transparent annotations cause an invalid access error.
- currentdict //nodict eq {/self dup load end 5 dict begin def} if
-} bind executeonly odef
-/AIS { .setalphaisshape } bind executeonly def
-/BM {
- /.setblendmode where {
- pop [ exch dup type /nametype ne { aload pop } if /Normal ] {
- { .setblendmode } //.internalstopped exec not { exit } if pop
- } forall
- } {
- pop
- } ifelse
-} bind executeonly def
-/TK {
- /.settextknockout where { pop .settextknockout } { pop } ifelse
-} bind executeonly def
-
-/UseBlackPtComp {
- %% Our implementation of black point compensation uses 0 or 1, not a boolean
- /.setblackptcomp where {pop //false eq {0}{1}ifelse .setblackptcomp }{ pop } ifelse
-} bind executeonly def
-
-% ---------------- Color installation ---------------- %
-
-% Establish a given color (and color space) as current.
-/.settransparencyparams { % <smask> .settransparencyparams -
- PDFusingtransparency {
- .currentalphaisshape
- {
- 1
- } {
- 0
- } ifelse
- % Set the soft mask by rendering the XObject. Doing this every time
- % is obviously very inefficient; we'll improve it later.
- .settransparencymask
- } {
- pop
- } ifelse
-} bind executeonly def
-/.settransparencymask { % <paramdict> <masknum> .settransparencymask -
- exch dup type /dicttype ne {
- PDFusingtransparency {
- pop pop
- } {
- dup /Draw get exec
- } ifelse
- } {
- dup /Processed .knownget {
- {
- pop pop
- } {
- dup /Draw get exec
- }ifelse
- }{
- dup /Draw get exec
- } ifelse
- } ifelse
-} bind executeonly def
-/setsmaskstate {
- .currentSMask .settransparencyparams
-} bind executeonly def
-/Cdict 15 dict dup begin % <color...> <colorspace> -proc- -
- /DeviceGray { pop setgray } bind executeonly def
- /DeviceRGB { pop setrgbcolor } bind executeonly def
- /DeviceCMYK { pop setcmykcolor } bind executeonly def
- /CIEBasedA { setgcolorspace setcolor } bind executeonly def
- /CIEBasedABC /CIEBasedA load def
- /CIEBasedDEF /CIEBasedA load def
- /CIEBasedDEFG /CIEBasedA load def
- /CalRGB /CIEBasedA load def
- /CalGray /CIEBasedA load def
- /Lab /CIEBasedA load def
- %% This section is to deal with the horrible pair of files in Bug #696690 and Bug #696120
- %% These files have ICCBased spaces where the value of /N and the number of components
- %% in the profile differ. In addition the profile in Bug #696690 is invalid. In the
- %% case of Bug #696690 the /N value is correct, and the profile is wrong, in the case
- %% of Bug #696120 the /N value is incorrect and the profile is correct.
- %% We 'suspect' that Acrobat uses the fact that Bug #696120 is a pure image to detect
- %% that the /N is incorrect, we can't be sure whether it uses the profile or just uses
- %% the /N to decide on a device space. What we now do is; If the /N and device profile
- %% number of components don't match, we assume the device profile is correct and patch
- %% /N to be the same as the profile (see /ICCBased-resolve), but we save the original
- %% value of /N in /OrigN. In setcolor, if the space is a genuine ICCBased space
- %% (not a replacement for a device profile) we call set_dev_color which will actually
- %% exercise the profile. If that fails we return an error. Here we run setcolor in a
- %% stopped context, and if it fails we check to see if there is a /OrigN (ths occurs
- %% only if the /N was different to the number of components in the profile). If there
- %% is a /OrigN then prefer that to the profile, otherwise they agreed, so just use
- %% /N and select a device space. If we can't select a device space with the correct
- %% number of components, give up and throw an error. See also /last-ditch-bpc-csp
- %% in pdf_draw.ps.
- /ICCBased {
- dup 1 get
- dup /OrigN .knownget {exch /N get}{/N get dup} ifelse
- 3 add mark exch 2 roll
- setgcolorspace {setcolor} stopped
- {
- cleartomark
- [//null /DeviceGray //null /DeviceRGB /DeviceCMYK] exch
- {get} stopped
- {
- ( **** Error: Unable to set an ICCBased colour space, and cannot set an alternate from the number of components.\n) print
- /setcolorspace cvx /undefined signalerror
- }
- {
- dup //null eq {
- ( **** Error: Unable to set an ICCBased colour space, and cannot set an alternate from the number of components.\n) print
- /setcolorspace cvx /undefined signalerror
- }{
- ICCProfileNError flush not {
- ( **** Warning : Error setting an ICCBased colour space, using /N to set an alternate device space.\n) print
- ( Output may be incorrect.\n) print
- } if
- setcolorspace
- /ICCProfileNError //true def
- } ifelse
- }ifelse
- }{
- cleartomark pop
- }
- ifelse
- } bind executeonly def
- /Separation /CIEBasedA load def
- /DeviceN /CIEBasedA load def
- /Indexed /CIEBasedA load def
- /Pattern
- { setgcolorspace
-
- % Since multiple patterns may share
- % same data stream, we need to ensure
- % that the stream is at 0 position.
- % Making this consistently with resolveshading,
- % which applies ReusableStreamDecode filter
- % to the PS stream, which represents the
- % PDF stream in dynamics.
-
- dup /Shading knownoget {
- dup /ShadingType oget 4 ge {
- /DataSource knownoget {
- dup type /filetype eq {
- 0 setfileposition
- } {
- pop
- } ifelse
- } if
- } {
- pop
- } ifelse
- } if
-
- % Associate pattern instance with the default qstate for the context.
- % A single pattren object can be reused in several contexts.
- dup DefaultQstate .knownget {
- exch pop
- } {
- % But don't update read-only initial null pattern.
- dup /PaintProc .knownget { //nullpatternproc ne } { //true } ifelse {
- dup dup /Matrix knownoget not { { 1 0 0 1 0 0 } } if
-
- gsave
- .currentfillconstantalpha
- .currentstrokeconstantalpha
- DefaultQstate setqstate
- .setstrokeconstantalpha
- .setfillconstantalpha
- makepattern
- grestore
-
- dup 3 1 roll
- DefaultQstate exch put
- } if
- } ifelse
- setcolor
- } bind executeonly def
-end def
-/setgcolor % (null | <color...>) <colorspace> setgcolor -
- { 1 index //null eq
- { pop pop }
- { dup 0 get //Cdict exch get exec }
- ifelse
- } bind executeonly def
-% Compare the old and new color spaces in an attempt to avoid expensive
-% reloads of CIEBased color spaces.
-/PCSdict 15 dict dup begin % <colorspace> -proc- <colorspace|pdfcspace>
- /CIEBasedA { dup 1 get /PDFColorSpace .knownget { exch pop } if } bind executeonly def
- /CIEBasedABC /CIEBasedA load def
- /CIEBasedDEF /CIEBasedA load def
- /CIEBasedDEFG /CIEBasedA load def
- /Indexed {
- dup 1 get dup pdfcolorspace 2 copy ne { 3 1 roll } if pop pop
- } bind executeonly def
-end def
-/pdfcolorspace { % <colorspace> pdfcolorspace <colorspace|pdfcspace>
- dup type /arraytype eq {
- //PCSdict 1 index 0 get .knownget { exec } if
- } if
-} bind executeonly def
-/setgcolorspace { % <colorspace> setgcolorspace -
- dup pdfcolorspace currentcolorspace pdfcolorspace eq {
- pop
- } {
- setcolorspace
- } ifelse
-} bind executeonly def
-
-/OPsaveDstack 6 dict def % for GroupPushed, saveOP, saveFillAlpha, saveBM
-//OPsaveDstack begin
- /GroupPushed //false def
- /ChangeBM //false def
- /saveStrokeAlpha 1 def
- /saveFillAlpha 1 def
- /saveBM /Normal def
- /previous 1 dict def % for nested setup_trans levels
-end
-
-/Dpush {
- .currentglobal //true .setglobal % 'previous' dict must be in global VM
- //OPsaveDstack 6 dict 1 index { 2 index 3 1 roll put } forall /previous exch put
- .setglobal
-} def
-/Dpop { //OPsaveDstack begin previous { def } forall end } def
-
-% colorspaces that require special overprint transparency handling
-/specialOPcs mark /DeviceGray 0 /DeviceCMYK 1 /DeviceN 2 /Separation 3 .dicttomark def
-
-% Take care of pushing a transparency group if we need it for SMask or for Overprint..
-% After pushing the group, we save the ca and CA and change them
-% both to 1. For overprint if the colorspace is acceptable, also change to
-% CompatibleOverprint if the device needs it.
-
-% NB: setup_trans is defined as either setupOPtrans (for devices that can support
-% overprint, or as setupSMtrans which pushes a group for SMask.
-% Also see 'teardown_trans' that pops the group and resets the changed values.
-/setupOPtrans % [ pathbbox ] <fillop|strokeop> setup_trans
-{ % Check OP and BM in case we need to push a group
- //OPsaveDstack begin
- //Dpush exec % push the current OPsaveDstack values into 'previous'
- /SupportsDevn .special_op
- specialOPcs currentcolorspace 0 get dup /Indexed eq {
- pop currentcolorspace 1 get % use the base space
- } if
- known or {
- dup /stroke ne {
- .currentfilloverprint
- 1 index dup /.fillstroke eq exch /.eofillstroke eq or {
- .currentstrokeoverprint or
- } if
- } {
- .currentstrokeoverprint
- } ifelse
- % Change BM to CompatibleOverprint if this has overprint true
- dup /ChangeBM exch def
- .currentblendmode dup /Normal eq exch /Compatible eq or
- not and
- } {
- //false
- } ifelse
- .currentSMask //null ne or { % push a group for OP or SMask
- % It should only be isolated if there is a softmask and the blend mode is not normal (or compatible)
- mark /Subtype /Group /Isolated .currentSMask //null ne .currentblendmode /Normal ne and .currentblendmode /Compatible ne and .dicttomark
- 2 index aload pop % pathbbox
- .begintransparencygroup
- % After group pushed, set alphas and blendmode
- /saveStrokeAlpha .currentstrokeconstantalpha def
- /saveFillAlpha .currentfillconstantalpha def
- 1 .setfillconstantalpha 1 .setstrokeconstantalpha
- /GroupPushed //true def
- } {
- /GroupPushed //false def
- } ifelse
- % we may change to CompatibleOverprint even if we didn't push a group.
- ChangeBM {
- /saveBM .currentblendmode def /CompatibleOverprint .setblendmode
- } if
- pop % fillop/strokeop
- pop % pathbbox array
- end % OPsaveDstack
-} bind executeonly def
-
-% Also see 'teardown_trans' that pops the group and resets the changed values.
-/setupSMtrans % [ pathbbox ] <fillop|strokeop> setup_trans
-{
- //OPsaveDstack begin
- //Dpush exec % push the current OPsaveDstack values into 'previous'
- .currentSMask //null ne 1 index /image ne and % only push for SMask if not from image
- {
- mark /Subtype /Group /Isolated //true .dicttomark
- 2 index aload pop % pathbbox
- .begintransparencygroup
- % After group pushed, set alphas and blendmode
- /saveStrokeAlpha .currentstrokeconstantalpha def
- /saveFillAlpha .currentfillconstantalpha def
- 1 .setfillconstantalpha 1 .setstrokeconstantalpha
- /GroupPushed //true def
- } {
- /GroupPushed //false def
- } ifelse
- end % OPsaveDstack
- pop % fillop/strokeop
- pop % pathbbox array
-} bind executeonly def
-
-% If a transparency group was pushed, pop it, and reset the settings.
-% Used after setup_trans
-/teardown_trans {
- //OPsaveDstack begin
- GroupPushed {
- % pop the group, then restore the alphas
- .endtransparencygroup % end the group
- saveStrokeAlpha .setstrokeconstantalpha saveFillAlpha .setfillconstantalpha
- } if
- % Also, if we changed the BM, restore it (AFTER the group was popped)
- .currentblendmode /CompatibleOverprint eq {
- % restore the blendmode
- saveBM .setblendmode
- } if
- end % OPsaveDstack
- //Dpop exec % load previous OPsaveDstack contents
-} bind executeonly def
-
-currentdict dup /Dpush .undef /Dpop .undef
-
-% ------------------------------------------------------------ %
-/fsexec % <fillop|strokeop> fsexec -
-{
- PDFusingtransparency {
- dup /stroke eq 1 index /.fillstroke eq or 1 index /.eofillstroke eq or {
- % BBox needs to include line width / line join expansion.
- % strokepath will return empty path (no currentpoint) if nothing is stroked
- { gsave strokepath pathbbox } stopped grestore {
- % If we get an error, just emit an empty box
- 0 0 0 0
- } if
- } {
- % If we get an error, just emit an empty box
- { pathbbox } stopped { 0 0 0 0 } if
- } ifelse
- % pathbbox valid -- proceed with drawing
- 4 array astore % pathbbox
- 1 index
- setup_trans
- cvx exec
- teardown_trans
- } {
- cvx exec
- } ifelse
-} bind executeonly def
-
-% ---------------- Path painting and clipping ---------------- %
-
-%% Bug #696017 In order to get the correct position of paths and other objects which
-%% are illegally present inside a text block, we need to use the saved TextSaveMatrix
-%% to construct/place them. But we don't want to do lots of lookups on every segment of
-%% a path (we feel its OK to do lookups for images). So what we do is redefine the
-%% path contruction operators at the beginning of a text block, and put them back afterwards.
-%% Here we define the 'normal' and 'inside text' versions of those operators, and routines
-%% to switch the definitions back and forth.
-
-/check_and_set_saved_matrix {
- currentdict /TextSaveMatrix known {
- currentdict /TextSaveMatrix get setmatrix
- }
- {
- currentdict /qTextSaveMatrix known {
- currentdict /qTextSaveMatrix get setmatrix
- } if
- } ifelse
-} bind executeonly def
-
-/normal_m { { moveto } stopped { count pdfemptycount sub 2 .min { pop } repeat 0 0 moveto } if } bind executeonly def
-/inside_text_m {
- {
- matrix currentmatrix 3 1 roll
- check_and_set_saved_matrix
- moveto
- setmatrix
- }
- stopped { count pdfemptycount sub 2 .min { pop } repeat 0 0 moveto } if
-} bind executeonly def
-
-/normal_l { { lineto } stopped { count pdfemptycount sub 2 .min { pop } repeat } if } bind executeonly def
-/inside_text_l {
- {
- matrix currentmatrix 3 1 roll
- check_and_set_saved_matrix
- lineto
- setmatrix
- }
- stopped { count pdfemptycount sub 2 .min { pop } repeat } if
-} bind executeonly def
-
-/normal_c { { curveto } stopped { count pdfemptycount sub 6 .min { pop } repeat } if } bind executeonly def
-/inside_text_c {
- {
- matrix currentmatrix 7 1 roll
- check_and_set_saved_matrix
- curveto
- setmatrix
- }
- stopped { count pdfemptycount sub 6 .min { pop } repeat } if
-} bind executeonly def
-
-/normal_v { count pdfemptycount sub 4 ge {
- { currentpoint 6 2 roll curveto } stopped { count pdfemptycount sub 6 .min { pop } repeat } if
- } {
- count pdfemptycount sub { pop } repeat
- } ifelse
- } bind executeonly def
-/inside_text_v { count pdfemptycount sub 4 ge {
- {
- matrix currentmatrix 5 1 roll
- check_and_set_saved_matrix
- currentpoint 6 2 roll curveto
- setmatrix
- } stopped { count pdfemptycount sub 6 .min { pop } repeat } if
- } {
- count pdfemptycount sub { pop } repeat
- } ifelse
- } bind executeonly def
-
-/normal_y { { 2 copy curveto } stopped { count pdfemptycount sub 6 .min { pop } repeat } if } bind executeonly def
-/inside_text_y {
- {
- matrix currentmatrix 5 1 roll
- check_and_set_saved_matrix
- 2 copy curveto
- setmatrix
- }
- stopped { count pdfemptycount sub 6 .min { pop } repeat } if
-} bind executeonly def
-
-/normal_re {
- 4 2 roll moveto exch dup 0 rlineto 0 3 -1 roll rlineto neg 0 rlineto
- closepath
- } bind executeonly def
-/inside_text_re {
- matrix currentmatrix 5 1 roll
- check_and_set_saved_matrix
- 4 2 roll moveto exch dup 0 rlineto 0 3 -1 roll rlineto neg 0 rlineto
- closepath
- setmatrix
- } bind executeonly def
-
-/S {
- OFFlevels length 0 eq {
- setsmaskstate .swapcolors /stroke fsexec .swapcolors
- } {
- newpath
- } ifelse
-} bind executeonly def
-
-/f {
- OFFlevels length 0 eq {
- setsmaskstate /fill fsexec
- } {
- newpath
- } ifelse
-} bind executeonly def
-
-/f* {
- OFFlevels length 0 eq {
- setsmaskstate /eofill fsexec
- } {
- newpath
- } ifelse
-} bind executeonly def
-
-/n { newpath } bind executeonly def % don't allow n to get bound in
-
-/s { closepath S } bind executeonly def
-
-/B {
- OFFlevels length 0 eq {
- setsmaskstate /.fillstroke fsexec
- } {
- newpath
- } ifelse
-} bind executeonly def
-
-/b { closepath B } bind executeonly def
-
-/B* {
- OFFlevels length 0 eq {
- setsmaskstate /.eofillstroke fsexec
- } {
- newpath
- } ifelse
-} bind executeonly def
-
-/b* { closepath B* } bind executeonly def
-
-% Clipping:
-
-/Wdict 8 dict dup begin
-/S { OFFlevels length 0 eq { gsave setsmaskstate .swapcolors stroke .swapcolors grestore } if n } bind executeonly def
-/f { OFFlevels length 0 eq { gsave setsmaskstate fill grestore } if n } bind executeonly def
-/f* { OFFlevels length 0 eq { gsave setsmaskstate eofill grestore } if n } bind executeonly def
-/B {
- OFFlevels length 0 eq {
- .fillstroke
- } if
- n
-} bind executeonly def
-/b { closepath B } bind executeonly def
-/B* {
- OFFlevels length 0 eq {
- .eofillstroke
- } if
- n
-} bind executeonly def
-/b { closepath B* } bind executeonly def
-/n { end .currentpoint_valid { clip } if newpath } bind executeonly def
-end readonly def
-/W { //Wdict begin } bind executeonly def
-/W*dict 8 dict dup begin
-Wdict { def } forall
-/n { end .currentpoint_valid { eoclip } if newpath } bind executeonly def
-end readonly def
-/W* { //W*dict begin } bind executeonly def
-% ---------------- Text control ---------------- %
-
-/textbeginpage
- {
- 1.0 .settexthscaling
- /FontMatrixNonHV //false def
- /Show { showfirst } def
- /TextFillStateNeeded //true def
- } bind executeonly def
-
-/TestDegenerateCTM {
- matrix currentmatrix
- dup 0 get
- exch dup 3 get
- exch dup 1 get
- exch 2 get
- mul
- 3 1 roll mul
- exch sub
- 0 eq {
- //true
- }{
- //false
- } ifelse
-} bind executeonly def
-
-% Contrary to the statement in the PDF manual, BT and ET *can* be nested,
-% if the CharProc for a Type 3 font does a BT/ET itself.
-% Since we always call the CharProc inside a q/Q, we simply ensure that
-% the text state is saved and restored like the rest of the extended
-% graphics state.
-
-/settextmatrix {
- matrix currentmatrix
- matrix .currenttextmatrix
- concat
- TestDegenerateCTM {
- (\n **** Error: Degenerate text matrix detected, ignoring Tm operation\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- setmatrix
- } {
- pop
- } ifelse
- .currenttexthscaling
- 1 ne { .currenttexthscaling
- 1 scale } if
- .currenttextrise 0 ne { 0 .currenttextrise
- translate } if
-} bind executeonly def
-
-/unsettextmatrix {
- .currenttextrise 0 ne {
- 0 .currenttextrise neg translate
- } if
- .currenttexthscaling 1 ne {
- 1 .currenttexthscaling div 1 scale
- } if
- matrix currentmatrix
- matrix .currenttextmatrix matrix invertmatrix concat setmatrix
-} bind executeonly def
-
-/settextstate {
- % The text state can be set even outside BT/ET.
- currentdict /TextSaveMatrix known {
- TextSaveMatrix
- aload pop
- 5 index 0 ne 3 index 0 ne and
- 5 index 0 ne 5 index 0 ne and or not {
- (\n **** Error: Invalid (0 scaling) text matrix for Tm ****\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- % handle invalid scale by using a really small value
- 2 -6 roll pop pop pop pop
- 0.00000001 0 0 0.00000001
- 6 -2 roll
- }if
- 6 array astore
- setmatrix settextmatrix
- } if
- currentdict /qTextSaveMatrix known {
- qTextSaveMatrix
- aload pop
- 5 index 0 ne 3 index 0 ne and
- 5 index 0 ne 5 index 0 ne and or not {
- (\n **** Error: Invalid (0 scaling) text matrix for Tm ****\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- % handle invalid scale by using a really small value
- 2 -6 roll pop pop pop pop
- 0.00000001 0 0 0.00000001
- 6 -2 roll
- }if
- 6 array astore
- setmatrix settextmatrix
- } if
-} bind executeonly def
-/settextposition {
- % Update the TextMatrix translation.
- gsave TextSaveMatrix setmatrix
- .currentpoint_valid {
- currentpoint
- .currenttextrise
- sub
- matrix .currenttextmatrix
- dup 5 4 -1 roll put
- dup 4 4 -1 roll put
- .settextmatrix
- % We would like to do "grestore currentpoint translate"
- % here, but some PDF files set a singular text matrix
- % (0 0 0 0 <x> <y> Tm), so we can't do this.
- TextTempMatrix identmatrix setmatrix currentpoint
- matrix .currenttextmatrix
- grestore
- .settextmatrix
- TextTempMatrix currentmatrix 4 2 getinterval astore pop
- TextTempMatrix setmatrix
- } {
- ( **** Error: Invalid currentpoint, probable degenerate CTM.\n) pdfformaterror
- ( Ignroing error, output may be incorrect.\n) pdfformaterror
- grestore
- } ifelse
-} bind executeonly def
-
-%% Do not make the procedures here executeonly. The /m procedure is
-%% tested in /.pdf_paintproc in pdf_draw.ps, we need to be able to
-%% read the name of the procedure from here in order to determine
-%% whether we are inside a text block. The procedures themselves
-%% are already executeonly anyway.
-
-/switch_to_text_marking_ops {
- pdfopdict /m {inside_text_m} bind .forceput
- pdfopdict /l {inside_text_l} bind .forceput
- pdfopdict /c {inside_text_c} bind .forceput
- pdfopdict /v {inside_text_v} bind .forceput
- pdfopdict /y {inside_text_y} bind .forceput
- pdfopdict /re {inside_text_re} bind .forceput
-} bind executeonly odef
-
-/switch_to_normal_marking_ops {
- pdfopdict /m {normal_m} bind .forceput
- pdfopdict /l {normal_l} bind .forceput
- pdfopdict /c {normal_c} bind .forceput
- pdfopdict /v {normal_v} bind .forceput
- pdfopdict /y {normal_y} bind .forceput
- pdfopdict /re {normal_re} bind .forceput
-} bind executeonly odef
-
-/BT {
- % Bug 703996 has a path defined before BT, then stroked afterwards
- .currentpoint_valid { //false upath } { //null } ifelse
- /BT_upath gput
- //false /illegal_BT gput
- currentdict /TextSaveMatrix known {
- ( **** Error: illegal nested BT operator detected.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- ET_NO_TXT_KO %% Does not push any compositor actions
- //true /illegal_BT gput
- } if
-
- %% Bug #695897 see the explanation in /q defined above.
- currentdict /qTextSaveMatrix known {
- currentdict /qTextSaveMatrix get /TextSaveMatrix gput
- ( **** Error: Illegal nested BT operator (inside a gsave) detected.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- ET_NO_TXT_KO %% Does not push any compositor actions
- //true /illegal_BT gput
- } if
- currentdict /n known {
- currentdict end
- /.W exch def
- } if
- matrix .settextlinematrix
- matrix .settextmatrix
-
- { showfirst } /Show gput
- currentdict /TextSaveMatrix .knownget not {
- matrix dup /TextSaveMatrix gput
- } if currentmatrix pop settextmatrix
- matrix /TextTempMatrix gput % see settextposition
-
- %% Set the special version of the path constructoin operators, so that
- %% they will work as expected if they are illgeally present in a text block.
- switch_to_text_marking_ops
-
- %% If needed, let the pdf14 device know we are in a BT condition. This
- %% distinguishes BT from an Annotation /FreeText show command which also
- %% can come into pdf_text_begin with an opacity not equal to 1.
- PDFusingtransparency .currenttextknockout and
- currentdict /illegal_BT get not and
- {
- .begintransparencytextgroup
- } if
-
-} bind executeonly def
-
-/clip_if_required {
- .currenttextrenderingmode 4 ge
- .currentpoint_valid
- and
- { .currentfilladjust2 0 dup .setfilladjust2 clip .setfilladjust2} if
- newpath
-} bind def
-
-/ET_NO_TXT_KO {
- currentdict /TextSaveMatrix known {
- //clip_if_required exec
- TextSaveMatrix setmatrix
- currentdict /TextSaveMatrix undef
-
- % if we were in a W/W* context, grab the dict, undefine temp entry for it,
- % and push it back on the dict stack
- currentdict /.W known {
- .W
- currentdict /.W undef
- begin
- } if
- } {
- ( **** Error: Ignoring spurious ET operator.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- } ifelse
- %% Only switch back to the regular marking operations if we were not
- %% in a nested text block (inside a gsave).
- currentdict /qTextSaveMatrix known not {
- switch_to_normal_marking_ops
- currentdict /BT_upath get dup //null eq { pop } { newpath uappend } ifelse
- } if
-} bind executeonly def
-
-currentdict /clip_if_required .undef
-
-/ET {
- //ET_NO_TXT_KO exec
- % Group push occurred in pdf14_text_begin.
- PDFusingtransparency .currenttextknockout and {
- .endtransparencytextgroup
- } if
-} bind executeonly def
-
-/Tc {
- {.settextspacing} stopped
- {
- (\n **** Error: A ) pdfformaterror
- $error /errorname get 256 string cvs pdfformaterror
- ( error occured while setting the Text Character spacing to ) pdfformaterror
- 256 string cvs pdfformaterror
- (\n Output may be incorrect.\n) pdfformaterror
- } if
- { showfirst } /Show gput
-} bind executeonly def
-/TL { .settextleading } bind executeonly def
-/Tr { .settextrenderingmode { showfirst } /Show gput } bind executeonly def
-/Ts { .settextrise settextstate } bind executeonly def
-/Tw { .setwordspacing { showfirst } /Show gput } bind executeonly def
-/Tz {
- dup 0 eq {
- (\n **** Error: Invalid 0.0 horizontal text scaling given for Tz\n)
- ( Output may be incorrect.\n) pdfformaterror
- pdfformaterror
- pop 0.00000001 % handle invalid scale by using a really small value
- }{
- 100 div
- }ifelse .settexthscaling %/TextHScaling gput
- settextstate} bind executeonly def
-
-% ---------------- Font control ---------------- %
-
-% Test if the FontMatrix could transform a horizontal/vertical (depending
-% on writing mode) advance vector in glyph space into one with a different
-% direction in text space.
-% - if FontMatrix = [a b c d tx ty], this condition translates to:
-% b != 0 for horizontal writing mode
-% c != 0 for vertical writing mode
-% - when false, we automatically have wy/x == 0 in text space whenever wy/x == 0
-% in glyph space, and can avoid the slow method that is otherwise necessary
-% to implement zeroing wy/x cf PDF Ref 5.3.3 "Text space details"
- % Worker procedure for testing a single font matrix
-/?FontMatrixNonHV { % ?horz <<fontdict>> -- ?horz ?nonhv
- /FontMatrix .knownget {
- 1 index { 1 } { 2 } ifelse get 0 ne
- } {
- //false
- } ifelse
-} bind executeonly def
- % Worker procedure for recursive checking of font matrices
-/?FontMatrixNonHV { % {self} ?horz <<font>> -- {self} ?horz ?nonhv
- 2 copy //?FontMatrixNonHV exec { % check the font's own FontMatrix
- pop pop //true
- } {
- % look for descendents/ components
- pop % {self} ?horz <<font>>
- dup /FontType get
- dup 0 eq { % Type 0: look into FDepVector
- pop /FDepVector get 2 index % {self} ?horz [fonts..] {testproc}
- } {
- 9 eq { % Type 9 (CIDFontType 0): check FDArray
- /FDArray get //?FontMatrixNonHV
- } { % all others: nothing more to check
- pop {} {}
- } ifelse
- } ifelse
- %stack: {self} ?horz [fonts..] {testproc}
- //false 5 2 roll { % {testproc} false {self} ?horz <<subfont>>
- 4 index exec {
- 4 -1 roll pop //true 4 1 roll
- exit
- } if
- } forall
- %stack: {testproc} ?nonhv {self} ?horz
- 4 2 roll exch pop
- } ifelse
-} bind executeonly def
- % Main procedure
-/?FontMatrixNonHV { % <<rootfont>> -- ?nonhv
- //?FontMatrixNonHV exch
- % determine WMode
- dup /WMode .knownget { 0 eq } { //true } ifelse % {proc} <<rootfont>> ?horz
- exch
- % call the worker procedure
- //?FontMatrixNonHV exec
- exch pop exch pop
-} bind executeonly def
-
-/Tf { % <font> <scale> Tf -
- dup .setPDFfontsize
- dup 0 eq {
- pop 0.00000001 % handle invalid scale by using a really small value
- } if
- 1 index type /dicttype ne {
- selectfont currentfont
- } {
- dup 1 eq { pop } { scalefont } ifelse
- }
- ifelse
- dup ?FontMatrixNonHV dup FontMatrixNonHV ne {
- /FontMatrixNonHV gput
- { showfirst } /Show gput
- } {
- pop
- } ifelse
- setfont
-} bind executeonly def
-
-% Copy a font, removing its FID. If changed is true, also remove
-% the UniqueID and XUID, if any. If the original dictionary doesn't have
-% the keys being removed, don't copy it.
-/.copyfontdict % <font> <changed> .copyfontdict <dict>
- {
- 1 index /.OrigUniqueIDXUID .knownget
- {//false}
- {
- 1 index /XUID .knownget
- {
- //true 1 index {0 gt and} forall
- {//false}{pop //true} ifelse
- }
- {
- //true
- }ifelse
- } ifelse
-
- {
- 1 index /UniqueID .knownget
- {[exch]}{//null} ifelse
- } if
- 3 1 roll
-
- 1 index /FID known
- 1 index { 2 index /UniqueID known or 2 index /XUID known or } if
- { % We add 1 to the length just in case the original
- % didn't have a FID.
- exch dup length 1 add dict exch
- { % Stack: changed newfont key value
- 1 index /FID eq
- not { 3 copy put } if pop pop
- }
- forall exch
- }
- if pop
-
- 1 index //null eq
- {exch pop}
- {dup 3 -1 roll /.OrigUniqueIDXUID exch put}
- ifelse
-
-} bind executeonly def
-
-% Insert a new Encoding or Metrics into a font if necessary.
-% Return a possibly updated font, and a flag to indicate whether
-% the font was actually copied.
-/.updatefontmetrics { % <font> <Metrics|null> .updatefontmetrics
- % <font'> <copied>
- dup //null ne {
- exch //true .copyfontdict dup /Metrics 4 -1 roll put //true
- } {
- pop //false
- } ifelse
-} bind executeonly def
-
-/.updatefontencoding { % <font> <Encoding|null> .updatefontencoding
- % <font'> <copied>
- dup //null ne { dup 2 index /Encoding get ne } { //false } ifelse {
- exch //false .copyfontdict dup /Encoding 4 -1 roll put //true
- } {
- pop //false
- } ifelse
-} bind executeonly def
-
-% Duplicate keys in CharString dictionary according to GlyphMap: <</new_glyph /old_glyph>>
-% We have to do this because PDF fonts can associate multiple widths with the same glyph
-% but Metrics dictionary works by the glyph name.
-/.update_charstring { % <font> <GlyphMap> .update_charstring <font'> <copied>
- dup //null ne {
- exch //true .copyfontdict % map font
- dup dup /CharStrings get % map font font cstr
- dup length % map font font cstr len
- 4 index length add % map font font cstr len+map_len
- dict copy dup begin % map font font cstr'
- /CharStrings exch put % map font
- exch { % font /new /old
- currentdict exch .knownget {
- def
- } {
- currentdict /.notdef .knownget {
- def
- } {
- pop
- % The font has no .notdef.
- % Could not resolve the conflict,
- % but either the font is invalid or the glyph name is never used.
- } ifelse
- } ifelse
- } forall
- end //true
- } {
- pop //false
- } ifelse
-} bind executeonly def
-
-/.updatefont { % <font> <Encoding|null> <Metrics|null> <GlyphMap|null>
- % .updatefont <font'> <copied>
- 4 2 roll % <Metrics|null> <GlyphMap> <font> <Encoding|null>
- .updatefontencoding % <Metrics|null> <GlyphMap> <font> bool
- 4 1 roll exch % bool <Metrics|null> <font> <GlyphMap>
- .update_charstring % bool <Metrics|null> <font> bool
- 3 1 roll exch % bool bool <font> <Metrics|null>
- .updatefontmetrics % bool bool <font> bool
- 4 2 roll or or % <font> is_copied
-} bind executeonly def
-
-% ---------------- Text positioning ---------------- %
-
-/Td {
- %% Bug #695950 - invalid parameter to 'Td' operator
- %% Technically the parameters to Td are reals and can vary +/- 3.403x10^38
- %% However that would be kind of hard to validate, and in any event these
- %% are somewhat unlikely numbers. We validate against +/- 2^32 instead. If this
- %% should ever be a problem we'll have to modify this check.
- %% Testing reveals that Acrobat clamps these out of range values to 0, it doesn't
- %% simply ignore the error.
- exch dup dup 4294967295 ge exch 4294967295 neg le or {
- ( **** Error: invalid argument to Td, Treating argument as 0.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop 0
- } if
- exch dup dup 4294967295 ge exch 4294967295 neg le or {
- ( **** Error: invalid argument to Td, Treating argument as 0.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop 0
- } if
- matrix .currenttextlinematrix transform
- matrix .currenttextlinematrix
- dup 3 -1 roll 5 exch put
- dup 3 -1 roll 4 exch put
- .settextlinematrix
- matrix .currenttextlinematrix .settextmatrix
-
- settextstate
-} bind executeonly def
-/TD { dup neg .settextleading Td } bind executeonly def
-/T* { 0 .currenttextleading neg Td } bind executeonly def
-/Tm {
- 5 index 0 ne 3 index 0 ne and
- 5 index 0 ne 5 index 0 ne and or not {
- ( **** Error: Invalid (0 scaling) text matrix for Tm ****\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- % handle invalid scale by using a really small value
- 2 -6 roll pop pop pop pop
- 0.00000001 0 0 0.00000001
- 6 -2 roll
- }if
- matrix .currenttextlinematrix astore .settextlinematrix
- matrix .currenttextlinematrix .settextmatrix
- settextstate
-} bind executeonly def
-
-% ---------------- Text painting ---------------- %
-
-/Vexch {
- rootfont /WMode knownoget { 1 eq { exch } if } if
-} bind executeonly def
-
-/textrenderingprocs [ % (0 is handled specially)
- % Painting-only modes
- { tf } executeonly { tS } executeonly { tB } executeonly { tn }
- % Clipping modes
- { gsave tf grestore tW } executeonly
- { gsave tS grestore tW } executeonly
- { gsave tB grestore tW } executeonly
- { tW } executeonly
-] readonly def
-
-/pdfwrite_textrenderingprocs [
- % Tr 0 - Fill
- { setsmaskstate show } bind executeonly
- % Tr 1 - Stroke
- { currentlinewidth exch setsmaskstate
- % Need to set the stroke width to a value which gives the correct
- % width under pdfwrite. Pdfwrite uses (in text mode) an identity
- % CTM, so we need to calculate the stroke width which would result
- % if the CTM had been unity.
- calc_text_linewidth
- setlinewidth
- show setlinewidth} bind executeonly
- % Tr 2 - Fill then Stroke
- { currentlinewidth exch setsmaskstate
- % Need to set the stroke width to a value which gives the correct
- % width under pdfwrite. Pdfwrite uses (in text mode) an identity
- % CTM, so we need to calculate the stroke width which would result
- % if the CTM had been unity.
- calc_text_linewidth
- setlinewidth
- setsmaskstate show setlinewidth} bind executeonly
- % Tr 3 - Neither fill nor stroke
- { setsmaskstate show } bind executeonly
- %
- % pdfwrite emits all text inside a gsave/grestore pair. As
- % a result we can't preserve any of the 'clip' modes, as the
- % clip gets undone by the restore. We need to handle the clip
- % separately.
- %
- % Tr 4 - Fill, add to clip
- { gsave 0 .settextrenderingmode
- setsmaskstate dup show grestore //true charpath } bind executeonly
- % Tr 5 - Stroke, add to clip
- { gsave 1 .settextrenderingmode
- calc_text_linewidth
- setlinewidth
- setsmaskstate dup show grestore
- //true charpath} bind executeonly
- % Tr 6 - Fill, stroke, add to clip
- { gsave 2 .settextrenderingmode
- calc_text_linewidth
- setlinewidth
- setsmaskstate dup show grestore
- //true charpath} bind executeonly
- % Tr 7 - Add to clip
- { //true charpath} bind executeonly
-] readonly def
-
-% - calc_text_linewidth calculated_width
-% This calculates the required linewidth for stroke for *pdfwrite*, it must not be
-% used for rendering. Because pdfwrite writes text scaled into a 72 dpi resolution
-% we cannot use the current linewidth for it, it will be too large. Instead we must
-% re-calculate the original linewidth (removing the default CTM) and then apply the
-% TextSaveMatrix to find the appropriate new linewidth.
-% We check to see if the x and y scaling are approximately the same, if they are not
-% then we calculate a linewidth based on a right triangle with the x and y values
-% of the current linewidth in each direction and then calculate the hypotenuse, which
-% we then use as an approximation to the required width.
-% The 'approximation' of 0.01 is just a guess.
-/calc_text_linewidth
-{
- currentlinewidth dup
- currentdict /qTextSaveMatrix known {
- matrix defaultmatrix idtransform qTextSaveMatrix dtransform
- }{
- matrix defaultmatrix idtransform TextSaveMatrix dtransform
- } ifelse
- abs 2 copy exch abs sub abs 0.01 le {
- pop
- }{
- % We used to leave the linewidth alone for non-square resolutions,
- % claiming it reduced to the text matrix in pdfwrite. This is not
- % true. So handle it the same way we usually do, the hypotenuse of
- % the unit square transformed through the TextSaveMatrix.
- dup mul exch dup mul add sqrt 2 div
- }ifelse
-} bind executeonly def
-
-/setstrokeforTrpreservation {
- % Check to see if the current device supports Tr
- /PreserveTrMode /GetDeviceParam .special_op {
- exch pop
- }{
- //false
- }ifelse
- {
- .currenttextrenderingmode 1 eq .currenttextrenderingmode 2 eq or
- .currenttextrenderingmode 5 eq .currenttextrenderingmode 6 eq or or {
- setsmaskstate
- % Need to set the stroke width to a value which gives the correct
- % width under pdfwrite. Pdfwrite uses (in text mode) an identity
- % CTM, so we need to calculate the stroke width which would result
- % if the CTM had been unity. NOTE! Only interested in magnitudes,
- % not signs.
- calc_text_linewidth
- setlinewidth
- } if
- } if
-} bind executeonly def
-
-% conditionally set fillstate to avoid multiple operations during text operators
-/settextfillstate {
- TextFillStateNeeded { setsmaskstate //false /TextFillStateNeeded gput } if
-} bind executeonly def
-
-% If current path is not known to be valid, use the clip path
-/TextTransSetup { % showarg path_valid TextTransSetup showarg
- % showarg path_valid false TextTransSetup showarg
- gsave
- % NB: if 'show' is used, then we use the clippath, but a smaller bbox is preferred
- {
- % path was (probably) valid (CTM may not be invertable)
- % Since TR mode may include stroking, expand for stroke
- % If we get an error, just emit an empty box
- { strokepath pathbbox } stopped { 0 0 0 0 } if
- } {
- clippath pathbbox stopped { 0 0 0 0 } if
- } ifelse
- grestore
- 4 array astore //null
- setup_trans
-} bind executeonly def
-
-/TextTransTeardown {
- teardown_trans
-} bind executeonly def
-
-/setshowstate
- {
- .currentwordspacing 0 eq .currenttextspacing
- 0 eq and FontMatrixNonHV not and
- {
- % Check to see if the current device supports Tr
- /PreserveTrMode /GetDeviceParam .special_op {
- exch pop
- }{
- //false
- }ifelse
- {
- pdfwrite_textrenderingprocs .currenttextrenderingmode get
- }
- {
- .currenttextrenderingmode 0 eq
- currentfont /FontType get 3 eq .currenttextrenderingmode 3 eq not
- and or
- {
- { settextfillstate //false TextTransSetup show TextTransTeardown }
- } {
- .currenttextrenderingmode 3 eq {
- % Some PDF files execute 'tm' with a singular matrix,
- % and then use the text rendering mode 3.
- % The graphics library currently cannot handle text
- % operations when the CTM is singular.
- % Work around this here.
- {
- matrix currentmatrix
- % Previously we tested specifically for a scale factor of 0,
- % but bug #701875 has a CTM which is minute, but not zero. If
- % we try to use that at anything except low resolution FreeType
- % ends up trying to deal with glyph metrics where one dimension is 0
- % and it throws an error. So instead of looking for zero, we'll look
- % for a really tiny CTM.
- % We also used to patch up the CTM, and still use it, but frankly
- % this is too much trouble. If the CTM is tiny then the displacement
- % due to drawing the text will also be tiny. Negligible in fact.
- % So if its that small then lets just ignore it.
- dup 0 get abs 0.00001 lt 1 index 1 get 0.00001 abs lt and not {
- dup 2 get abs 0.00001 lt 1 index 3 get abs 0.00001 lt and not {
- pop
- currentpoint
- % don't worry about transparency for invisible text
- 2 index settextfillstate show % Tr was set to graphic state.
- moveto
- % now set the currentpoint using the original matrix
- gsave
- //false charpath currentpoint newpath
- grestore
- moveto
- } {
- pop pop
- }ifelse
- } {
- pop pop
- }ifelse
- }
- } {
- { //false charpath textrenderingprocs .currenttextrenderingmode get exec }
- } ifelse
- } ifelse
- } ifelse
- }
- {
- % If we are doing a plain old fill, or no text at all, *or* we are going to
- % a device supporting text rendering modes, then go through this route.
- %
- .currenttextrenderingmode 0 eq .currenttextrenderingmode 3 eq or
- currentfont /FontType get 3 eq or
-
- /PreserveTrMode /GetDeviceParam .special_op {
- exch pop
- }{
- //false
- }ifelse
- % pdfwrite can't handle rendering modes which involve clipping
- .currenttextrenderingmode 4 lt and or
- % Tr was set to graphic state.
- {
- FontMatrixNonHV {
- {
- % preserve current line width around possible stroke setup
- currentlinewidth exch
- setstrokeforTrpreservation
- settextfillstate //false TextTransSetup
- [ .currenttextspacing .currentwordspacing 3 index
- { % str [... weach wword c undef|ythis xthis|undef
- exch % will be removed, unless FontMatrix.xx/yy == 0 (FontMatrixNonHV already true)
- Vexch pop % str [... weach wword c wthis
- 3 index add exch 32 eq {1 index add} if % str [... weach wword w
- 3 1 roll % str [... w weach wword
- }
- % for the "exch" removed or not below, see comment in pdf_font.ps::getfontmetrics
- currentfont /FontMatrix get 0 3 Vexch pop get 0 ne {
- 1 1 index length 1 sub getinterval cvx
- } if
- cshow pop pop ]
- { xshow } { yshow } Vexch pop exec
- setlinewidth TextTransTeardown
- }
- } {
- .currentwordspacing
- 0 eq {
- {
- { setstrokeforTrpreservation
- settextfillstate //false TextTransSetup .currenttextspacing
- 0 Vexch 3 -1 roll ashow TextTransTeardown
- }
- currentlinewidth
- { setlinewidth }
- 3 .execn
- }
- } {
- .currenttextspacing 0 eq {
- { % preserve current line width around possible stroke setup
- { setstrokeforTrpreservation
- settextfillstate //false TextTransSetup .currentwordspacing
- 0 Vexch 32 4 -1 roll .pdfwidthshow
- TextTransTeardown
- }
- currentlinewidth
- { setlinewidth }
- 3 .execn
- }
- } {
- { % preserve current line width around possible stroke setup
- { setstrokeforTrpreservation
- settextfillstate //false TextTransSetup .currentwordspacing
- 0 Vexch 32
- .currenttextspacing 0 Vexch 6 -1 roll .pdfawidthshow TextTransTeardown
- }
- currentlinewidth
- { setlinewidth }
- 3 .execn
- }
- } ifelse
- } ifelse
- } ifelse
- }
- {
- { currentlinewidth exch
- .currentwordspacing
- .currenttextspacing
- % Implement the combination of t3 and false charpath.
- % Note that we must use cshow for this, because we
- % can't parse multi-byte strings any other way.
- % Stack: string wword wchar
- {
- exch % will be removed, unless FontMatrixNonHV && FontMatrix.xx/yy == 0
- % Stack: str wword wchar ccode xthis ythis
- Vexch pop currentpoint 6 3 roll
- % Stack: str wthis xorig yorig wword wchar ccode
- (x) dup 0 3 index put
- %
- % for devices which can handle the text rendering mode we don't want
- % to decompose into paths, we want to do a 'show'. However pdfwrite
- % can't handle clipping text, so we *do* want to do the clip path
- % as a 'true charpath'.
- %
- /PreserveTrMode /GetDeviceParam .special_op {
- exch pop
- }{
- //false
- }ifelse {
- % NB we must have Tr at least 4 or the test above would have
- % taken a different path, so we *know* the Tr involves clipping
- % or we wouldn't be here. Subtract 4 from the Tr and preserve
- % that mode, then do a charpath so the clip path gets set up
- % correctly.
- gsave .currenttextrenderingmode 4 sub .settextrenderingmode
- setstrokeforTrpreservation
- setsmaskstate settextfillstate //false TextTransSetup dup show grestore TextTransTeardown } if
- //false charpath
- 3 copy 32 eq { add } { exch pop } ifelse
- % Stack: str wthis xorig yorig wword wchar ccode wextra
- 7 -3 roll moveto add
- 0 Vexch rmoveto pop
- }
- % for the "exch" removed or not below, see comment in pdf_font.ps::getfontmetrics
- FontMatrixNonHV dup not exch {
- currentfont /FontMatrix get 0 3 Vexch pop get 0 ne
- } if {
- 1 1 index length 1 sub getinterval cvx
- } if
- 4 -1 roll cshow pop pop
- %
- % If the device doesn't handle text rendering modes then we now have a suitable
- % path, so call the correct routine to stroke/fill it (clip is handled when we
- % get ET).
- %
- /PreserveTrMode /GetDeviceParam .special_op {
- exch pop not
- }{
- //true
- }ifelse {
- textrenderingprocs .currenttextrenderingmode get exec
- } if
- setlinewidth
- }
- }
- ifelse
- }
- ifelse /Show gput
- } bind executeonly def
-/showfirst { setshowstate Show } executeonly def
-
-/Tj {
- {
- //true /TextFillStateNeeded gput
- 0 0 moveto Show settextposition
- }
- OFFlevels length 0 eq {
- exec
- } {
- gsave nulldevice exec grestore
- } ifelse
- //true /TextFillStateNeeded gput
-} bind executeonly def
-/' { T* Tj } bind executeonly def
-/" { exch Tc exch Tw T* Tj } bind executeonly def
-/TJ {
- { 0 0 moveto {
- dup type /stringtype eq {
- Show
- } { -1000 div
- currentfont /ScaleMatrix .knownget { 0 get mul } if
- 0 Vexch rmoveto
- } ifelse
- } forall settextposition
- //true /TextFillStateNeeded gput
- }
- OFFlevels length 0 eq {
- exec
- } {
- gsave nulldevice exec grestore
- } ifelse
- //true /TextFillStateNeeded gput
-} bind executeonly def
-
-% NB: We don't need clippath when filling or stroking
-/tf {
- .currentPDFfontsize 0 eq not {
- //true /TextFillStateNeeded gput
- settextfillstate //true TextTransSetup currentpoint fill TextTransTeardown moveto
- } if
-} bind executeonly def
-/tn { currentpoint newpath moveto } bdef % Obsolete, never used.
-% For stroking characters, temporarily restore the graphics CTM so that
-% the line width will be transformed properly.
-/Tmatrix matrix def
-/tS
- {
- currentfont /FontType get 3 eq
- {
- settextfillstate //true TextTransSetup currentpoint fill TextTransTeardown moveto
- }
- {
- .currentPDFfontsize 0 eq not {
- setsmaskstate //true TextTransSetup
- currentpoint //Tmatrix currentmatrix TextSaveMatrix setmatrix
- currentdict /qTextSaveMatrix known {qTextSaveMatrix setmatrix} if
- .swapcolors stroke TextTransTeardown .swapcolors
- setmatrix moveto
- } if
- } ifelse
- //true /TextFillStateNeeded gput
- } bind executeonly def
-
-% Handle transparency the same as /B operator
-/tB {
- % Type 3 fonts don't honour text rendering modes, see note on p401 of the 1.7 PDF Reference
- currentfont /FontType get 3 eq
- {
- settextfillstate //true TextTransSetup currentpoint fill TextTransTeardown moveto
- }
- {
- % Don't try to draw text when the point size is 0
- .currentPDFfontsize 0 eq not {
- setsmaskstate settextfillstate
- % While text will always have a currentpoint, strokepath seems to mess with it.
- % we get the currentpoint, then use moveto to restore it.
- currentpoint
-
- % For stroking characters, temporarily restore the graphics CTM so that
- % the line width will be transformed properly.
- //Tmatrix currentmatrix TextSaveMatrix setmatrix
- currentdict /qTextSaveMatrix known {qTextSaveMatrix setmatrix} if
- B
- setmatrix
- moveto
- } if
- } ifelse
- //true /TextFillStateNeeded gput
-} bind executeonly def
-
-% This does the wrong thing if there have been multiple text operations
-% within a single BT/ET pair, but it's a start.
-/tW { } bind executeonly def
-
-%% split a string containing \r or \n into multiple strings)
-%% \r\n is also handled.
-%% (string) .splitstring (string1) (string2) .....
-/.splitstring {
- 0 exch %% start_index string
- dup length 1 sub %% start_index string (string length - 1)
- 0 1 3 -1 roll %% start_index string 0 1 (string_length -1)
- { %% start_index string loop_index
- dup %% start_index string loop_index loop_index
- 2 index exch get %% start_index string loop_index character
- dup 10 eq exch 13 eq or { %% start_index string loop_index
- dup 3 index %% start_index string loop_index loop_index start_index
- sub %% start_index string loop_index (loop_index - start_index)
- dup 0 gt { %% \r\n will give us a 0 length string so ignore it
- 3 index exch %% start_index string loop_index start_index (loop_index - start_index)
- 3 index 3 1 roll %% start_index string loop_index string start_index (loop_index - start_index)
- getinterval %% start_index string loop_index sub_string
- 4 1 roll %% sub_string start_index string loop_index
- 1 add
- 3 -1 roll %% sub_string string loop_index start_index
- pop exch %% sub_string loop_index string %% loop_index becomes new start_index
- }{
- pop %% start_index string loop_index
- 1 add 3 1 roll exch %% loop_index string start_index
- pop %% loop_index string %% loop_index becomes new start index
- } ifelse
- }{
- pop %% start_index string
- } ifelse
- } for
- %% start_index string
- dup length 2 index sub dup %% start_index string (length - start_index) (length - start_index)
- 0 gt { %% we have characters left %% start_index string (length - start_index)
- 3 -1 roll exch %% string start_index (length - start_index)
- getinterval %% sub_string
- } {
- pop pop pop
- } ifelse
-} bind executeonly def
-
-% Text formatting and painting for the AcroForm field without appearance streams.
-/Tform { % <MaxLen> (V) <Ff> <Q> Tform -
- clippath pathbbox 4 2 roll pop pop % MaxLen (V) Ff Q dx dy
- currentfont /ScaleMatrix .knownget { 3 get } { 1 } ifelse % MaxLen (V) Ff Q dx dy yy
-
- currentfont /FontBBox .knownget
- not
- {
- currentfont dup /FontType get
- 0 eq
- {
- /FDepVector get 0 get /FontBBox get}
- {
- pop //null % force an error
- } ifelse
- }if
- dup 1 get neg exch 3 get % MaxLen (V) Ff Q dx dy yy desc asc
-
- dup 0 ne { div } { pop pop 0 } ifelse % MaxLen (V) Ff Q dx dy yy desc/asc
- 1 index mul % MaxLen (V) Ff Q dx dy yy desc/asc*yy
-
- %% Check if this is declared as a multiine text widget, and if it is
- %% check that the string has at least 2 characters, so we can split it
- %% into at least two strings....
- %% Bug #687498.pdf has a multiline text widget with an empty string (amongst
- %% many other problems with this file).
- 5 index 16#1000 and 0 ne 7 index length 1 gt and{ % multiline
- %% First lets see how many lines we have, make a copy of the string
- 6 index mark exch .splitstring % MaxLen (V) Ff Q dx dy yy desc/asc*yy [ () () ...
- counttomark 1 add 4 add index % MaxLen (V) Ff Q dx dy yy desc/asc*yy [ () () ... count Q
- dup 0 eq {
- pop % remove extra copy of Q
- counttomark dup 2 add 2 add index exch div % MaxLen (V) Ff Q dx dy yy desc/asc*yy [ () () ... line_height
- counttomark 1 add 1 roll % MaxLen (V) Ff Q dx dy yy desc/asc*yy line_height [ () () ...
- 2 0 moveto % start at bottom left of rect
- counttomark 1 1 3 -1 roll { % for every string
- pop gsave
- <EFBBBF> anchorsearch {
- pop
- } {
- <FEFF> anchorsearch {
- pop
- } if
- } ifelse
- Show grestore % pop loop counter, show string (saving current point)
- counttomark 1 add index 0 exch rmoveto % get line height, move that amount vertically.
- } for
- pop pop
- }{
- 1 eq {
- counttomark dup 2 add 2 add index exch div % MaxLen (V) Ff Q dx dy yy desc/asc*yy [ () () ... line_height
- counttomark 1 add 1 roll % MaxLen (V) Ff Q dx dy yy desc/asc*yy line_height [ () () ...
- 2 0 moveto % start at bottom left of rect
- counttomark 1 1 3 -1 roll { % for every string
- pop gsave % pop loop counter
- <EFBBBF> anchorsearch {
- pop
- } {
- <FEFF> anchorsearch {
- pop
- } if
- } ifelse
- dup stringwidth pop counttomark 5 add index % get rectangle width
- exch sub 2 div 0 rmoveto % subtract width of string, divide by 2 move that amount
- Show grestore % show string
- counttomark 1 add index 0 exch rmoveto % get line height, move that amount vertically.
- } for
- pop pop
- }{
- counttomark dup 2 add 2 add index exch div % MaxLen (V) Ff Q dx dy yy desc/asc*yy [ () () ... line_height
- counttomark 1 add 1 roll % MaxLen (V) Ff Q dx dy yy desc/asc*yy line_height [ () () ...
- 2 0 moveto % start at bottom left of rect
- counttomark 1 1 3 -1 roll { % for every string
- pop gsave % pop loop counter
- <EFBBBF> anchorsearch {
- pop
- } {
- <FEFF> anchorsearch {
- pop
- } if
- } ifelse
- dup stringwidth pop counttomark 5 add index % get rectangle width
- exch sub 2 sub 0 rmoveto % subtract width of string,move that amount
- Show grestore % show string
- counttomark 1 add index 0 exch rmoveto % get line height, move that amount vertically.
- } for
- pop pop
- }ifelse
- }ifelse
- 8 { pop } repeat
- } {
- 5 index 16#1000000 and 0 ne { % comb
- 6 index type /stringtype eq {
- 6 index length 0 gt {
- 6 index length 8 index % length of V and MaxLength
- gt {
- (Comb field with /V string which exceeds /MaxLength. Ignoring field.) =
- 8 {pop} repeat
- }{
- 3 index 8 index div % field Rect width / MaxLength, the offset between 'comb' boxes
- 7 index
- <EFBBBF> anchorsearch {
- pop
- } {
- <FEFF> anchorsearch {
- pop
- } if
- } ifelse
- {
- currentpoint newpath moveto % new path, preserving currnt point
- currentpoint % store the current point, this is the origin for the next 'comb'
- 3 -1 roll 1 string dup 3 -1 roll exch 0 3 -1 roll put % turn the character code into a 1 byte string
- dup gsave
- false charpath flattenpath pathbbox grestore % get the bounding box of that character
- 3 -1 roll sub 3 1 roll exch sub % get its width and height (ch, cw)
- 8 index 6 index % comb box width and height (bh, bw)
- 3 -1 roll % ch cw bh bw -> ch bh bw cw
- sub 2 div % ch bh (bw - cw) / 2 = ch bh dw
- 3 1 roll % ch bh dw -> dw ch bh
- exch sub 2 div % dw (bh - ch) /2 = dw dh
- rmoveto % centers character in box
- Show exch 2 index add exch moveto % Draw the character
- } forall % repeat for every character in the original string
- 9 {pop} repeat % discard the various arguments
- }ifelse
- }{
- 8 {pop} repeat % discard the parameters
- }ifelse
- }{
- (Comb field with a non-string /V value is illegal. Ignoring field.) =
- 8 {pop} repeat
- } ifelse
- } { % plain text
- 3 1 roll sub add 2 div % MaxLen (V) Ff Q dx (dy-yy+desc)/2
- 0 exch moveto % MaxLen (V) Ff Q dx
- 1 index 0 ne {
- 3 index
- <EFBBBF> anchorsearch {
- pop
- } {
- <FEFF> anchorsearch {
- pop
- } if
- } ifelse
- stringwidth pop % MaxLen (V) Ff Q dx w
- sub exch 1 eq { 2 div } { 2 sub } ifelse % MaxLen (V) Ff (dx-w)/2
- 0 rmoveto % MaxLen (V) Ff
- pop % MaxLen (V)
- } {
- pop pop pop % MaxLen (V)
- 2 0 rmoveto
- } ifelse
- exch pop
- <EFBBBF> anchorsearch {
- pop
- } {
- <FEFF> anchorsearch {
- pop
- } if
- } ifelse
- Show % -
- } ifelse
- } ifelse
-} bind executeonly def
-
-end readonly put % GS_PDF_ProcSet
-
-.setglobal
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_rbld.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_rbld.ps
deleted file mode 100644
index 6eeb6085e99..00000000000
--- a/Master/tlpkg/tlgs/Resource/Init/pdf_rbld.ps
+++ /dev/null
@@ -1,476 +0,0 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
-% 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.
-%
-% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
-%
-
-% pdf_rbld.ps - Rebuilding of broken PDF files (xref errors)
-
-% This module contains routines that are used if we detect an error
-% while reading the xref tables. These routines will scan the file and
-% build an xref table by finding the objects. We also need to find the
-% appropriate trailer dictionary. Note: One procedure is also used
-% even if we do not need to rebuild a PDF file.
-%
-% This module cannot rebuild a PDF file which has had errors created inside
-% of objects or binary data streams. It often succeeds with files that
-% have had its end of lines converted between unix and dos versions.
-
-% if true --> we have an object with duplicate object and generation numbers.
-/dup_obj_gen_num //false def
-
-% Note: This procedure is also used by non-rebuild code.
-% Store a line in the xref array (Actually Objects and Generations arrays)
-% <obj num> (strm num> <obj loc> <gen num> <rebuild>
-% setxrefentry <obj num> strm num> <obj loc> <gen num>
-/setxrefentry
-{
- 5 1 roll
- dup 65535 or 65535 ne {
- ( **** Error: Generation number out of 0..65535 range, assuming 0.\n)
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- pop 0
- } if
- % We store generation numbers as value + 1
- % We reserve 0 to indicate an free xref entry
- 1 add % increment generation number
- % To save space, generations numbers are stored in a string unless we
- % find a generation number greater than 255. If so then transfer to
- % an array.
- dup 255 gt {
- Generations type /stringtype eq { % Convert Generations to an array.
- Generations length array dup % Create new array
- 0 1 2 index length 1 sub { % Copy from old string to new array
- Generations 1 index get put dup
- } for
- pop
- /Generations exch store % Save new Generations array
- } if
- } if
- % Verify that the new values are for a new object. If the current
- % entry is null then we have a new entry.
- Objects 4 index get //null eq {
- ObjectStream 4 index 4 index cvx put % Save ObjectStream object number
- Objects 4 index 3 index cvx put % Save object location
- Generations 4 index 2 index put % Save geenration number
- } {
- % Verify that the new entry has at least as high a generaton number
- % We accept equal entry number because we have found PDF files in
- % which there are multiple objects with the same object and entry
- % numbers. The normal xref logic only accepts the first such
- % entry that it finds. However the 'rebuild PDF' logic can find
- % both such entries. The correct one is usually the last one.
- Generations 4 index get 1 index le {
- %% Check if the object we already found was at the locaton specified
- %% in the original xref (now stored in Orig_Objects). If so, prefer
- %% that offset, otherwise prefer the later object.
- %% NB check first to see that the object number is in the range of the original
- %% xref. If it isn't, set the 'original' Offset to 0.
- 3 index Orig_Objects length le {Orig_Objects 4 index get}{0}ifelse
- Objects 5 index get eq not
- {
- ObjectStream 4 index 4 index cvx put % Save ObjectStream object number
- Objects 4 index 3 index cvx put % Save object location
- Generations 4 index 2 index put % Save geenration number
- } if
- } if
- % Set error flag if we have equal object and generation numbers
- Generations 4 index get 1 index eq { /dup_obj_gen_num //true def } if
- } 8 -1 roll { ifelse } { pop if } ifelse % Run 'else' only when rebuilding.
-} bind executeonly def
-
-% Print the contents of the xref array. This actually consists of three
-% arrays (Objects, Generations, and ObjectStream).
-/print_xref % - print_xref -
-{ 0 1 Objects length 1 sub % stack: 0 1 <number of objects - 1>
- { dup =only % print object number
- ( ) print
- dup Generations exch get 1 sub =only % print Generation number
- ( ) print
- dup ObjectStream exch get ==only % print ObjectStream object number
- ( ) print
- Objects exch get === % print object location
- } for
- flush
-} bind executeonly def
-
-% Get token from string and check its type
-% <string> <type> typed_token <false> % no token or not match
-% <string> <type> typed_token <obj> <last> <true> % matching token type
-% Where last is the string remainder
-/typed_token
-{ exch
- token_nofail % get token
- {
- dup type % stack: type last token type
- 4 -1 roll eq { % stack: last token bool
- exch //true % desired object found - set exit status
- } {
- pop pop //false % not type - clear stack, set exit status
- } ifelse
- } {
- pop //false % no token - pop type, set exit status
- } ifelse % check if we got token
-} bind executeonly def
-
-% Allocate space for post_eof_count to be bound into procedures below.
-/post_eof_count 0 def
-
-% We want the location of the trailer dictionary at the start of file.
-% First we will find the xref. Then we will skip over the xref entries
-% to the trailer.
-/search_start_trailer % - search_start_trailer <trailer loc>
-{ % Read the first 300 bytes and check for xref
- PDFfile 0 setfileposition
- PDFfile bytesavailable post_eof_count sub % location of end of data
- 300 .min % block size to read
- dup string 0 1 4 -1 roll 1 sub
- { 2 copy PDFfile read pop put pop } for
- (xref) search {
- % found 'xref'
- exch pop exch pop length 4 add PDFfile exch setfileposition
- PDFfile token pop % get starting entry - or 'trailer'
- (trailer) ne { % if we do not already have 'trailer'
- PDFfile token pop % get number of entries
- % The following check could be more efficient
- % but broken file.....
- dup
- PDFfile fileposition
- PDFfile 0 setfileposition
- PDFfile bytesavailable
- exch PDFfile exch setfileposition
- % On the basis it requires at least 15 bytes to define an object
- % in PDF, if the claimed number of objects is more than the number
- % of bytes in the file, then it is clearly bogus, and we just give up
- 15 idiv
- lt {
- PDFfile token pop pop % this moves us into the middle of the first entry
- 25 string exch % define working string for readline
- { PDFfile 1 index readline pop pop
- } repeat % skip entries
- pop % pop working string
- PDFfile token pop pop % get 'trailer'
- PDFfile fileposition % get file position
- }
- { pop 0}
- ifelse
- } if
- } {
- pop 0 % no xref, should not happen, report it upstrem
- } ifelse
-} bind executeonly def
-
-
-%% Searches backwards from a specified point looking for a 'trailer' keyword.
-%% position search_earlier_trailer position or 0
-%%
-%% Its is just possible that a 'trailer' keyword could straddle a buffer, in which case
-%% we wouldn't find it. Given that this only executes for broken files anyway I don't
-%% propose to worry about it at the moment, if anyone ever turns up an example we may
-%% choose to enhance this routine further.
-%%
-/search_earlier_trailer {
- { % position
- dup 0 gt { % position bool
- dup 65535 .min exch % block_size position
- 1 index sub % block_size position-block_size
- dup % block_size new_position new_position
- PDFfile exch setfileposition % block_size new position
- exch dup % new position block_size block_size
- dup string 0 1 4 -1 roll 1 sub %
- {2 copy PDFfile read pop put pop } for %
- % new_position block size (...string from file....)
- (trailer) search {
- pop
- { search not { exit } if pop } loop
- % determine where the trailer is in the file
- % trailer loc = end loc - remaing string length
- length % new_position block size string length
- 3 1 roll % string length new_position block size
- add exch sub % string length - (new_position + block size)
- } {
- pop % discard old block size
- pop 0
- } ifelse
- } {
- pop 0 exit
- }ifelse
-
- %% We either have a position for a trailer, or 0 if we failed to find one
- dup 0 eq not {
- exit
- }if
- pop % renove the zero leaving the new start position
- } loop
-} bind executeonly def
-
-% We want the location of the trailer dictionary at the end of file.
-% We will read the last block of data and search for the final occurance
-% of the word 'trailer'
-/search_end_trailer % - search_end_trailer <trailer loc>
-{ % Position to read block of data from the end of the file. Note: We ignore
- % anything past the last %%EOF since this is not PDF data.
- PDFfile 0 setfileposition
- PDFfile bytesavailable post_eof_count sub % location of end of data
- dup 65535 .min % block size to read
- % stack: <file end pos> <block size>
- % move file position to the start of the block
- 2 copy sub PDFfile exch setfileposition
- % read block of data
- dup string 0 1 4 -1 roll 1 sub { 2 copy PDFfile read pop put pop } for
- % search for last occurance of 'trailer'
- (trailer) search {
- pop
- { search not { exit } if pop } loop
- % determine where the trailer is in the file
- % trailer loc = end loc - remaing string length
- length sub
- } {
- pop pop 0
- } ifelse
-} bind executeonly def
-
-% We want to find the trailer dictionary. There is a trailer dictionary
-% for each xref object list. We only want the trailer dictionary associated
-% with the first xref object list. In theory this can be anywhere in the
-% file. However since we are trying to repair a broken file, we cannot simply
-% follow the xref links. So we are falling back to a simple strategy. We
-% find the specified location of the first xref list. If its location is in
-% the first half of the file then we search for the first trailer dictionary
-% at the start of the file. Otherwise we search for the last trailer at the
-% end of the file.
-/search_trailer % - search_trailer -
-{ % Find the 'startxref' and associated position at the end of the file.
- % Position to read block of data from the end of the file. Note: We
- % actually end at the end of the last %%EOF since this is the end of the
- % useful PDF data. (Some files contain trailing garbage.)
- PDFfile 0 setfileposition
- PDFfile bytesavailable % size of file
- post_eof_count sub dup % location of end of last %%EOF
- dup 4096 .min % block size to read
- % stack: <useful file size> <useful file size file> <block size>
- % move file position to the start of the block
- 2 copy sub PDFfile exch setfileposition
- % read block of data
- dup string 0 1 4 -1 roll 1 sub { 2 copy PDFfile read pop put pop } for
- % search for last occurance of 'startxref'
- //false % Assume that startxref not present
- exch (startxref) {
- search not { exit } if % Exit loop when no more startxref's
- pop 3 -1 roll pop //true 3 1 roll % Idicate that we have found starxref
- } loop
- exch % Exch last string and 'found' flag
- {
- % determine where the startxref is in the file
- % 'startxref' loc = end loc - remaing string length - 9 bytes
- length sub 9 sub
- % move the file to this position and read startxref and position
- % First, read the startxref token, this should not fail.
- PDFfile exch setfileposition PDFfile token
- {
- % Discard the startxref token and read the following token, which should be the offset.
- pop PDFfile token_no_close
- {
- % Now chck its an integer
- dup type /integertype eq not {
- pop
- % startxref not followed by integer. We will search the end of the file for trailer.
- PDFfilelen
- } if
- } {
- % startxref not followed by any token. We will search the end of the file for trailer.
- PDFfilelen
- } ifelse
- } {
- % No startxref token ? We will search the end of the file for trailer.
- PDFfilelen
- } ifelse
- } {
- % startxref not found. We will search the end of the file for trailer.
- pop pop PDFfilelen
- } ifelse
- % compare xref position to 1/2 the length of the file and search for trailer
- exch 2 div lt {
- search_start_trailer dup 0 eq { pop search_end_trailer } if
- } {
- search_end_trailer dup 0 eq { pop search_start_trailer } if
- } ifelse
- dup 0 eq {
- pop
- ( **** Error: Trailer dictionary not found.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }{
- % get the trailer
- dup
- PDFfile exch setfileposition % set to the specified trailer location
- /dictlevelcount 0 def
- PDFfile traileropdict .pdfrun % read trailer info
-
- {
- dup /Root known not {
- ( **** Warning: This trailer dictionary does not contain a /Root entry\n searching for a prior trailer.\n) pdfformatwarning
- %% remove trailer dict copy, duplicate file position, then remove the length of 'trailer' so we don't
- %% find the same one again....
- pop dup 7 sub
- search_earlier_trailer
- }{exit}ifelse
- dup 0 eq {
- pop
- ( **** Error: Valid trailer not found.\n) pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }{
- PDFfile exch setfileposition % set to the specified trailer location
- /dictlevelcount 0 def
- PDFfile traileropdict .pdfrun % read trailer info
- } ifelse
- } loop
- /Trailer exch def
- pop
- } ifelse
-} bind executeonly def
-
-% This routine will determine if there is stuff after the %%EOF. There is
-% supposed to be only a line termination. However many real life files
-% contain some garbage. This routine checks how much. We then ignore this
-% stuff when we are scanning for objects.
-/determine_post_eof_count % - determine_post_eof_count <count>
-{ % Position to read block of data from the end of the file.
- PDFfilelen % size of file
- dup 4096 .min % file_size block_size
- dup 3 1 roll sub % block_size file_size-block_size
- PDFfile exch setfileposition % block_size
- string PDFfile exch readstring pop % ()
-
- % search for last occurance of 'startxref', '%%EOF' is often damaged
- (startxref) search {
- pop
- { search not { exit } if pop
- } loop
- % how much is left = remaining string length
-
- % Now search for %%EO or try to read a number after 'startxref'.
- (%%EO) search {
- pop pop
- } {
- % Look for a number after startxref
- { dup token { pop exch pop } if
- } stopped pop
- } ifelse
- length
- } {
- % Can't even find startxref, assume it's all objects
- pop 0
- } ifelse
-} bind executeonly def
-
-% This routine will scan a file searaching for object locations to build
-% an alternate version of the data in the xref tables.
-% Its purpose is to provide a basis for an xref fixing facility.
-/search_objects % - search_objects -
-{ % Initialize the Objects, Generations, etc. arrays
- Objects dup length array copy /Orig_Objects exch def
- initPDFobjects
- % reset duplicate object and generation numbers error flag
- /dup_obj_gen_num //false def
- % Determine how many bytes are in the file after the final %%EOF
- /post_eof_count determine_post_eof_count def
- % Start at the beginning of the file
- PDFfile 0 setfileposition
- % Create a working string (and also store its length on stack). We are
- % using a maximum size string size the logic below wants a recovered object
- % to fit into our working string.
- 65535 dup string
- { % Now loop through the entire file looking for objects
- PDFfile fileposition % save current file position
- % When we get near the end of the file, we use a smaller interval of
- % our working string to prevent reading past the end. (See comments on
- % EOF testing below.)
- PDFfile bytesavailable post_eof_count sub 10 sub dup 4 index lt {
- 2 index 0 3 -1 roll getinterval % near EOF, use interval of string
- } {
- pop 1 index % not near end, use full working string
- } ifelse
- % Read a line from file. If the line does not fit into our working string,
- % or any other error, then we will discard it.
- PDFfile exch { readline } //.internalstopped exec
- { pop pop //false } if % indicate no string if we stopped
- { % stack: <length> <working_str> <loc> <string>
- % Now that we have line, get obj num, ref num, and 'obj'. Verify that each
- % of these is correct type.
- dup (obj) search { % preliminary check for obj
- pop pop pop
- /integertype typed_token { % get obj number
- /integertype typed_token { % get ref number
- /nametype typed_token { % get 'obj' text
- pop % pop remaining string
- /obj eq { % verify name is 'obj'
- % make sure we have room in the arrays. We work in increments
- % of 20 each time we increase the size.
- 1 index 20 add 20 idiv 20 mul
- growPDFobjects
- % save xref parameters into ObjectStream, Objects and Generations
- 1 index 0 % rearrange parms for setxrefentry
- 4 index PDFoffset sub 3 index
- //true setxrefentry % save parameters
- pop pop pop pop % clear parameters
- } if % check if name is 'obj'
- } if % check if we got 'obj" string
- pop % remove ref number
- } if % check if we got ref number
- pop % remove obj number
- } if % check if we got object number
- } {
- pop pop
- } ifelse
- } if % check if got a string from readline
- pop % remove location
- % Check if we are approaching the end of the file. We do not want to
- % read past the end of the file since that closes it. We actually stop
- % 10-20 bytes early since there cannot be an object that close to the end.
- % (There is a Trailer dictionary, etc. at the end of the file.)
- PDFfile bytesavailable post_eof_count sub 20 lt { exit } if
- } loop % loop through the entire file
- pop pop % remove working string and its length
- % Output warning if we have two objects with the same object and generation
- % numbers.
- dup_obj_gen_num {
- ( **** Warning: There are objects with matching object and generation\n)
- pdfformatwarning
- ( **** numbers. The output may be incorrect.\n)
- pdfformatwarning
- } if
- currentdict /Orig_Objects undef
-} bind executeonly def
-
-% Print warning message because we found a problem while reading the xref
-% tables
-/print_xref_warning
-{ ( **** Error: An error occurred while reading an XREF table.\n)
- pdfformaterror
- ( **** The file has been damaged. This may have been caused\n)
- pdfformaterror
- ( **** by a problem while converting or transferring the file.\n)
- pdfformaterror
- ( **** Ghostscript will attempt to recover the data.\n)
- pdfformaterror
- ( **** However, the output may be incorrect.\n) pdfformaterror
-} bind executeonly def
-
-% Attempt to recover the XRef data. This is called if we have a failure
-% while reading the normal XRef tables. This routine usually works
-% only for pre PDF1.5 versions of PDF files.
-/recover_xref_data % - recover_xref_data -
-{ print_xref_warning % Print warning message
- count pdfemptycount sub { pop } repeat % remove anything left by readxref
- search_objects % Search for objects
-} bind executeonly def
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_sec.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_sec.ps
deleted file mode 100644
index 9e6c1c0f074..00000000000
--- a/Master/tlpkg/tlgs/Resource/Init/pdf_sec.ps
+++ /dev/null
@@ -1,829 +0,0 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
-% 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.
-%
-% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
-%
-% Copyright (C) 1996-1998 Geoffrey Keating.
-% Copyright (C) 2001-2008 Artifex Software, Inc.
-% This file may be freely distributed with or without modifications,
-% so long as modified versions are marked as such and copyright notices are
-% not removed.
-
-% Implementation of security hooks for PDF reader.
-
-% This file contains the procedures that have to take encryption into
-% account when reading a PDF file. It was originally distributed
-% separately by Geoffrey Keating as an add-on to version 6 and earlier.
-
-% Modified by Alex Cherepanov to work with GS 6.60 and higher.
-% New versions of GS require explicit checks for /true, /false, and /null
-% in .decpdfrun. This fix is backward-compatible.
-
-% Modified by Raph Levien and Ralph Giles to use the new C
-% implementations of md5 and arcfour in ghostscript 7.01, and to
-% be compatible with PDF 1.4 128-bit encryption.
-
-% Modified by Ralph Giles for PDF 1.6 AES encryption.
-
-% Modified by Michael Constant for PDF 1.7 ExtensionLevel 3
-% AES-256 encryption.
-
-/.setlanguagelevel where { pop 2 .setlanguagelevel } if
-.currentglobal //true .setglobal
-pdfdict begin
-
-% Older ghostscript versions do not have .pdftoken, so we use 'token' instead.
-/.pdftoken where { pop } { /.pdftoken /token load def } ifelse
-
-% take a stream and arc4 decrypt it.
-% <stream> <key> arc4decodefilter <stream>
-/arc4decodefilter {
- 1 dict begin
- /Key exch def
- currentdict end /ArcfourDecode filter
-} bind executeonly def
-
-% <ciphertext> <key> arc4decode <plaintext>
-/arc4decode {
- 1 index length 0 eq {
- pop
- } {
- 1 index length string 3 1 roll arc4decodefilter exch readstring pop
- } ifelse
-} bind executeonly def
-
-% take a stream and aes decrypt it.
-% <stream> <key> aesdecodefilter <stream>
-/aesdecodefilter {
- 1 dict begin
- /Key exch def
- currentdict end
- /AESDecode filter
-} bind executeonly def
-
-% AES decrypt a string, returning a string. The second argument can
-% be a dictionary of the form << /Key key /Padding false >>, which
-% specifies the key and any options for the AESDecode filter, or it
-% can just be a string (the key).
-%
-% <ciphertext> <dict> aesdecode <plaintext>
-% <ciphertext> <key> aesdecode <plaintext>
-/aesdecode {
- 1 index length 0 eq {
- pop
- } {
- 1 index length string 3 1 roll
-
- % If our second argument is a dictionary, it's the full set
- % of decoding options (including the key); pass it directly
- % to the AESDecode filter. Otherwise, it's just the key, so
- % call aesdecodefilter to construct the dictionary.
- dup type /dicttype eq { /AESDecode filter } { aesdecodefilter } ifelse
-
- exch readstring pop
- } ifelse
-} bind executeonly def
-
-/md5 {
- 16 string dup /MD5Encode filter dup 4 3 roll writestring closefile
-} bind executeonly def
-
-/md5_trunk {
- md5 0 pdf_key_length getinterval
-} bind executeonly def
-
-/sha256 {
- 32 string dup /SHA256Encode filter dup 4 3 roll writestring closefile
-} bind executeonly def
-
-% <string> contains_non_ascii <bool>
-/contains_non_ascii {
- //false exch { 128 ge { pop //true exit } if } forall
-} bind executeonly def
-
-/pdf_padding_string
- <28bf4e5e4e758a41 64004e56fffa0108
- 2e2e00b6d0683e80 2f0ca9fe6453697a>
-def
-
-% Pad a key out to 32 bytes.
-/pdf_pad_key { % <key> pdf_pad_key <padded key>
- dup length 32 gt { 0 32 getinterval } if
- pdf_padding_string
- 0 32 3 index length sub getinterval
- concatstrings
-} bind executeonly def
-
-/pdf_xorbytes { % <iter-num> <key> pdf_xorbytes <xored-key>
- dup length dup string
- exch 1 sub 0 1 3 2 roll {
- % <iter-num> <key> <new-key> <byte-num>
- dup 3 index exch get 4 index xor
- % <iter-num> <key> <new-key> <byte-num> <byte>
- 3 copy put pop pop
- } for
- 3 1 roll pop pop
-} bind executeonly def
-
-% Get length of encryption key in bytes
-/pdf_key_length { % pdf_key_length <key_length>
- Trailer /Encrypt oget
- dup /V knownoget not { 0 } if 1 eq
- { pop 5 } % If V == 1 then always use 40 bits
- { /Length knownoget { -3 bitshift } { 5 } ifelse }
- ifelse
-} bind executeonly def
-
-% Algorithm 3.2
-/pdf_compute_encryption_key { % <password> pdf_compute_encryption_key <key>
- % Step 1.
- pdf_pad_key
-
- % Step 2, 3.
- Trailer /Encrypt oget dup /O oget
- % <padded-key> <encrypt> <O>
-
- % Step 4.
- exch /P oget 4 string exch
- 2 copy 255 and 0 exch put
- 2 copy -8 bitshift 255 and 1 exch put
- 2 copy -16 bitshift 255 and 2 exch put
- 2 copy -24 bitshift 255 and 3 exch put pop
- % <padded-key> <O> <P>
-
- % Step 5.
- Trailer /ID knownoget { 0 oget } {
- ()
- ( **** Error: ID key in the trailer is required for encrypted files.\n) pdfformaterror
- ( File may not be possible to decrypt.\n) pdfformaterror
- } ifelse
- 3 { concatstrings } repeat
- % We will finish step 5 after possibly including step 6.
-
- % The following only executed for /R equal to 3 or more
- Trailer /Encrypt oget dup /R oget dup 3 ge {
-
- % Step 6. If EncryptMetadata is false, pass 0xFFFFFFFF to md5 function
- % The PDF 1.5 Spec says that EncryptMetadata is an undocumented
- % feature of PDF 1.4. That implies that this piece of logic should
- % be executed if R >= 3. However testing with Acrobat 5.0 and 6.0 shows
- % that this step is not executed if R equal to 3. Thus we have a test for
- % R being >= 4.
- 4 ge {
- /EncryptMetadata knownoget % Get EncryptMetadata (if present)
- not { //true } if % Default is true
- not { % If EncryptMetadata is false
- <ff ff ff ff> concatstrings % Add 0xFFFFFFFF to working string
- } if
- } {
- pop % Remove Encrypt dict
- } ifelse
- md5_trunk % Finish step 5 and 6.
-
- % Step 7. Executed as part of step 6
- % Step 8. (This step is defintely a part of PDF 1.4.)
- 50 { md5_trunk } repeat
- } {
- pop pop md5_trunk % Remove R, Encrypt dict, finish step 5
- } ifelse
-
- % Step 9 - Done in md5_trunk.
-} bind executeonly def
-
-% Algorithm 3.4
-/pdf_gen_user_password_R2 { % <filekey> pdf_gen_user_password_R2 <U>
-
- % Step 2.
- pdf_padding_string exch arc4decode
-} bind executeonly def
-
-% Algorithm 3.5
-/pdf_gen_user_password_R3 { % <filekey> pdf_gen_user_password_R3 <U>
-
- % Step 2.
- pdf_padding_string
-
- % Step 3.
- Trailer /ID knownoget { 0 oget } {
- ()
- ( **** Error: ID key in the trailer is required for encrypted files.\n) pdfformaterror
- ( File may not be possible to decrypt.\n) pdfformaterror
- } ifelse
- concatstrings md5
-
- % Step 4.
- 1 index arc4decode
-
- % Step 5.
- 1 1 19 {
- 2 index pdf_xorbytes arc4decode
- } for
- exch pop
-
-} bind executeonly def
-
-/pdf_gen_user_password { % <password> pdf_gen_user_password <filekey> <U>
- % common Step 1 of Algorithms 3.4 and 3.5.
- pdf_compute_encryption_key dup
-
- Trailer /Encrypt oget
-
- /R oget dup 2 eq {
- pop pdf_gen_user_password_R2
- } {
- dup 3 eq {
- pop pdf_gen_user_password_R3
- } {
- dup 4 eq { % 4 uses the algorithm as 3
- pop pdf_gen_user_password_R3
- } {
- % This procedure is only used if R is between 2 and 4,
- % so we should never get here.
- /pdf_gen_user_password cvx /undefined signalerror
- } ifelse
- } ifelse
- } ifelse
-} bind executeonly def
-
-% Algorithm 3.6
-% <password> pdf_check_pre_r5_user_password <filekey> true
-% <password> pdf_check_pre_r5_user_password false
-/pdf_check_pre_r5_user_password {
- pdf_gen_user_password
-
- Trailer /Encrypt oget /U oget
-
- 0 2 index length getinterval eq {
- //true
- } {
- pop //false
- } ifelse
-} bind executeonly def
-
-% Compute an owner key, ie the result of step 4 of Algorithm 3.3
-/pdf_owner_key % <password> pdf_owner_key <owner-key>
-{
- % Step 1.
- pdf_pad_key
-
- % Step 2.
- md5_trunk
-
- % 3.3 Step 3. Only executed for /R equal to 3 or more
- Trailer /Encrypt oget /R oget 3 ge {
- 50 { md5_trunk } repeat
- } if
-
- % Step 4 - Done in md5_trunk.
-} bind executeonly def
-
-% Algorithm 3.7
-% <password> pdf_check_pre_r5_owner_password <filekey> true
-% <password> pdf_check_pre_r5_owner_password false
-/pdf_check_pre_r5_owner_password {
- % Step 1.
- pdf_owner_key
-
- % Step 2.
- Trailer /Encrypt oget dup /O oget 2 index arc4decode
- % <encryption-key> <encrypt-dict> <decrypted-O>
-
- % Step 3. Only executed for /R equal to 3 or more
- exch /R oget 3 ge {
- 1 1 19 {
- 2 index pdf_xorbytes arc4decode
- } for
- } if
- exch pop
- % <result-of-step-3>
-
- pdf_check_pre_r5_user_password
-} bind executeonly def
-
-% Algorithm 3.2a
-% <password> pdf_check_r5_password <filekey> true
-% <password> pdf_check_r5_password false
-/pdf_check_r5_password {
- 10 dict begin % temporary dict for local variables
-
- % Step 1.
- % If the .saslprep operator isn't available (because ghostscript
- % wasn't built with libidn support), just skip this step. ASCII
- % passwords will still work fine, and even most non-ASCII passwords
- % will be okay; any non-ASCII passwords that fail will produce a
- % warning from pdf_process_Encrypt.
- /.saslprep where { pop .saslprep } if
-
- % Step 2.
- dup length 127 gt { 0 127 getinterval } if
- /Password exch def
-
- % Step 3.
- /O Trailer /Encrypt oget /O oget def
- /U Trailer /Encrypt oget /U oget def
-
- Password O 32 8 getinterval concatstrings
- U 0 48 getinterval concatstrings sha256
-
- O 0 32 getinterval eq {
- % Step 3, second paragraph.
-
- Password O 40 8 getinterval concatstrings
- U 0 48 getinterval concatstrings sha256
-
- 16 string Trailer /Encrypt oget /OE oget concatstrings
- << /Key 4 -1 roll /Padding //false >> aesdecode //true
- } {
- % Step 4.
- Password U 32 8 getinterval concatstrings sha256
- U 0 32 getinterval eq {
- % Step 4, second paragraph.
- Password U 40 8 getinterval concatstrings sha256
-
- 16 string Trailer /Encrypt oget /UE oget concatstrings
- << /Key 4 -1 roll /Padding //false >> aesdecode //true
- } {
- //false
- } ifelse
- } ifelse
-
- % Step 5.
- dup {
- % Adobe says to decrypt the Perms string using "ECB mode with
- % an initialization vector of zero", which must be a mistake --
- % ECB mode doesn't use initialization vectors. It looks like
- % they meant "ECB mode, or CBC mode with an initialization
- % vector of zero", since the two are equivalent for a single-
- % block message. We use the latter.
- 16 string Trailer /Encrypt oget /Perms oget concatstrings
- << /Key 4 index /Padding //false >> aesdecode
-
- 9 3 getinterval (adb) eq not {
- ( **** Error: Failed to decrypt Perms string.\n) pdfformaterror
- ( Cannot decrypt PDF file.\n) pdfformaterror
- printProducer
- /pdf_check_r5_password cvx /rangecheck signalerror
- } if
- } if
-
- end
-} bind executeonly def
-
-% <password> pdf_check_password <filekey> true
-% <password> pdf_check_password false
-/pdf_check_password {
- % If R is 2, 3, or 4, use Algorithms 3.6 and 3.7 to see if this is
- % a valid user or owner password. Following historical practice,
- % we treat the password as an arbitrary string of bytes and don't
- % interpret it in any way. (If the password fails, it would be
- % nice to try some plausible character set conversions, but this
- % gets complicated. Even Adobe products don't seem to handle it
- % consistently.)
- %
- % If R is 5, use Algorithm 3.2a. The password should be text, in
- % either UTF-8 or the current locale's charset.
-
- Trailer /Encrypt oget /R oget
-
- dup dup 2 ge exch 4 le and {
- pop
- dup pdf_check_pre_r5_user_password {
- exch pop //true
- } {
- pdf_check_pre_r5_owner_password
- } ifelse
- } {
- dup 5 eq {
- pop
- % First, try the password as UTF-8.
- dup pdf_check_r5_password {
- exch pop //true
- } {
- % The password didn't work as UTF-8, so maybe it's in the
- % locale character set instead. If possible, convert it to
- % UTF-8 and try again.
- /.locale_to_utf8 where {
- pop .locale_to_utf8 pdf_check_r5_password
- } {
- pop //false
- } ifelse
- } ifelse
- } {
- dup 6 eq {
- pop
- % First, try the password as UTF-8.
- dup Trailer /Encrypt oget //check_r6_password exec {
- exch pop //true
- } {
- % The password didn't work as UTF-8, so maybe it's in the
- % locale character set instead. If possible, convert it to
- % UTF-8 and try again.
- /.locale_to_utf8 where {
- pop .locale_to_utf8 Trailer /Encrypt oget //check_r6_password exec
- } {
- pop //false
- } ifelse
- } ifelse
- } {
- ( **** Warning: This file uses an unknown standard security handler revision: )
- exch =string cvs concatstrings (\n) concatstrings pdfformatwarning
- ( Cannot decrypt PDF file.\n) pdfformaterror
- printProducer
- /pdf_check_password cvx /undefined signalerror
- } ifelse
- } ifelse
- } ifelse
-} bind executeonly def
-systemdict /check_r6_password .forceundef
-
-% Process the encryption information in the Trailer.
-/pdf_process_Encrypt {
- Trailer /Encrypt oget
- /Filter oget /Standard eq not {
- ( **** Warning: This file uses an unknown security handler.\n) pdfformatwarning
- ( Cannot decrypt PDF file.\n) pdfformaterror
- printProducer
- /pdf_process_Encrypt cvx /undefined signalerror
- } if
-
- % Bug 702598: We can have a trailer dictionary with an /Encrypt entry, and if the
- % Encrypt dictionary is V 4 or greater we can (should ?) have StrF and stmF entries.
- %
- % The code below checks for the existence of StmF and StrF entries. Its possible
- % that both may be /Identity (which means no encryption) in which case we don't need to check
- % the password, as we won't need to decrypt any streams or strings. Note that the dict may still
- % have a non-Identity /EFF (embedded files) key, but Ghostscript doesn't process embedded
- % files so we don't have to worry about that.
- Trailer /Encrypt oget dup
- /V get 4 ge {
- % NB: Entries in the Encrypt dictionary cannot be indirect references
- dup /StmF .knownget {
- /Identity eq not
- } {
- false % default StmF is Identity
- }ifelse
- 1 index /StrF .knownget {
- /Identity eq not
- } {
- false % default StrF is Identity
- }ifelse
- or
- % ...still in the V4 or above checking...
- % Even if StmF and StrF are Identity, if the StdCF is missing AuthEvent
- % or it is DocOpen, we require the password. Check for that.
- 1 index /CF .knownget {
- oforce dup type /dicttype eq {
- /StdCF .knownget {
- oforce dup type /dicttype eq {
- /AuthEvent .knownget {
- oforce dup type /nametype eq {
- /DocOpen eq
- or
- }{
- ( **** Error: AuthEvent has wrong type.\n) pdfformaterror
- ( Cannot decrypt PDF file.\n) pdfformaterror
- /pdf_process_Encrypt cvx /invalidfileaccess signalerror
- } ifelse
- } {
- pop true % no AuthEvent, default is DocOpen, require password
- } ifelse
- }{
- ( **** Error: StdCF has wrong type.\n) pdfformaterror
- ( Cannot decrypt PDF file.\n) pdfformaterror
- /pdf_process_Encrypt cvx /invalidfileaccess signalerror
- } ifelse
- } {
- pop true % no StdCF, require password
- } ifelse
- }{
- ( **** Error: CF has wrong type.\n) pdfformaterror
- ( Cannot decrypt PDF file.\n) pdfformaterror
- /pdf_process_Encrypt cvx /invalidfileaccess signalerror
- } ifelse
- } {
- pop true % no CF, require password
- } ifelse
- exch pop % discard Encrypt dict
- }{
- % Not V4 or later
- pop true % discard Encrypt dict, require password
- } ifelse
- % If we were given a PDFPassword, check it anyway, even if the
- % code above said we didn't need one. This will allow us to process
- % PDF files with an initial CryptFilter which has StrF=StmF=Identity,
- % but contains streams which themselves have non-Identity StmF or StrF.
- /PDFPassword where {
- pop true
- }
- {
- false
- } ifelse
- or
- {
- () pdf_check_password
- {
- /FileKey exch def
- } {
- /PDFPassword where {
- pop PDFPassword pdf_check_password
- {
- /FileKey exch def
- } {
- ( **** Error: Password did not work.\n) pdfformaterror
- ( Cannot decrypt PDF file.\n) pdfformaterror
-
- % If ghostscript was built without libidn, it's missing the
- % .saslprep operator and thus can't do proper Unicode password
- % normalization. Similarly, if the system provides neither
- % iconv nor the Windows MultiByteToWideChar function, then we
- % won't have the .locale_to_utf8 operator to convert passwords
- % from the locale character set to UTF-8.
- %
- % It's not a huge problem if you're missing either or both of
- % these. ASCII passwords will work fine regardless, and even
- % Unicode passwords will often be okay.
- %
- % However, if .saslprep or .locale_to_utf8 is missing, and the
- % user enters a non-ASCII password that doesn't work, we give
- % a warning message.
- PDFPassword contains_non_ascii {
- /.saslprep where not {
- ( **** WARNING: Ghostscript was configured without libidn,\n)
- ( **** so non-ASCII passwords aren't supported!\n)
- concatstrings pdfformaterror
- } {
- pop
- /.locale_to_utf8 where not {
- ( **** WARNING: Ghostscript was configured without iconv,\n)
- ( **** so non-ASCII passwords aren't supported!\n)
- concatstrings pdfformaterror
- } {
- pop
- } ifelse
- } ifelse
- } if
-
- /pdf_process_Encrypt cvx /invalidfileaccess signalerror
- } ifelse
- } {
- ( **** This file requires a password for access.\n) pdfformaterror
- /pdf_process_Encrypt cvx /invalidfileaccess signalerror
- } ifelse
- } ifelse
- }
- {
- ( **** This file has an Encryption dictionary, but both the StmF and StrF entries\n) pdfformatwarning
- ( **** are /Identity, and AuthEvent allows the document to be opened. It is possible\n) pdfformatwarning
- ( **** that embedded streams may still use encryption, if the file fails to process\n) pdfformatwarning
- ( **** you may need to supply a User or Owner password by setting -sPDFPassword=\n) pdfformatwarning
- } ifelse
-} bind executeonly def
-
-% Calculate the key used to decrypt an object (to pass to .decpdfrun or
-% put into a stream dictionary).
-/computeobjkey % <object#> <generation#> computeobjkey <keystring>
-{
- Trailer /Encrypt oget /V oget 5 eq {
- % Encrypt version 5 doesn't use object keys; everything is
- % encrypted with the file key.
- pop pop FileKey
- } {
- exch
- FileKey length 5 add string
- dup 0 FileKey putinterval
- exch
- % stack: gen# string obj#
- 2 copy 255 and FileKey length exch put
- 2 copy -8 bitshift 255 and FileKey length 1 add exch put
- 2 copy -16 bitshift 255 and FileKey length 2 add exch put
- pop exch
- 2 copy 255 and FileKey length 3 add exch put
- 2 copy -8 bitshift 255 and FileKey length 4 add exch put
- pop
- % this step is for the AES cipher only
- Trailer /Encrypt oget
- dup /StmF knownoget {
- %% Treat StmF of 'Identity' the same as if it is missing.
- dup /Identity eq {
- pop pop
- } {
- exch /CF knownoget {
- exch oget /CFM oget /AESV2 eq {
- (sAlT) concatstrings
- } if
- } {
- pop
- } ifelse
- } ifelse
- } {
- pop
- } ifelse
- md5 0 FileKey length 5 add 2 index length .min getinterval
- } ifelse
-} bind executeonly def
-
-% As .pdfrun, but decrypt strings with key <key>.
-/PDFScanRules_true << /PDFScanRules //true >> def
-/PDFScanRules_null << /PDFScanRules //null >> def
-/.decpdfrun % <file> <keystring> <opdict> .decpdfrun -
- { % Construct a procedure with the file, opdict and key bound into it.
- 2 index cvlit mark
- /PDFScanRules .getuserparam //null eq {
- //PDFScanRules_true { setuserparams } 0 get % force PDF scanning mode
- mark 7 4 roll
- } {
- mark 5 2 roll
- } ifelse
- { .pdftoken not { (%%EOF) cvn cvx } if
- dup xcheck
- { PDFDEBUG { dup //== exec flush } if
- 3 -1 roll pop
- 2 copy .knownget
- { exch pop exch pop exec
- }
- { exch pop
- dup /true eq
- { pop //true
- }
- { dup /false eq
- { pop //false
- }
- { dup /null eq
- { pop //null
- }
- { ( **** Error: Unknown operator: )
- exch =string cvs concatstrings (\n) concatstrings
- pdfformaterror
- ( Output may be incorrect.\n) pdfformaterror
- }
- ifelse
- }
- ifelse
- }
- ifelse
- }
- ifelse
- }
- { exch pop PDFDEBUG { dup ==only ( ) print flush } if
- dup type /stringtype eq
- {
- % Check if we have encrypted strings R>=4 allows for
- % selection of encryption on streams and strings
- Trailer /Encrypt oget % Get encryption dictionary
- dup /R oget 4 lt % only >=4 has selectable
- { % R < 4 --> arc4 strings
- pop 1 index arc4decode % Decrypt string
- PDFDEBUG { (%Decrypted: ) print dup //== exec flush } if
- } { % Else R >= 4
- /StrF knownoget % Get StrF (if present)
- { % If StrF is present ...
- dup /Identity eq not % Check if StrF != Identity
- { /StdCF eq
- { Trailer /Encrypt oget /CF knownoget {
- /StdCF oget /CFM oget
- dup /AESV2 eq exch /AESV3 eq or
- } {
- //false
- } ifelse { % Decrypt string
- 1 index aesdecode
- } {
- 1 index arc4decode
- } ifelse
- }
- { 1 index arc4decode }
- ifelse % If StrF != StdCF
- PDFDEBUG { (%Decrypted: ) print dup //== exec flush } if
- }
- { pop }
- ifelse % If StrF != identity
- }
- if % If StrF is known
- }
- ifelse % Ifelse R < 4
- } {
- dup type /nametype eq {
- .pdffixname
- } if
- }
- ifelse
- exch pop
- }
- ifelse
- }
- aload pop //.packtomark exec cvx
- { loop } 0 get 2 packedarray cvx
- { stopped } 0 get
- /PDFScanRules .getuserparam //null eq {
- //PDFScanRules_null { setuserparams } 0 get % reset PDF scannig mode if it was off
- } if
- /PDFsource PDFsource
- { store { stop } if } aload pop //.packtomark exec cvx
- /PDFsource 3 -1 roll store exec
- } bind executeonly def
-currentdict /PDFScanRules_true undef
-currentdict /PDFScanRules_null undef
-
-% Run the code to resolve an object reference.
-/pdf_run_resolve
-{ /FileKey where % Check if the file is encrypted
- { pop % File is encrypted
- 2 copy computeobjkey dup 4 1 roll
- PDFfile exch resolveopdict .decpdfrun
- dup dup dup 5 2 roll
- % stack: object object key object object
- { % Use loop to provide an exitable context.
- xcheck exch type /dicttype eq and % Check if executable dictionary
- not { % If object is not ...
- pop pop % ignore object
- exit % Exit 'loop' context
- } if % If not possible stream
- % Starting with PDF 1.4 (R = 3), there are some extra features
- % which control encryption of streams. The EncryptMetadata entry
- % in the Encrypt dict controls the encryption of metadata streams.
- Trailer /Encrypt oget % Get encryption dictionary
- dup /R oget dup 3 lt % Only PDF 1.4 and higher has options
- { % R < 3 --> all streams encrypted
- pop pop /StreamKey exch put % Insert StreamKey in dictionary
- exit % Exit 'loop' context
- } if
- % Check EncryptMeta. stack: object object key Encrypt R
- exch dup /EncryptMetadata knownoget % Get EncryptMetadata (if present)
- not { //true } if % If not present default = true
- not % Check if EncryptMetadata = false
- { % if false we need to check the stream type
- 3 index /Type knownoget % Get stream type (if present)
- not { //null } if % If type not present use fake name
- /Metadata eq % Check if the type is Metadata
- { pop pop pop pop % Type == Metadata --> no encryption
- exit % Exit 'loop' context
- } if
- } if
- % PDF 1.5 encryption (R == 4) has selectable encryption handlers. If
- % this is not PDF 1.5 encryption (R < 4) then we are done checking and
- % we need to decrypt the stream. stack: object object key R Encrypt
- exch 4 lt % Check for less than PDF 1.5
- { pop /StreamKey exch put % Insert StreamKey in dictionary
- exit % Exit 'loop' context
- } if
- % Check if the stream encryption handler (StmF) == Identity.
- PDFDEBUG {
- Trailer /Encrypt oget /CF knownoget {
- /StdCF oget /CFM oget
- (Encrypt StmF is StdCF with CFM ) print =
- } if
- } if
- /StmF knownoget % Get StmF (if present)
- not { /Identity } if % If StmF not present default = Identity
- /Identity eq % Check if StmF == Identity
- { pop pop % Identity --> no encryption
- exit % Exit 'loop' context
- } if
- % If we get here then we need to decrypt the stream.
- /StreamKey exch put % Insert StreamKey into dictionary
- exit % Exit 'loop' context, never loop
- } loop % End of loop exitable context
- } { % Else file is not encrypted
- PDFfile resolveopdict .pdfrun
- } ifelse % Ifelse encrypted
-} bind executeonly def
-
-% Prefix a decryption filter to a stream if needed.
-% Stack: readdata? dict parms file/string filternames
-% (both before and after).
-/pdf_decrypt_stream
- { 3 index /StreamKey known % Check if the file is encrypted
- {
- exch
- % Stack: readdata? dict parms filternames file/string
- 3 index /StreamKey get
- Trailer /Encrypt oget
- dup /StmF knownoget
- { % stack: key Encrypt StmF
- exch /CF knownoget {
- exch oget /CFM oget % stack: key StmF-CFM
- dup /AESV2 eq exch /AESV3 eq or
- } { pop //false } ifelse
- { aesdecodefilter } % install the requested filter
- { arc4decodefilter }
- ifelse
- }
- { pop arc4decodefilter } % fallback for no StmF
- ifelse
- exch
- } if
- } bind executeonly def
-
-end % pdfdict
-
-systemdict /pdfdict .forceundef % hide pdfdict
-
-.setglobal
diff --git a/Master/tlpkg/tlgs/Resource/SubstCID/CNS1-WMode b/Master/tlpkg/tlgs/Resource/SubstCID/CNS1-WMode
index 9b3939fab43..44967c682c1 100644
--- a/Master/tlpkg/tlgs/Resource/SubstCID/CNS1-WMode
+++ b/Master/tlpkg/tlgs/Resource/SubstCID/CNS1-WMode
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% $Id:
diff --git a/Master/tlpkg/tlgs/Resource/SubstCID/GB1-WMode b/Master/tlpkg/tlgs/Resource/SubstCID/GB1-WMode
index 7d022f8536f..6a04c71bfa1 100644
--- a/Master/tlpkg/tlgs/Resource/SubstCID/GB1-WMode
+++ b/Master/tlpkg/tlgs/Resource/SubstCID/GB1-WMode
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% $Id:
diff --git a/Master/tlpkg/tlgs/Resource/SubstCID/Japan1-WMode b/Master/tlpkg/tlgs/Resource/SubstCID/Japan1-WMode
index f2110449b4b..6619010a847 100644
--- a/Master/tlpkg/tlgs/Resource/SubstCID/Japan1-WMode
+++ b/Master/tlpkg/tlgs/Resource/SubstCID/Japan1-WMode
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% $Id:
diff --git a/Master/tlpkg/tlgs/Resource/SubstCID/Korea1-WMode b/Master/tlpkg/tlgs/Resource/SubstCID/Korea1-WMode
index 8832bbe45b8..67e29e54cd0 100644
--- a/Master/tlpkg/tlgs/Resource/SubstCID/Korea1-WMode
+++ b/Master/tlpkg/tlgs/Resource/SubstCID/Korea1-WMode
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% $Id:
diff --git a/Master/tlpkg/tlgs/bin/gsdll64.dll b/Master/tlpkg/tlgs/bin/gsdll64.dll
index e52883305ae..e5964bee3c9 100755
--- a/Master/tlpkg/tlgs/bin/gsdll64.dll
+++ b/Master/tlpkg/tlgs/bin/gsdll64.dll
Binary files differ
diff --git a/Master/tlpkg/tlgs/bin/gswin64.exe b/Master/tlpkg/tlgs/bin/gswin64.exe
index 7b93fcda6f6..b35f06f9333 100755
--- a/Master/tlpkg/tlgs/bin/gswin64.exe
+++ b/Master/tlpkg/tlgs/bin/gswin64.exe
Binary files differ
diff --git a/Master/tlpkg/tlgs/bin/gswin64c.exe b/Master/tlpkg/tlgs/bin/gswin64c.exe
index f969c5300dd..4494fa3b232 100755
--- a/Master/tlpkg/tlgs/bin/gswin64c.exe
+++ b/Master/tlpkg/tlgs/bin/gswin64c.exe
Binary files differ
diff --git a/Master/tlpkg/tlgs/lib/PDFA_def.ps b/Master/tlpkg/tlgs/lib/PDFA_def.ps
index c5e2aa6801c..96cb6776175 100644
--- a/Master/tlpkg/tlgs/lib/PDFA_def.ps
+++ b/Master/tlpkg/tlgs/lib/PDFA_def.ps
@@ -70,7 +70,7 @@ def
{ICCProfile (r) file} stopped
{
(\n\tFailed to open the supplied ICCProfile for reading. This may be due to\n) print
- (\t an incorrect filename or a failure to add --permif-file-read=<profile>\n) print
+ (\t an incorrect filename or a failure to add --permit-file-read=<profile>\n) print
(\t to the command line. This PostScript program needs to open the file\n) print
(\t and you must explicitly grant it permission to do so.\n\n) print
(\tPDF/A processing aborted, output may not be a PDF/A file.\n\n) print
diff --git a/Master/tlpkg/tlgs/lib/align.ps b/Master/tlpkg/tlgs/lib/align.ps
index e1f562b39a1..ae5b21e71a3 100644
--- a/Master/tlpkg/tlgs/lib/align.ps
+++ b/Master/tlpkg/tlgs/lib/align.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Print a page that indicates the proper settings of Margins and HWMargins
diff --git a/Master/tlpkg/tlgs/lib/caption.ps b/Master/tlpkg/tlgs/lib/caption.ps
index 7e345ba502e..72b117ba936 100644
--- a/Master/tlpkg/tlgs/lib/caption.ps
+++ b/Master/tlpkg/tlgs/lib/caption.ps
@@ -1,5 +1,5 @@
%!
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -10,8 +10,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Add a "caption" to the bottom of each page.
diff --git a/Master/tlpkg/tlgs/lib/cat.ps b/Master/tlpkg/tlgs/lib/cat.ps
new file mode 100644
index 00000000000..fd3698da838
--- /dev/null
+++ b/Master/tlpkg/tlgs/lib/cat.ps
@@ -0,0 +1,74 @@
+% Copyright (C) 2001-2023 Artifex Software, Inc.
+% 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.
+%
+% Refer to licensing information at http://www.artifex.com or contact
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
+%
+%
+% $Id: cat.ps 8331 2008-02-05 11:07:00Z kens $
+%
+% Appends one file to another. Primarily used to overcome the
+% 'copy' limitation of Windows command shell for ps2epsi
+%
+% the files to be appended are given by the environament
+% variables %infile% and %outfile%. %infile% is appended to
+% %outfile%
+%
+
+/datastring 1024 string def
+
+{
+ (outfile) getenv
+ {
+ /outfilename exch def
+ (infile) getenv
+ {
+ /infilename exch def
+
+ infilename status
+ {
+ pop pop pop pop outfilename status
+ {
+ pop pop pop pop
+ infilename (r) file /infile exch def
+ outfilename (a+) file /outfile exch def
+ {
+ infile datastring readstring
+ {
+ outfile exch writestring
+ }
+ {
+ dup length 0 gt
+ {outfile exch writestring} {pop} ifelse
+ exit
+ } ifelse
+ } loop
+ infile closefile
+ outfile closefile
+ }
+ {
+ (Failed to find file ) print outfilename ==
+ } ifelse
+ }
+ {
+ (Failed to find file ) print infilename ==
+ } ifelse
+ }
+ {
+ (Couldn't find %infile% environment variable) ==
+ } ifelse
+ }
+ {
+ (Couldn't find %outfile% environment variable) ==
+ }
+ ifelse
+} bind
+exec
diff --git a/Master/tlpkg/tlgs/lib/cid2code.ps b/Master/tlpkg/tlgs/lib/cid2code.ps
index 45044cdf955..cafc92dd1e9 100644
--- a/Master/tlpkg/tlgs/lib/cid2code.ps
+++ b/Master/tlpkg/tlgs/lib/cid2code.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Construct an inverse map from CIDs to codes.
diff --git a/Master/tlpkg/tlgs/lib/docie.ps b/Master/tlpkg/tlgs/lib/docie.ps
index 1d1ad9a193c..7f7f4d4caff 100644
--- a/Master/tlpkg/tlgs/lib/docie.ps
+++ b/Master/tlpkg/tlgs/lib/docie.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% docie.ps
diff --git a/Master/tlpkg/tlgs/lib/font2pcl.ps b/Master/tlpkg/tlgs/lib/font2pcl.ps
new file mode 100644
index 00000000000..4dcf22a5f79
--- /dev/null
+++ b/Master/tlpkg/tlgs/lib/font2pcl.ps
@@ -0,0 +1,604 @@
+% Copyright (C) 2001-2023 Artifex Software, Inc.
+% 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.
+%
+% Refer to licensing information at http://www.artifex.com or contact
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
+%
+
+% font2pcl.ps
+% Write out a font as a PCL bitmap font.
+
+/pcldict 60 dict def
+
+% Write out the current font as a PCL bitmap font.
+% The current transformation matrix defines the font size and orientation.
+
+/WriteResolution? false def % true=use "resolution bound font" format,
+ % false=use older format
+
+/LJ4 false def % true=use LJ4 Typeface code
+ % false=use LJIIP/IID/IIIx Typeface code
+
+pcldict begin % internal procedures
+
+/findstring % <string> <substring> findstring <bool>
+ { search { pop pop pop true } { pop false } ifelse
+ } def
+
+ % Determine which set of keywords is present in a string.
+ % The last keyword set must be empty.
+
+/keysearch % <string> <array of arrays of keywords> keysearch <index>
+ { 0 1 2 index length 1 sub
+ { 2 copy get true exch
+ { % Stack: <string> <a.a.k.> <index> <bool> <keyword>
+ 4 index exch findstring and
+ }
+ forall
+ { 0 exch getinterval exit
+ }
+ if pop
+ }
+ for
+ exch pop length % invalid index if missing
+ } def
+
+ % Determine the device height of a string in quarter-dots.
+
+/charheight % <string> charheight <int>
+ { gsave newpath 0 0 moveto false charpath
+ pathbbox exch pop exch sub exch pop 0 exch grestore
+ dtransform add abs 4 mul cvi
+ } def
+
+ % Compute an integer version of the transformed FontBBox.
+
+/inflate % <num> inflate <num>
+ { dup 0 gt { ceiling } { floor } ifelse
+ } def
+/ixbbox % - ixbbox <llx> <lly> <urx> <ury>
+ { /FontBBox load aload pop % might be executable or literal
+ 4 2 roll transform exch truncate cvi exch truncate cvi
+ 4 2 roll transform exch inflate cvi exch inflate cvi
+ } def
+
+ % Determine the original font of a possibly transformed font.
+ % Since some badly behaved PostScript files construct transformed
+ % fonts "by hand", we can't just rely on the OrigFont pointers.
+ % Instead, if a font with the given name exists, and if its
+ % entries for FontType and UniqueID match those of the font we
+ % obtain by following the OrigFont chain, we use that font.
+
+/origfont
+ { { dup /OrigFont known not { exit } if /OrigFont get } loop
+ FontDirectory 1 index /FontName get .knownget
+ { % Stack: origfont namedfont
+ 1 index /FontType get 1 index /FontType get eq
+ { 1 index /UniqueID .knownget
+ { 1 index /UniqueID .knownget
+ { eq { exch } if }
+ { pop }
+ ifelse
+ }
+ if
+ }
+ if pop
+ }
+ if
+ } def
+
+ % Determine the bounding box of the current device's image.
+ % Free variables: row, zerow.
+
+/devbbox % <rw> <rh> devbbox <ymin> <ymax1> <xmin> <xmax1>
+ { % Find top and bottom whitespace.
+ dup
+ { dup 0 eq { exit } if 1 sub
+ dup currentdevice exch row copyscanlines
+ zerow ne { 1 add exit } if
+ }
+ loop % ymax1
+ 0
+ { 2 copy eq { exit } if
+ dup currentdevice exch row copyscanlines
+ zerow ne { exit } if
+ 1 add
+ }
+ loop % ymin
+ exch
+ % Find left and right whitespace.
+ 3 index 0
+ % Stack: rw rh ymin ymax1 xmin xmax1
+ 3 index 1 4 index 1 sub
+ { currentdevice exch row copyscanlines .findzeros
+ exch 4 1 roll .max 3 1 roll .min exch
+ }
+ for % xmin xmax1
+ % Special check: xmin > xmax1 if height = 0
+ 2 copy gt { exch pop dup } if
+ 6 -2 roll pop pop
+
+ } def
+
+ % Write values on outfile.
+
+ /w1 { 255 and outfile exch write } def
+ /w2 { dup -8 bitshift w1 w1 } def
+ /wbyte % <byte> <label> wbyte
+ { VDEBUG { print ( =byte= ) print dup == flush } { pop } ifelse w1
+ } def
+ /wword % <word16> <label> wword
+ { VDEBUG { print ( =word= ) print dup == flush } { pop } ifelse w2
+ } def
+ /wdword % <word32> <label> wdword
+ { VDEBUG { print ( =dword= ) print dup == flush } { pop } ifelse
+ dup -16 bitshift w2 w2
+ } def
+
+/style.posture.keys
+ [ { (Italic) } { (Oblique) }
+ { }
+ ] def
+/style.posture.values <010100> def
+
+/style.appearance.width.keys
+ [ { (Ultra) (Compressed) }
+ { (Extra) (Compressed) }
+ { (Extra) (Condensed) }
+ { (Extra) (Extended) }
+ { (Extra) (Expanded) }
+ { (Compressed) }
+ { (Condensed) }
+ { (Extended) }
+ { (Expanded) }
+ { }
+ ] def
+/style.appearance.width.values <04030207070201060600> def
+
+/width.type.keys
+ [ { (Ultra) (Compressed) }
+ { (Extra) (Compressed) }
+ { (Extra) (Condensed) }
+ { (Extra) (Expanded) }
+ { (Compressed) }
+ { (Condensed) }
+ { (Expanded) }
+ { }
+ ] def
+/width.type.values <fbfcfd03fdfe0200> def
+
+/stroke.weight.keys
+ [ { (Ultra) (Thin) }
+ { (Ultra) (Black) }
+ { (Extra) (Thin) }
+ { (Extra) (Light) }
+ { (Extra) (Bold) }
+ { (Extra) (Black) }
+ { (Demi) (Light) }
+ { (Demi) (Bold) }
+ { (Semi) (Light) }
+ { (Semi) (Bold) }
+ { (Thin) }
+ { (Light) }
+ { (Bold) }
+ { (Black) }
+ { }
+ ] def
+/stroke.weight.values <f907fafc0406fe02ff01fbfd030500> def
+
+/vendor.keys
+ [ { (Agfa) }
+ { (Bitstream) }
+ { (Linotype) }
+ { (Monotype) }
+ { (Adobe) }
+ { }
+ ] def
+/vendor.default.index 4 def % might as well be Adobe
+/old.vendor.values <020406080a00> def
+/new.vendor.values <010203040500> def
+/vendor.initials (CBLMA\000) def
+
+currentdict readonly end pop % pcldict
+
+% Convert and write a PCL font for the current font and transformation.
+
+% Write the font header. We split this off only to avoid overflowing
+% the limit on the maximum size of a procedure.
+% Free variables: outfile uury u0y rw rh orientation uh ully
+/writefontheader
+ { outfile (\033\)s) writestring
+ outfile 64 WriteResolution? { 4 add } if
+ Copyright length add write==only
+ outfile (W) writestring
+ WriteResolution? { 20 68 } { 0 64 } ifelse
+ (Font Descriptor Size) wword
+ (Header Format) wbyte
+ 1 (Font Type) wbyte
+ FullName style.posture.keys keysearch style.posture.values exch get
+ FullName style.appearance.width.keys keysearch
+ style.appearance.width.values exch get 4 mul add
+ PaintType 2 eq { 32 add } if
+ /style exch def
+ style -8 bitshift (Style MSB) wbyte
+ 0 (Reserved) wbyte
+ /baseline uury 1 sub u0y sub def
+ baseline (Baseline Position) wword
+ rw (Cell Width) wword
+ rh (Cell Height) wword
+ orientation (Orientation) wbyte
+ FontInfo /isFixedPitch .knownget not { false } if
+ { 0 } { 1 } ifelse (Spacing) wbyte
+ % Use loop/exit to fake a multiple-exit block.
+ { Encoding StandardEncoding eq { 10 (J) exit } if
+ Encoding ISOLatin1Encoding eq { 11 (J) exit } if
+ Encoding SymbolEncoding eq { 19 (M) exit } if
+ Encoding DingbatsEncoding eq { 10 (L) exit } if
+% (Warning: unknown Encoding, using ISOLatin1.\n) print flush
+ 11 (J) exit
+ }
+ loop
+ 0 get 64 sub exch 32 mul add (Symbol Set) wword
+ ( ) stringwidth pop 0 dtransform add abs 4 mul
+ /pitch exch def
+ pitch cvi (Pitch) wword
+ uh 4 mul (Height) wword % Height
+ (x) charheight (x-Height) wword
+ FullName width.type.keys keysearch
+ width.type.values exch get (Width Type) wbyte
+ style 255 and (Style LSB) wbyte
+ FullName stroke.weight.keys keysearch
+ stroke.weight.values exch get (Stroke Weight) wbyte
+ FullName vendor.keys keysearch
+ dup vendor.initials exch get 0 eq
+ { % No vendor in FullName, try Notice
+ pop Copyright vendor.keys keysearch
+ dup vendor.initials exch get 0 eq { pop vendor.default.index } if
+ }
+ if
+ /vendor.index exch def
+ 0 (Typeface LSB) wbyte % punt
+ 0 (Typeface MSB) wbyte % punt
+ 0 (Serif Style) wbyte % punt
+ 2 (Quality) wbyte
+ 0 (Placement) wbyte
+ gsave FontMatrix concat rot neg rotate
+ /ulwidth
+ FontInfo /UnderlineThickness .knownget
+ { 0 exch dtransform exch pop abs }
+ { resolution 100 div }
+ ifelse def
+ FontInfo /UnderlinePosition .knownget
+ { 0 exch transform exch pop negY ulwidth 2 div add }
+ { ully ulwidth add }
+ ifelse u0y sub
+ round cvi 1 .max 255 .min (Underline Position) wbyte
+ ulwidth round cvi 1 .max 255 .min (Underline Thickness) wbyte
+ grestore
+ uh 1.2 mul 4 mul cvi (Text Height) wword
+ (average lowercase character) dup stringwidth
+ pop 0 dtransform add abs
+ exch length div 4 mul cvi (Text Width) wword
+ 0
+ { dup Encoding exch get /.notdef ne { exit } if
+ 1 add
+ }
+ loop (First Code) wword
+ 255
+ { dup Encoding exch get /.notdef ne { exit } if
+ 1 sub
+ }
+ loop (Last Code) wword
+ pitch dup cvi sub 256 mul cvi (Pitch Extended) wbyte
+ 0 (Height Extended) wbyte
+ 0 (Cap Height) wword % (default)
+ currentfont /UniqueID known { UniqueID } { 0 } ifelse
+ 16#c1000000 add (Font Number (Adobe UniqueID)) wdword
+ FontName length 16 .max string
+ dup FontName exch cvs pop
+ outfile exch 0 16 getinterval writestring % Font Name
+ WriteResolution?
+ { resolution dup (X Resolution) wword (Y Resolution) wword
+ }
+ if
+ outfile Copyright writestring % Copyright
+ } def
+
+/writePCL % <fontfile> <resolution> writePCL -
+ {
+ save
+ currentfont begin
+ pcldict begin
+ 80 dict begin % allow for recursion
+ /saved exch def
+ /resolution exch def
+ /outfile exch def
+ matrix currentmatrix dup 4 0 put dup 5 0 put setmatrix
+
+ % Supply some default values so we don't have to check later.
+
+ currentfont /FontInfo known not { /FontInfo 1 dict def } if
+ currentfont /FontName known not { /FontName () def } if
+ /Copyright FontInfo /Notice .knownget not { () } if def
+ /FullName
+ FontInfo /FullName .knownget not
+ { FontName dup length string cvs }
+ if def
+
+ % Determine the original font, and its relationship to this one.
+
+ /OrigFont currentfont origfont def
+ /OrigMatrix OrigFont /FontMatrix get def
+ /OrigMatrixInverse OrigMatrix matrix invertmatrix def
+ /ScaleMatrix matrix currentfont OrigFont ne
+ { FontMatrix exch OrigMatrixInverse exch concatmatrix
+ } if
+ def
+ /CurrentScaleMatrix
+ matrix currentmatrix
+ matrix defaultmatrix
+ dup 0 get 1 index 3 get mul 0 lt
+ 1 index dup 1 get exch 2 get mul 0 gt or
+ /flipY exch def
+ dup invertmatrix
+ dup concatmatrix
+ def
+ /negY flipY { {neg} } { {} } ifelse def
+
+ % Print debugging information.
+
+ /CDEBUG where { pop } { /CDEBUG false def } ifelse
+ /VDEBUG where { pop } { /VDEBUG false def } ifelse
+ CDEBUG { /VDEBUG true def } if
+ DEBUG
+ { (currentmatrix: ) print matrix currentmatrix ==
+ (defaultmatrix: ) print matrix defaultmatrix ==
+ (flipY: ) print flipY ==
+ (scaling matrix: ) print CurrentScaleMatrix ==
+ (FontMatrix: ) print FontMatrix ==
+ (FontBBox: ) print /FontBBox load ==
+ currentfont OrigFont ne
+ { OrigFont /FontName .knownget { (orig FontName: ) print == } if
+ (orig FontMatrix: ) print OrigMatrix ==
+ } if
+ currentfont /ScaleMatrix .knownget { (ScaleMatrix: ) print == } if
+ gsave
+ FontMatrix concat
+ (combined matrix: ) print matrix currentmatrix ==
+ grestore
+ flush
+ } if
+
+ % Determine the orientation.
+
+ ScaleMatrix matrix currentmatrix dup concatmatrix
+ 0 1 3
+ { 1 index 1 get 0 eq 2 index 2 get 0 eq and 2 index 0 get 0 gt and
+ { exit } if
+ pop -90 matrix rotate exch dup concatmatrix
+ }
+ for
+ dup type /integertype ne
+ { (Only rotations by multiples of 90 degrees are supported:\n) print
+ == flush
+ saved end end end restore stop
+ }
+ if
+ /orientation exch def
+ /rot orientation 90 mul def
+ DEBUG { (orientation: ) print orientation == flush } if
+
+ dup dup 0 get exch 3 get negY sub abs 0.5 ge
+ { (Only identical scaling in X and Y is supported:\n) print
+ exch flipY 3 array astore ==
+%
+% .devicename has been deprecated
+% currentdevice .devicename ==
+%
+ currentpagedevice /Name get ==
+ matrix defaultmatrix == flush
+ saved end end end restore stop
+ }
+ if pop
+
+ % Determine the font metrics, in the PCL character coordinate system,
+ % which has +Y going towards the top of the page.
+
+ gsave
+ FontMatrix concat
+ 0 0 transform
+ negY round cvi /r0y exch def
+ round cvi /r0x exch def
+ ixbbox
+ negY /rury exch def /rurx exch def
+ negY /rlly exch def /rllx exch def
+ /rminx rllx rurx .min def
+ /rminy rlly negY rury negY .min def
+ /rw rurx rllx sub abs def
+ /rh rury rlly sub abs def
+ gsave rot neg rotate
+ 0 0 transform
+ negY round cvi /u0y exch def
+ round cvi /u0x exch def
+ ixbbox
+ negY /uury exch def /uurx exch def
+ negY /ully exch def /ullx exch def
+ /uw uurx ullx sub def
+ /uh uury ully sub def
+ grestore
+ DEBUG
+ { (rmatrix: ) print matrix currentmatrix ==
+ (rFontBBox: ) print [rllx rlly rurx rury] ==
+ (uFontBBox: ) print [ullx ully uurx uury] ==
+ flush
+ } if
+ grestore
+
+ % Disable the character cache, to avoid excessive allocation
+ % and memory sandbars.
+
+ mark cachestatus /upper exch def
+ cleartomark 0 setcachelimit
+
+ % Write the font header.
+
+ writefontheader
+
+ % Establish an image device for rasterizing characters.
+
+ matrix currentmatrix
+ dup 4 rminx neg put
+ dup 5 rminy neg put
+ % Round the width up to a multiple of 8
+ % so we don't get garbage bits in the last byte of each row.
+ rw 7 add -8 and rh <ff 00> makeimagedevice
+ /cdevice exch def
+ nulldevice % prevent page device switching
+ cdevice setdevice
+
+ % Rasterize each character in turn.
+
+ /raster rw 7 add 8 idiv def
+ /row raster string def
+ /zerow row length string def
+ 0 1 Encoding length 1 sub
+ { /cindex exch def
+ Encoding cindex get /.notdef ne
+ { VDEBUG { Encoding cindex get == flush } if
+ erasepage initgraphics
+ 0 0 moveto currentpoint transform add
+ ( ) dup 0 cindex put show
+ currentpoint transform add exch sub round cvi
+ /cwidth exch abs def
+ rw rh devbbox
+ VDEBUG
+ { (image bbox: ) print 4 copy 4 2 roll 4 array astore == flush
+ } if
+ % Save the device bounding box.
+ % Note that this is in current device coordinates,
+ % not PCL (right-handed) coordinates.
+ /bqx exch def /bpx exch def /bqy exch def /bpy exch def
+ % Re-render with the character justified to (0,0).
+ % This may be either the lower left or the upper left corner.
+ bpx neg bpy neg idtransform moveto
+ erasepage
+ VDEBUG { (show point: ) print [ currentpoint transform ] == flush } if
+ ( ) dup 0 cindex put show
+ % Find the bounding box. Note that xmin and ymin are now 0,
+ % xmax1 = xw, and ymax1 = yh.
+ rw rh devbbox
+ /xw exch def
+ % xmin or ymin can be non-zero only if the character is blank.
+ xw 0 eq
+ { pop }
+ { dup 0 ne { (Non-zero xmin! ) print = } { pop } ifelse }
+ ifelse
+ /yh exch def
+ yh 0 eq
+ { pop }
+ { dup 0 ne { (Non-zero ymin! ) print = } { pop } ifelse }
+ ifelse
+
+ /xbw xw 7 add 8 idiv def
+ /xright raster 8 mul xw sub def
+ % Write the Character Code command.
+ outfile (\033*c) writestring
+ outfile cindex write==only
+ outfile (E) writestring
+ % Write the Character Definition command.
+ outfile (\033\(s) writestring
+ yh xbw mul 16 add
+ outfile exch write=only
+ % Record the character position for the .PCM file.
+ /cfpos outfile fileposition 1 add def
+ outfile (W\004\000\016\001) writestring
+ orientation (Orientation) wbyte 0 (Reserved) wbyte
+ rminx bpx add r0x sub (Left Offset) wword
+ flipY { rminy bpy add neg } { rminy bqy add } ifelse r0y sub
+ (Top Offset) wword
+ xw (Character Width) wword
+ yh (Character Height) wword
+ cwidth orientation 2 ge { neg } if 4 mul (Delta X) wword
+ % Write the character data.
+ flipY { 0 1 yh 1 sub } { yh 1 sub -1 0 } ifelse
+ { cdevice exch row copyscanlines
+ 0 xbw getinterval
+ CDEBUG
+ { dup
+ { 8
+ { dup 128 ge { (+) } { (.) } ifelse print
+ 127 and 1 bitshift
+ }
+ repeat pop
+ }
+ forall (\n) print
+ }
+ if
+ outfile exch writestring
+ }
+ for
+ }
+ { /bpx 0 def /bpy 0 def /bqx 0 def /bqy 0 def
+ /cwidth 0 def
+ /cfpos 0 def
+ }
+ ifelse
+
+ }
+ for
+
+ % Wrap up.
+
+ upper setcachelimit
+ outfile closefile
+
+ nulldevice % prevent page device switching
+ saved end end end restore
+
+ } def
+
+% Provide definitions for testing with older or non-custom interpreters.
+
+/.findzeros where { pop (%END) .skipeof } if
+/.findzeros
+ { userdict begin /zs exch def /zl zs length def
+ 0 { dup zl ge { exit } if dup zs exch get 0 ne { exit } if 1 add } loop
+ zl { dup 0 eq { exit } if dup 1 sub zs exch get 0 ne { exit } if 1 sub } loop
+ exch 3 bitshift exch 3 bitshift
+ 2 copy lt
+ { exch zs 1 index -3 bitshift get
+ { dup 16#80 and 0 ne { exit } if exch 1 add exch 1 bitshift } loop pop
+ exch zs 1 index -3 bitshift 1 sub get
+ { dup 1 and 0 ne { exit } if exch 1 sub exch -1 bitshift } loop pop
+ }
+ if end
+ } bind def
+%END
+
+/write=only where { pop (%END) .skipeof } if
+/w=s 128 string def
+/write=only
+ { w=s cvs writestring
+ } bind def
+%END
+
+%**************** Test
+/PCLTEST where {
+ pop
+ /DEBUG true def
+ /CDEBUG true def
+ /VDEBUG true def
+ /Times-Roman findfont 10 scalefont setfont
+ (t.pcf) (w) file
+ 300 72 div dup scale
+ 300 writePCL
+ flush quit
+} if
diff --git a/Master/tlpkg/tlgs/lib/gs_ce_e.ps b/Master/tlpkg/tlgs/lib/gs_ce_e.ps
index 150c55b27a3..69de21220cc 100644
--- a/Master/tlpkg/tlgs/lib/gs_ce_e.ps
+++ b/Master/tlpkg/tlgs/lib/gs_ce_e.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define the Adobe CE (Central European) encoding vector.
diff --git a/Master/tlpkg/tlgs/lib/gs_il2_e.ps b/Master/tlpkg/tlgs/lib/gs_il2_e.ps
index e9ee3075845..0fb5593d6e5 100644
--- a/Master/tlpkg/tlgs/lib/gs_il2_e.ps
+++ b/Master/tlpkg/tlgs/lib/gs_il2_e.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define the ISO Latin-2 (8859-2) encoding vector.
diff --git a/Master/tlpkg/tlgs/lib/gs_kanji.ps b/Master/tlpkg/tlgs/lib/gs_kanji.ps
index f2de7816242..9377626d4a7 100644
--- a/Master/tlpkg/tlgs/lib/gs_kanji.ps
+++ b/Master/tlpkg/tlgs/lib/gs_kanji.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Scaffolding for Kanji fonts. This is based on the Wadalab free font
diff --git a/Master/tlpkg/tlgs/lib/gs_ksb_e.ps b/Master/tlpkg/tlgs/lib/gs_ksb_e.ps
index 2d2960c74bc..8c298410076 100644
--- a/Master/tlpkg/tlgs/lib/gs_ksb_e.ps
+++ b/Master/tlpkg/tlgs/lib/gs_ksb_e.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define the KanjiSub encoding vector.
diff --git a/Master/tlpkg/tlgs/lib/gs_lgo_e.ps b/Master/tlpkg/tlgs/lib/gs_lgo_e.ps
index 1f949ab9b54..39b87c194d8 100644
--- a/Master/tlpkg/tlgs/lib/gs_lgo_e.ps
+++ b/Master/tlpkg/tlgs/lib/gs_lgo_e.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define the Adobe "original" Latin glyph set.
diff --git a/Master/tlpkg/tlgs/lib/gs_lgx_e.ps b/Master/tlpkg/tlgs/lib/gs_lgx_e.ps
index a2f6216077f..067bba1d361 100644
--- a/Master/tlpkg/tlgs/lib/gs_lgx_e.ps
+++ b/Master/tlpkg/tlgs/lib/gs_lgx_e.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define the Adobe "extension" Latin glyph set.
diff --git a/Master/tlpkg/tlgs/lib/gs_wl1_e.ps b/Master/tlpkg/tlgs/lib/gs_wl1_e.ps
index 10a8f3ca533..57fc4896264 100644
--- a/Master/tlpkg/tlgs/lib/gs_wl1_e.ps
+++ b/Master/tlpkg/tlgs/lib/gs_wl1_e.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define the Windows 3.1 Latin 1 encoding vector (H-P Symbol set 19U).
diff --git a/Master/tlpkg/tlgs/lib/gs_wl2_e.ps b/Master/tlpkg/tlgs/lib/gs_wl2_e.ps
index f7fc8cc1e9a..08e2bf459c9 100644
--- a/Master/tlpkg/tlgs/lib/gs_wl2_e.ps
+++ b/Master/tlpkg/tlgs/lib/gs_wl2_e.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define the Windows 3.1 Latin 2 encoding vector (H-P Symbol set 9E).
diff --git a/Master/tlpkg/tlgs/lib/gs_wl5_e.ps b/Master/tlpkg/tlgs/lib/gs_wl5_e.ps
index f7549b49d8b..970d350a625 100644
--- a/Master/tlpkg/tlgs/lib/gs_wl5_e.ps
+++ b/Master/tlpkg/tlgs/lib/gs_wl5_e.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Define the Windows 3.1 Latin 5 encoding vector (H-P Symbol set 5T).
diff --git a/Master/tlpkg/tlgs/lib/gslp.ps b/Master/tlpkg/tlgs/lib/gslp.ps
index b2cb80df450..232e5bb07d1 100644
--- a/Master/tlpkg/tlgs/lib/gslp.ps
+++ b/Master/tlpkg/tlgs/lib/gslp.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% gslp.ps - format and print text
diff --git a/Master/tlpkg/tlgs/lib/gsnup.ps b/Master/tlpkg/tlgs/lib/gsnup.ps
index 61fd57a6633..b8719bf0b06 100644
--- a/Master/tlpkg/tlgs/lib/gsnup.ps
+++ b/Master/tlpkg/tlgs/lib/gsnup.ps
@@ -1,5 +1,5 @@
%!
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -10,8 +10,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Prefix this to very well-behaved PostScript files for n-up printing.
diff --git a/Master/tlpkg/tlgs/lib/image-qa.ps b/Master/tlpkg/tlgs/lib/image-qa.ps
index 4780c14e583..44173b1b9fa 100644
--- a/Master/tlpkg/tlgs/lib/image-qa.ps
+++ b/Master/tlpkg/tlgs/lib/image-qa.ps
@@ -1,5 +1,5 @@
%!PS
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -10,8 +10,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
%
% Tests for the image operators
diff --git a/Master/tlpkg/tlgs/lib/jispaper.ps b/Master/tlpkg/tlgs/lib/jispaper.ps
index 6b59f70b0b5..28034937769 100644
--- a/Master/tlpkg/tlgs/lib/jispaper.ps
+++ b/Master/tlpkg/tlgs/lib/jispaper.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Select JIS B paper sizes for b0...b6.
diff --git a/Master/tlpkg/tlgs/lib/jobseparator.ps b/Master/tlpkg/tlgs/lib/jobseparator.ps
new file mode 100644
index 00000000000..fbb6920842f
--- /dev/null
+++ b/Master/tlpkg/tlgs/lib/jobseparator.ps
@@ -0,0 +1,3 @@
+% Execute the "real" system version of the ^D to separate jobs
+% when -dJOBDSERVER is being used.
+<04> cvn .systemvar exec
diff --git a/Master/tlpkg/tlgs/lib/lines.ps b/Master/tlpkg/tlgs/lib/lines.ps
index a721009aaf6..e441bf1064e 100644
--- a/Master/tlpkg/tlgs/lib/lines.ps
+++ b/Master/tlpkg/tlgs/lib/lines.ps
@@ -1,5 +1,5 @@
%!
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -10,8 +10,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Test line rendering (stroke).
diff --git a/Master/tlpkg/tlgs/lib/mkcidfm.ps b/Master/tlpkg/tlgs/lib/mkcidfm.ps
index 6e017161dc3..5e35791a6d6 100644
--- a/Master/tlpkg/tlgs/lib/mkcidfm.ps
+++ b/Master/tlpkg/tlgs/lib/mkcidfm.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
diff --git a/Master/tlpkg/tlgs/lib/pdf2dsc.ps b/Master/tlpkg/tlgs/lib/pdf2dsc.ps
index 8e65d9e0279..82c3e990e14 100644
--- a/Master/tlpkg/tlgs/lib/pdf2dsc.ps
+++ b/Master/tlpkg/tlgs/lib/pdf2dsc.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% pdf2dsc.ps
diff --git a/Master/tlpkg/tlgs/lib/pdf_info.ps b/Master/tlpkg/tlgs/lib/pdf_info.ps
index 2a5f5796658..2e2aa21ab20 100644
--- a/Master/tlpkg/tlgs/lib/pdf_info.ps
+++ b/Master/tlpkg/tlgs/lib/pdf_info.ps
@@ -1,5 +1,5 @@
%!PS
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -10,8 +10,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
%
% $Id: pdf_info.ps 6300 2005-12-28 19:56:24Z alexcher $
diff --git a/Master/tlpkg/tlgs/lib/pfbtopfa.ps b/Master/tlpkg/tlgs/lib/pfbtopfa.ps
index e31db5b0603..8edafa30cef 100644
--- a/Master/tlpkg/tlgs/lib/pfbtopfa.ps
+++ b/Master/tlpkg/tlgs/lib/pfbtopfa.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% pfbtopfa.ps
diff --git a/Master/tlpkg/tlgs/lib/ppath.ps b/Master/tlpkg/tlgs/lib/ppath.ps
index daf7f3990e2..bb70151c0a4 100644
--- a/Master/tlpkg/tlgs/lib/ppath.ps
+++ b/Master/tlpkg/tlgs/lib/ppath.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Redefine pathforall for tracing.
diff --git a/Master/tlpkg/tlgs/lib/pphs.ps b/Master/tlpkg/tlgs/lib/pphs.ps
index 78dfd060e23..1be276e8869 100644
--- a/Master/tlpkg/tlgs/lib/pphs.ps
+++ b/Master/tlpkg/tlgs/lib/pphs.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Print Linearized PDF hint streams
diff --git a/Master/tlpkg/tlgs/lib/prfont.ps b/Master/tlpkg/tlgs/lib/prfont.ps
index 59b9c199610..358a04d9dae 100644
--- a/Master/tlpkg/tlgs/lib/prfont.ps
+++ b/Master/tlpkg/tlgs/lib/prfont.ps
@@ -1,7 +1,7 @@
%!
%%Creator: Eric Gisin <egisin@waterloo.csnet>
%%Title: Print font catalog
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -12,8 +12,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Copyright (c) 1986 Eric Gisin
% Copyright (C) 1992 Aladdin Enterprises, Menlo Park, CA
diff --git a/Master/tlpkg/tlgs/lib/ps2ai.ps b/Master/tlpkg/tlgs/lib/ps2ai.ps
index fd0dac4a863..1185aef6714 100644
--- a/Master/tlpkg/tlgs/lib/ps2ai.ps
+++ b/Master/tlpkg/tlgs/lib/ps2ai.ps
@@ -1,5 +1,5 @@
%!
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -10,8 +10,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
%xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
diff --git a/Master/tlpkg/tlgs/lib/ps2epsi.ps b/Master/tlpkg/tlgs/lib/ps2epsi.ps
index 07d19ded1ee..787a78f4680 100644
--- a/Master/tlpkg/tlgs/lib/ps2epsi.ps
+++ b/Master/tlpkg/tlgs/lib/ps2epsi.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
% Convert a PostScript file to an EPSI file, adding the Preview Image.
diff --git a/Master/tlpkg/tlgs/lib/rollconv.ps b/Master/tlpkg/tlgs/lib/rollconv.ps
index edeb11074e8..d1b2aa1fd18 100644
--- a/Master/tlpkg/tlgs/lib/rollconv.ps
+++ b/Master/tlpkg/tlgs/lib/rollconv.ps
@@ -1,5 +1,5 @@
%!
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -10,8 +10,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Utility program for converting Japanese fonts produced by Macromedia's
diff --git a/Master/tlpkg/tlgs/lib/stcinfo.ps b/Master/tlpkg/tlgs/lib/stcinfo.ps
new file mode 100644
index 00000000000..250eac7a742
--- /dev/null
+++ b/Master/tlpkg/tlgs/lib/stcinfo.ps
@@ -0,0 +1,794 @@
+% Copyright (C) 2001-2023 Artifex Software, Inc.
+% 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.
+%
+% Refer to licensing information at http://www.artifex.com or contact
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
+%
+
+% stcinfo.ps
+% Epson Stylus-Color Printer-Driver
+
+% The purpose of this file is to print & show Parameters of the
+% stcolor-driver. If not run on ghostscript/stcolor, it prints
+% something like a color-chart.
+
+% use either existing STCinfo-dictionary, retrieve new one or create dummy
+
+statusdict begin product end
+dup (Ghostscript) eq 1 index (Artifex Ghostscript) eq or
+exch (AFPL Ghostscript) eq or{
+
+ currentdevice getdeviceprops .dicttomark
+ dup /Name get (stcolor) eq /STCi_onstc exch def
+ /STCinfo where {/STCinfo get exch pop} if
+ /STCinfo exch def
+
+}{
+
+ /STCinfo 10 dict def
+ STCinfo begin /Name (unknown) def end
+ /STCi_onstc false def
+
+}ifelse
+
+% Next Block are procedures to generate the color-triangles.
+% you may wish to separate them, just look ahead for the name
+% given in the next line to achieve that.
+% Begin: colortri_procedures
+
+% Plot the CIE-XY-triangle (or something like that)
+
+% /colortri_mat Conversion matrix RGB -> XYZ
+% /colortri_bg procedure, that takes X/Y-Values and delivers the
+% "background color" as RGB-Values, default is:
+% {pop pop 0.85 dup dup}
+
+% The default matrix was taken from:
+% Color spaces FAQ - David Bourgin
+% Date: 15/6/94 (items 5.3 and 6 updated)
+% Last update: 29/6/94
+
+ /colortri_mat [ % RGB -> CIE XYZitu601-1 (D65)
+ 0.4306 0.3415 0.1784
+ 0.2220 0.7067 0.0713
+ 0.0202 0.1295 0.9394
+ ] def
+
+ /colortri_bg {pop pop 0.85 dup dup} bind def
+
+% +---------------------------------------------------------------------+
+% | Besides from fixing bugs, nothing should be changed below this line |
+% +---------------------------------------------------------------------+
+
+% Arbitrary operation on a pair of vectors, *CHANGES* 1st.
+% invoke: Vaccu Vop op vop
+ /vop {
+ bind 0 1 3 index length 1 sub {
+ 3 index 1 index get 3 index 2 index get 3 index exec 4 index 3 1 roll put
+ } for pop pop
+ } bind def
+
+ /vsub { {sub} vop } bind def % subtract two vectors
+ /vmul { {mul} vop } bind def % multiply two vectors
+
+% Compute sum of vectors elements
+ /vsum {0.0 exch{add}forall} bind def
+
+% Sum up products of elements
+ /veqn { [ 3 -1 roll {} forall ] exch vmul vsum } bind def
+
+% Find index of |maximum| in array
+ /imax {
+ dup 0 get abs 0 exch % array i v[i]
+ 1 1 4 index length 1 sub {
+ 3 index 1 index get abs dup 3 index gt {4 2 roll}if pop pop
+ } for
+ 3 -1 roll pop
+ } bind def
+
+% Procedure to *CHANGE* RGB-Values into XYZ-Values
+ /rgb2xyz {
+ 0 3 6 { colortri_mat exch 3 getinterval 1 index veqn exch } for astore
+ } bind def
+
+% Procedure to *CHANGE* transform rgb->xy
+ /rgb2xy {
+ rgb2xyz
+ dup 0 get 1 index 1 get 2 index vsum % XYZ X Y sum
+ dup 0 ne {
+ exch 1 index div 3 1 roll div % XYZ y x
+ 2 index exch 0 exch put % xYZ y
+ 1 index exch 1 exch put % xyZ
+ }{
+ pop pop pop dup 0 0 put dup 0 1 put
+ } ifelse
+ 0 2 getinterval
+ } bind def
+
+% So here we go with our procedure
+
+/colortri { %Usage: box #pixels
+ save
+ 1 index type /arraytype eq {exch 8}{3 1 roll} ifelse % Default scale
+ /colortri_scale exch def
+ /colortri_box exch def
+
+% Prepare some useful constants for xy -> RGB conversion
+
+ /colsum [ % Array with column-sums
+ 0 1 2{0 exch 3 1 index 6 add{colortri_mat exch get add}for}for
+ ] def
+
+ /Xrow colortri_mat 0 3 getinterval def % two rows from colortri_mat
+ /Yrow colortri_mat 3 3 getinterval def
+
+% Avoid allocating new arrays
+ /xcoeff 3 array def
+ /ycoeff 3 array def
+
+% Procedure to derive RGB-Values form X,Y
+ /xy2rgb{ aload pop
+ dup dup dup ycoeff astore colsum vmul Yrow vsub imax
+ 3 index dup dup xcoeff astore colsum vmul Xrow vsub imax
+ 3 -1 roll 1 index 1 index gt{
+ xcoeff ycoeff /xcoeff exch def /ycoeff exch def pop 3 -1 roll pop
+ }{
+ 3 1 roll pop pop
+ } ifelse
+ 1e-6 lt { % No Pivot ?
+ pop colortri_bg xcoeff astore pop
+ }{ % Have a Pivot
+ dup ycoeff exch get neg
+ 0 1 2 { dup ycoeff exch get 2 index div ycoeff 3 1 roll put} for
+ pop ycoeff 1 index 0 put
+
+ xcoeff 1 index get
+ 0 1 2 {
+ ycoeff 1 index get 2 index mul xcoeff 2 index get add
+ xcoeff 3 1 roll put
+ } for
+ pop xcoeff 1 index 0 put
+ xcoeff imax 1e-6 lt { % no Pivot ?
+ pop pop colortri_bg xcoeff astore pop
+ }{
+ dup 2 index or 3 exch sub
+ xcoeff 1 index get xcoeff 3 index get div neg
+ xcoeff exch 3 index exch put
+ xcoeff 1 index 1 put
+ ycoeff exch get ycoeff 2 index get xcoeff 4 -1 roll get mul add
+ xcoeff 3 1 roll put
+ 0 1 2 {
+ xcoeff exch get dup -0.0015 lt exch 1.0015 gt or {
+ colortri_bg xcoeff astore dup exit
+ } if
+ } for
+ pop pop xcoeff
+ } ifelse
+ } ifelse
+ } bind def
+
+% Compute the displayed range
+ [ 1 1 1 ] rgb2xy
+ dup 0 get /colortri_x0 exch def /colortri_dx colortri_x0 def
+ 1 get /colortri_y0 exch def /colortri_dy colortri_y0 def
+ [[0 0 1][0 1 0][0 1 1][1 0 0][1 0 1][1 1 0]] {
+ rgb2xy
+ dup 0 get
+ dup colortri_x0 lt {/colortri_x0 1 index def}if
+ dup colortri_dx gt {/colortri_dx 1 index def}if
+ pop 1 get
+ dup colortri_y0 lt {/colortri_y0 1 index def}if
+ dup colortri_dy gt {/colortri_dy 1 index def}if
+ pop
+ } forall
+ colortri_dx colortri_x0 sub /colortri_dx exch def
+ colortri_dy colortri_y0 sub /colortri_dy exch def
+%
+
+% determine the scale
+ colortri_box 2 get colortri_box 0 get sub colortri_dx div % fx
+ colortri_box 3 get colortri_box 1 get sub colortri_dy div % fx fy
+ gt { % fy limits
+ colortri_box 3 get colortri_box 1 get sub
+ dup colortri_dx mul colortri_dy div exch
+ }{ % fx limits
+ colortri_box 2 get colortri_box 0 get sub
+ dup colortri_dy mul colortri_dx div
+ } ifelse
+ dtransform abs colortri_scale div cvi /colortri_ny exch def
+ abs colortri_scale div cvi /colortri_nx exch def
+ colortri_nx colortri_scale mul colortri_ny colortri_scale mul
+ idtransform abs exch abs exch
+ colortri_box 0 get colortri_box 2 get 1 index sub 3 index sub 2 div add
+ colortri_box 1 get colortri_box 3 get 1 index sub 3 index sub 2 div add
+ transform .5 add cvi exch .5 add cvi exch itransform
+ translate scale
+
+% String & indices
+ /colortri_tmp colortri_nx 3 mul string def
+ /colortri_dx colortri_dx colortri_nx 1 sub div def
+ /colortri_dy colortri_dy colortri_ny 1 sub div def
+ /colortri_xy [ colortri_x0 colortri_y0 ] def
+ /colortri_ie colortri_tmp length 3 sub def
+
+ colortri_nx colortri_ny 8 [ colortri_nx 0 0 colortri_ny 0 0 ]
+ {
+ colortri_xy 0 colortri_x0 put
+ 0 3 colortri_ie {
+ colortri_tmp exch % buf ir
+ colortri_xy xy2rgb % buf ir rgb buf ib
+ 2 index 2 index 2 add 2 index 2 get 255 mul cvi put
+ 2 index 2 index 1 add 2 index 1 get 255 mul cvi put
+ 0 get 255 mul cvi put
+ colortri_xy dup 0 exch 0 get colortri_dx add put
+ }for
+ colortri_xy dup 1 exch 1 get colortri_dy add put
+ colortri_tmp
+ } bind
+ false 3 colorimage
+ restore
+} bind def
+
+% [ newpath clippath pathbbox ] colortri showpage % standalone usage
+
+% End: colortri_procedures
+
+% The next section is a group of procedures, that I for myself
+% do no more fully understand, but they do the Job.
+
+% Begin: stcinfo_procedures_1
+
+% fetch a parameter from the dictionary
+/STCiget { STCinfo exch get } bind def
+
+% action upon ProcessColorModel
+/STCimode {
+ /ProcessColorModel STCiget dup
+ /DeviceCMYK eq{pop 2}{/DeviceRGB eq{1}{0}ifelse}ifelse get exec
+} bind def
+
+% print given number of blanks
+/STCipspace {
+ dup 0 gt{ 1 exch 1 exch { pop ( ) print}for }{ pop } ifelse
+} bind def
+
+% print right or left-justified text
+/STCiprint {
+ dup 0 gt { dup 2 index length sub STCipspace } if
+ 1 index print
+ dup 0 lt { neg dup 2 index length sub STCipspace } if
+ pop pop
+} bind def
+
+% floating-point to fixed-length-string conversion
+
+/STCicvs { % number -> string
+
+% Prepare the result
+ 8 string dup 0 ( ) putinterval
+ exch
+
+% Make it unsigned
+ dup 0 lt {neg(-)}{( )}ifelse 0 get exch
+
+ dup 1000 lt 1 index 0 eq 2 index 0.001 ge or and { % floating point
+ (e+) 0
+ }{ % engineering
+ 0 {
+ 1 index 1000.0 ge
+ {3 add exch 1000 div exch}
+ {1 index 1 lt {3 sub exch 1000 mul exch}{exit}ifelse}
+ ifelse
+ }loop
+ dup 0 lt {neg(e-)}{(e+)}ifelse exch
+ }ifelse
+
+% string sign num esig e
+
+% always up to three Integer Digits plus sign
+ 2 index cvi 3 { % string sign num esig e int ind
+ 1 index 10 div cvi dup 10 mul 3 index exch sub cvi
+ (0123456789) exch get 8 index exch 3 index exch put
+ 3 -2 roll 1 sub exch pop dup 0 eq 2 index 0 eq or {exit} if
+ } loop exch pop % string sign num esig e ind
+ 5 index exch 6 -1 roll put % string num esig e
+
+% print either fraction or exponent
+ dup 0 eq { pop pop dup cvi sub % String fraction
+
+ dup 0.0 ne { % Fraction present
+ 0.0005 add 1 index 4 (.) putinterval
+ 5 1 7 { % string frac ind
+ exch 10 mul dup cvi exch 1 index sub % string ind ic nfrac
+ exch (0123456789) exch get 3 -1 roll % string nfrac chr ind
+ exch 3 index 3 1 roll put
+ } for
+ } if
+ pop
+
+ }{ 3 -1 roll pop % string esig e
+
+ exch 2 index exch 4 exch putinterval
+ 7 -1 6 { % string n i
+ 1 index 10 div cvi dup 10 mul 3 index exch sub cvi % string n i n/10
+ (0123456789) exch get 4 index exch 3 index exch put
+ exch pop exch pop
+ } for
+ pop
+ } ifelse
+
+} bind def
+
+% compute colorvalue-steps from transfer & coding
+/STCisteps { % xfer, coding => X-values, Y-Values
+% 2^nbits
+ 2 /BitsPerComponent STCiget dup 11 gt { pop 11 } if exp cvi
+
+% X & Y - Arrays (stack: xv:4 yv:3 xfer:2 coding:1 2^ni:0)
+ dup 1 add array 1 index array 5 2 roll
+
+% compute GS-Color-Value according to the coding-array
+
+ 1 index null eq { % no coding present
+
+ 0 1 2 index 1 sub {
+ dup 6 index exch dup 4 index div put
+ 4 index exch dup 3 index 1 sub div put
+ } for
+
+ }{ % coding-array given
+
+ 1.0 1 index 1 sub div % y step
+ 0 % current index
+ 0 1 4 index 1 sub { % over indices
+ dup 3 index mul
+ {
+ dup 3 index 1 add dup 8 index length ge {pop pop exit} if % i y
+ 7 index exch get le {exit} if
+ 2 index 1 add 3 1 roll 4 -1 roll pop
+ } loop
+ 5 index 3 index get sub
+ 5 index 3 index 1 add get 6 index 4 index get sub div
+ 2 index add 5 index length 1 sub div
+ 2 copy exch dup 0 eq {
+ 10 index exch 0.0 put pop
+ }{
+ dup 10 index exch 1 sub get 3 -1 roll add 2 div
+ 10 index 3 1 roll put
+ }ifelse
+ 7 index 3 1 roll put
+ } for % over indices
+ pop pop
+ } ifelse
+ 4 index 1 index 1.0 put
+
+% Replace the raw y-values by those computed from the transfer-array
+
+ 0 1 2 index 1 sub { % over indices, 2nd
+ dup 5 index exch get
+ dup 5 index length 1 sub mul cvi % -> iy
+ 5 index 1 index get
+ 1 index 1 add 7 index length lt {
+ dup 7 index 3 index 1 add get exch sub
+ 3 index 3 index 9 index length 1 sub div sub mul
+ 7 index length 1 sub mul add
+ } if
+ exch pop exch pop 5 index 3 1 roll put
+ } for % over indices, 2nd
+
+ pop pop pop
+} bind def
+
+/STCibar { % Window X-Values proc => Window
+ 0 1 3 index length 2 sub {
+ dup 3 index exch get exch
+ 1 add 3 index exch get
+ dup 2 index add 2 div 3 index exec % Color to average
+ 4 index 2 get 5 index 0 get sub exch 1 index mul 5 index 0 get add 3 1 roll
+ mul 4 index 0 get add 4 index 3 get 5 index 1 get
+ newpath
+ 2 index 1 index moveto
+ 3 index 1 index lineto
+ 3 index 2 index lineto
+ 2 index 2 index lineto
+ closepath fill
+ pop pop pop pop
+ } for
+ pop pop
+ 0 setgray
+ newpath
+ dup 0 get 1 index 1 get moveto
+ dup 2 get 1 index 1 get lineto
+ dup 2 get 1 index 3 get lineto
+ dup 0 get 1 index 3 get lineto
+ closepath stroke
+ pop
+} bind def
+
+% End: stcinfo_procedures_1
+
+% Begin: stcinfo_preparation
+
+% Compute used area from clippath
+
+/STCi_clip [
+ newpath clippath pathbbox
+ 2 sub 4 1 roll 2 sub 4 1 roll 2 add 4 1 roll 2 add 4 1 roll
+] def
+
+%
+% Perpare the texual messages, assume no stcolor if this fails
+%
+{
+ /STCi_stopped % A Special Mark
+
+% Textual Parameters (an array of pairs of strings)
+ /STCi_l1 0 def
+ /STCi_l2 0 def
+ /STCi_text [
+% Driver-Name & Version
+ (Parameters of)
+ /Name STCiget length /Version STCiget length add 1 add string
+ dup 0 /Name STCiget putinterval dup /Name STCiget length (-)putinterval
+ dup /Name STCiget length 1 add /Version STCiget putinterval
+% Dithering-Algorithm
+ (Dithering)
+ /Dithering STCiget
+ [{( \(Monochrome\))}{( \(RGB\))}{( \(CMYK\))}] STCimode
+ dup length 2 index length add string exch 1 index exch
+ 3 index length exch putinterval dup 3 1 roll exch 0 exch putinterval
+% Flags for the algorithm
+ (Flag4-0) 5 string
+ dup 0 /Flag4 STCiget {(T)}{(f)} ifelse putinterval
+ dup 1 /Flag3 STCiget {(T)}{(f)} ifelse putinterval
+ dup 2 /Flag2 STCiget {(T)}{(f)} ifelse putinterval
+ dup 3 /Flag1 STCiget {(T)}{(f)} ifelse putinterval
+ dup 4 /Flag0 STCiget {(T)}{(f)} ifelse putinterval
+
+% Bits Per Pixel & Bits Per Component
+ (BitsPerPixel) 10 string % (nn -> nxnn)
+ /BitsPerPixel STCiget 1 index cvs length % string used
+ dup 2 index exch ( -> ) putinterval 4 add dup 2 add exch 2 index exch
+ [{(1x)}{(3x)}{(4x)}] STCimode putinterval % String used
+ /BitsPerComponent STCiget 2 index 2 index 2 getinterval cvs length add
+ 0 exch getinterval
+
+ () ()
+% ColorAdjustMatrix
+ (ColorAdjustMatrix)
+ /ColorAdjustMatrix STCiget dup null eq {
+ pop (default)
+ }{
+ { STCicvs } forall
+ [{ % Monochrome
+ 26 string
+ dup 0 6 -1 roll putinterval dup 8 ( ) putinterval
+ dup 9 5 -1 roll putinterval dup 17 ( ) putinterval
+ dup 18 4 -1 roll putinterval
+ }{ % RGB
+ 26 string
+ dup 0 12 -1 roll putinterval dup 8 ( ) putinterval
+ dup 9 11 -1 roll putinterval dup 17 ( ) putinterval
+ dup 18 10 -1 roll putinterval
+
+ () 26 string
+ dup 0 11 -1 roll putinterval dup 8 ( ) putinterval
+ dup 9 10 -1 roll putinterval dup 17 ( ) putinterval
+ dup 18 9 -1 roll putinterval
+
+ () 26 string
+ dup 0 10 -1 roll putinterval dup 8 ( ) putinterval
+ dup 9 9 -1 roll putinterval dup 17 ( ) putinterval
+ dup 18 8 -1 roll putinterval
+ }{
+ 35 string
+ dup 0 19 -1 roll putinterval dup 8 ( ) putinterval
+ dup 9 18 -1 roll putinterval dup 17 ( ) putinterval
+ dup 18 17 -1 roll putinterval dup 26 ( ) putinterval
+ dup 27 16 -1 roll putinterval
+
+ () 35 string
+ dup 0 17 -1 roll putinterval dup 8 ( ) putinterval
+ dup 9 16 -1 roll putinterval dup 17 ( ) putinterval
+ dup 18 15 -1 roll putinterval dup 26 ( ) putinterval
+ dup 27 14 -1 roll putinterval
+
+ () 35 string
+ dup 0 15 -1 roll putinterval dup 8 ( ) putinterval
+ dup 9 14 -1 roll putinterval dup 17 ( ) putinterval
+ dup 18 13 -1 roll putinterval dup 26 ( ) putinterval
+ dup 27 12 -1 roll putinterval
+
+ () 35 string
+ dup 0 13 -1 roll putinterval dup 8 ( ) putinterval
+ dup 9 12 -1 roll putinterval dup 17 ( ) putinterval
+ dup 18 11 -1 roll putinterval dup 26 ( ) putinterval
+ dup 27 10 -1 roll putinterval
+
+ }
+ ] STCimode
+ } ifelse
+ () ()
+
+% Printer Model
+ (Printer-Model) /Model STCiget
+
+% Resolution
+ (Resolution) 15 string % (nnnnnxnnnnn DpI)
+ /HWResolution STCiget 0 get cvi 1 index cvs length
+ dup 2 index exch (x) putinterval 1 add dup 2 index exch 5 getinterval
+ /HWResolution STCiget 1 get cvi exch cvs length add dup 2 index
+ exch ( DpI) putinterval 4 add 0 exch getinterval
+
+% HWsize holds entire Page in Pixels,
+% .HWMargins is [left,bottom,right,top] in Points
+ (Printed Area) 18 string % (nnnnnxnnnnn Pixel)
+ /HWSize STCiget 0 get /.HWMargins STCiget dup 0 get exch 2 get add
+ /HWResolution STCiget 0 get mul 72.0 div sub cvi 1 index cvs length
+ dup 2 index exch (x) putinterval 1 add dup 2 index exch 5 getinterval
+ /HWSize STCiget 1 get /.HWMargins STCiget dup 1 get exch 3 get add
+ /HWResolution STCiget 1 get mul 72.0 div sub cvi exch cvs length add
+ dup 2 index exch ( Pixel) putinterval 6 add 0 exch getinterval
+
+ () ()
+% WeaveMode
+ (Weave-Mode)
+ /noWeave STCiget {
+ (noWeave)
+ }{
+ /Microweave STCiget {(Microweave)}{(Softweave)}ifelse
+ }ifelse
+% Unidirectional
+ (Unidirectional) /Unidirectional STCiget {(ON)}{(off)} ifelse
+% Output coding
+ (OutputCode) /OutputCode STCiget
+% number of heads
+ (escp_Band) /escp_Band STCiget 3 string cvs
+ (escp_Width) /escp_Width STCiget 5 string cvs
+ (escp_Height) /escp_Height STCiget 5 string cvs
+ (escp_Top) /escp_Top STCiget 5 string cvs
+ (escp_Bottom) /escp_Bottom STCiget 5 string cvs
+ ] def
+
+%
+% compute the Proper X & Y-Arrays
+%
+ [{ % Monochrome
+ /Ktransfer STCiget /Kcoding STCiget STCisteps
+ /STCi_yv [ 3 -1 roll ] def
+ /STCi_xv [ 3 -1 roll ] def
+ /STCi_col [[0 0 0]] def
+ /STCi_set [{1.0 exch sub setgray}] def
+ }{ % RGB
+ /Rtransfer STCiget /Rcoding STCiget STCisteps
+ /Gtransfer STCiget /Gcoding STCiget STCisteps
+ /Btransfer STCiget /Bcoding STCiget STCisteps
+ exch 4 -1 roll 6 -1 roll exch 3 -1 roll
+ /STCi_xv [ 5 2 roll ] def
+ /STCi_yv [ 5 2 roll ] def
+ /STCi_col [[1 0 0] [0 1 0] [0 0 1]] def
+ /STCi_set [
+ {1.0 exch sub 1 exch dup setrgbcolor}
+ {1.0 exch sub dup 1 exch setrgbcolor}
+ {1.0 exch sub dup 1 setrgbcolor}
+ ] def
+ }{ % CMYK
+ /Ctransfer STCiget /Ccoding STCiget STCisteps
+ /Mtransfer STCiget /Mcoding STCiget STCisteps exch 3 1 roll
+ /Ytransfer STCiget /Ycoding STCiget STCisteps exch 4 1 roll
+ /Ktransfer STCiget /Kcoding STCiget STCisteps exch 5 1 roll
+ /STCi_yv [ 6 2 roll ] def
+ /STCi_xv [ 6 2 roll ] def
+ /STCi_col [[0 1 1] [1 0 1] [1.0 0.5 0.0] [0 0 0]] def
+ /STCi_set [
+ { 0 0 0 setcmykcolor }
+ { 0 exch 0 0 setcmykcolor }
+ { 0 exch 0 exch 0 setcmykcolor }
+ { 0 exch 0 exch 0 exch setcmykcolor }
+ ] def
+ }
+ ]STCimode
+
+} stopped
+
+{ {/STCi_stopped eq {exit}if}loop true}
+{ {/STCi_stopped eq {exit}if}loop false} ifelse
+
+% End: stcinfo_preparation
+
+% The Next section does the real job
+
+% Begin: stcinfo_execution
+{
+ (%%[ stcinfo.ps: currentdevice is not supported -> colortri ]%%\n) print
+ STCi_clip colortri % The default action
+
+}{
+%
+% Print the text
+%
+ 0 2 STCi_text length 2 sub { dup 1 add exch
+ STCi_text exch get length dup STCi_l1 gt{/STCi_l1 exch def}{pop}ifelse
+ STCi_text exch get length dup STCi_l2 gt{/STCi_l2 exch def}{pop}ifelse
+ } for
+ /STCi_l2 STCi_l2 neg def
+ 0 2 STCi_text length 2 sub {
+ dup 1 add STCi_text exch get exch STCi_text exch get
+ 1 index length 0 gt {
+ dup STCi_l1 STCiprint length 0 gt {(: )}{( )}ifelse print print
+ }{
+ pop pop
+ } ifelse
+ (\n) print
+ } for
+%
+% Deactivate a present ColorAdjust Matrix, if any
+%
+ /ColorAdjustMatrix STCiget null ne STCi_onstc and {
+ mark
+ /ColorAdjustMatrix null
+ currentdevice putdeviceprops pop
+ } if
+%
+% "Show" the text
+%
+ /Times-Roman findfont 10 scalefont setfont
+ /STCi_l1 0 def
+ 0 2 STCi_text length 2 sub {
+ STCi_text exch get stringwidth pop dup STCi_l1 gt {
+ /STCi_l1 exch def
+ }{
+ pop
+ } ifelse
+ } for
+ STCi_l1 STCi_clip 0 get add /STCi_l1 exch def
+
+ STCi_clip 3 get 12 sub
+ 0 2 STCi_text length 2 sub {
+ STCi_text exch get dup length 0 gt {
+ dup stringwidth pop STCi_l1 exch sub 2 index moveto show
+ }{
+ pop
+ } ifelse
+ 12 sub
+ } for
+ pop
+
+ /Courier findfont 10 scalefont setfont
+ /STCi_l2 0 def
+ 1 2 STCi_text length 1 sub {
+ STCi_text exch get stringwidth pop dup STCi_l2 gt {
+ /STCi_l2 exch def
+ }{
+ pop
+ } ifelse
+ } for
+
+ STCi_clip 3 get 12 sub
+ 1 2 STCi_text length 1 sub {
+ STCi_text exch get dup length 0 gt {
+ STCi_l1 12 add 2 index moveto show
+ }{
+ pop
+ } ifelse
+ 12 sub
+ } for
+ pop
+
+%
+% compute the space for the graph-window
+%
+ STCi_l1 12 add STCi_l2 add 12 add dup STCi_clip 2 get exch sub % Extend
+ [ 3 -1 roll dup 3 index add STCi_clip 3 get dup 5 index sub 3 1 roll ]
+ /STCi_win exch def /STCi_l1 exch def
+
+% The "Axis"
+ newpath
+ STCi_win 0 get STCi_win 1 get 14 add moveto
+ STCi_win 2 get STCi_win 1 get 14 add lineto stroke
+
+ STCi_win 0 get 14 add STCi_win 1 get moveto
+ STCi_win 0 get 14 add STCi_win 3 get lineto stroke
+
+% The Labels
+ /Times-Roman findfont 10 scalefont setfont
+ (Postscript-color) dup stringwidth pop
+ STCi_win 2 get STCi_win 0 get sub 14 sub 1 index sub 2 div exch pop
+ STCi_win 0 get add 14 add STCi_win 1 get 4 add moveto show
+
+ gsave
+ STCi_win 0 get 10 add STCi_win 1 get 14 add translate 90 rotate
+ (Device-color) dup stringwidth pop
+ STCi_win 3 get STCi_win 1 get sub 14 sub 1 index sub 2 div exch pop
+ 0 moveto show
+ grestore
+
+% The Graphs
+ gsave
+ STCi_win 0 get 14 add STCi_win 1 get 14 add
+ STCi_win 2 get 2 index sub STCi_win 3 get 2 index sub
+ 4 2 roll translate
+ STCi_col 0 1 2 index length 1 sub {
+ 1 index 1 index get aload pop setrgbcolor
+ STCi_xv 1 index get STCi_yv 3 -1 roll get
+ newpath
+ 1 index 0 get 5 index mul 1 index 0 get 5 index mul moveto
+ 1 index 1 get 5 index mul 1 index 0 get 5 index mul lineto
+ 1 1 2 index length 1 sub {
+ 2 index 1 index get 6 index mul
+ 2 index 2 index get 6 index mul lineto
+ 2 index 1 index 1 add get 6 index mul
+ 2 index 2 index get 6 index mul lineto
+ pop
+ } for
+ stroke pop pop
+ } for
+ pop pop pop
+ grestore
+
+%
+% Find lowest Y from Text or graph
+%
+ STCi_win 1 get STCi_clip 3 get STCi_text length 2 div 12 mul sub
+ dup 2 index gt { pop } { exch pop } ifelse 12 sub
+
+%
+% compute the upper bar-window
+%
+ /STCi_win [
+ STCi_clip 0 get 4 -1 roll 36 sub STCi_clip 2 get 1 index 36 add
+ ] def
+
+%
+% Draw the required number of graphs
+%
+ [{ % Monochrome
+ STCi_win STCi_xv 0 get {setgray} STCibar
+ }{ % RGB
+ STCi_win STCi_xv 0 get {0 0 setrgbcolor} STCibar
+ STCi_win dup 1 exch 1 get 47 sub put
+ STCi_win dup 3 exch 3 get 47 sub put
+ STCi_win STCi_xv 1 get {0 0 3 1 roll setrgbcolor} STCibar
+ STCi_win dup 1 exch 1 get 47 sub put
+ STCi_win dup 3 exch 3 get 47 sub put
+ STCi_win STCi_xv 2 get {0 0 3 2 roll setrgbcolor} STCibar
+ }{ % CMYK
+ STCi_win STCi_xv 0 get {0 0 0 setcmykcolor} STCibar
+ STCi_win dup 1 exch 1 get 47 sub put
+ STCi_win dup 3 exch 3 get 47 sub put
+ STCi_win STCi_xv 1 get {0 0 0 4 1 roll setcmykcolor} STCibar
+ STCi_win dup 1 exch 1 get 47 sub put
+ STCi_win dup 3 exch 3 get 47 sub put
+ STCi_win STCi_xv 2 get {0 0 0 4 2 roll setcmykcolor} STCibar
+ STCi_win dup 1 exch 1 get 47 sub put
+ STCi_win dup 3 exch 3 get 47 sub put
+ STCi_win STCi_xv 3 get {0 0 0 4 3 roll setcmykcolor} STCibar
+ }
+ ] STCimode
+
+ STCi_win 1 STCi_clip 1 get put
+ STCi_win dup 3 exch 3 get 47 sub put
+
+%
+% Plot either one or two Color-Triangles
+%
+ /ColorAdjustMatrix STCiget null ne STCi_onstc and {
+ STCi_win 0 get STCi_win 2 get add 2 div
+ [STCi_win 0 get STCi_win 1 get 3 index STCi_win 3 get ] colortri
+ mark /ColorAdjustMatrix dup STCiget currentdevice putdeviceprops pop
+ [1 index STCi_win 1 get STCi_win 2 get STCi_win 3 get ] colortri
+ pop
+ }{
+ STCi_win colortri
+ } ifelse
+ newpath clippath stroke
+} ifelse
+showpage
diff --git a/Master/tlpkg/tlgs/lib/stcolor.ps b/Master/tlpkg/tlgs/lib/stcolor.ps
new file mode 100644
index 00000000000..a0d27bc7ef4
--- /dev/null
+++ b/Master/tlpkg/tlgs/lib/stcolor.ps
@@ -0,0 +1,169 @@
+% Copyright (C) 2001-2023 Artifex Software, Inc.
+% 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.
+%
+% Refer to licensing information at http://www.artifex.com or contact
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
+%
+
+% stcolor.ps
+% Epson Stylus-Color Printer-Driver
+
+% The purpose of this file is to configure the stcolor-printer driver
+
+%
+% It is useless and dangerous to interpret the following code with anything
+% else than Ghostscript, so this condition is verified first. If this fails
+% a message is send to the output. If this message bothers you, remove it,
+% but I prefer to know why the device-setup failed.
+
+statusdict begin product end
+dup (Ghostscript) eq 1 index (Artifex Ghostscript) eq or
+exch (AFPL Ghostscript) eq or{
+
+% fetch the current device-parameters this is specific for Ghostscript.
+
+ /STCold currentdevice getdeviceprops .dicttomark def
+
+% Any Ghostscript-Driver has a Name, verify that the selected device is
+% stcolor, otherwise nothing than another message will be produced.
+
+ STCold /Name get (stcolor) eq {
+
+%
+% The main thing this file does, is to establish transfer-functions.
+% Here are two predefined arrays for 360x360Dpi and for 720x720DpI.
+% If resolution is 360x720 or 720x360 the average is used. You may
+% want to define other arrays here.
+%
+
+ /STCdeftransfer [ 0.0 1.0 ] def
+
+ /STCKtransfer360 [
+ 0.0000 0.0034 0.0185 0.0377 0.0574 0.0769 0.0952 0.1147
+ 0.1337 0.1540 0.1759 0.1985 0.2209 0.2457 0.2706 0.2949
+ 0.3209 0.3496 0.3820 0.4145 0.4505 0.4907 0.5344 0.5840
+ 0.6445 0.7093 0.8154 0.9816 0.9983 0.9988 0.9994 1.0000
+ ] def
+
+ /STCKtransfer720 [
+ 0.0000 0.0011 0.0079 0.0151 0.0217 0.0287 0.0354 0.0425
+ 0.0492 0.0562 0.0633 0.0700 0.0766 0.0835 0.0900 0.0975
+ 0.1054 0.1147 0.1243 0.1364 0.1489 0.1641 0.1833 0.2012
+ 0.2217 0.2492 0.2814 0.3139 0.3487 0.3996 0.4527 0.5195
+ ] def
+
+% compute the resolution
+
+ STCold /HWResolution get dup
+ 0 get exch 1 get mul sqrt /STCdpi exch def
+
+% pick the colormodel
+ STCold /ProcessColorModel get /STCcolor exch def
+
+ mark % prepare stack for "putdeviceprops"
+
+% warn for BitsPerPixel=30 with fsrgb
+ STCcolor /DeviceRGB eq STCold /BitsPerPixel get 32 eq and
+ {
+ (%%[ stcolor.ps: inefficient RGB-setup, recommend BitsPerPixel=24 ]%%\n)
+ print
+ } if
+
+% if the Dithering-Method is default (gscmyk), change it to fscmyk
+% this is achieved by pushing a name/value-pair onto the stack
+% if the selected algorithm uses another ProcessColorModel, it is necessary
+% to change the Value of STCcolor according to the new algorithm.
+
+ STCold /Dithering get (gscmyk) eq
+ {
+ /Dithering (hscmyk) % preferred dithering-method
+ } if % might be necessary to change STCcolor too
+
+%
+% select the array according to the resolution
+%
+ STCdpi 359.0 lt
+ { STCdeftransfer }
+ { STCdpi 361.0 lt
+ { STCKtransfer360 }
+ { STCdpi 719.0 gt
+ { STCKtransfer720 }
+ {
+ STCKtransfer360 length STCKtransfer720 length eq
+ {
+ 0 1 STCKtransfer360 length 1 sub
+ {
+ dup dup
+ STCKtransfer360 exch get
+ exch STCKtransfer720 exch get
+ add 2.0 div
+ STCKtransfer360 3 1 roll put
+ } for
+ }if
+ STCKtransfer360
+ } ifelse
+ }ifelse
+ } ifelse
+ /STCtransfer exch def
+
+%
+% Add the arrays. With Version 1.17 and above, it seems to be
+% a good idea, to use the transfer-arrays as coding-arrays too.
+%
+
+%
+% RGB-Model requires inversion of the transfer-arrays
+%
+ STCcolor /DeviceRGB eq
+ {
+ /RGBtransfer STCtransfer length array def
+ 0 1 STCtransfer length 1 sub
+ {
+ dup RGBtransfer length 1 sub exch sub exch
+ STCtransfer exch get 1.0 exch sub
+ RGBtransfer 3 1 roll put
+ } for
+
+ /Rtransfer RGBtransfer
+ /Gtransfer RGBtransfer
+ /Btransfer RGBtransfer
+
+ /Rcoding RGBtransfer
+ /Gcoding RGBtransfer
+ /Bcoding RGBtransfer
+
+ }{
+
+ /Ctransfer STCtransfer
+ /Mtransfer STCtransfer
+ /Ytransfer STCtransfer
+ /Ktransfer STCtransfer
+
+ /Ccoding STCtransfer
+ /Mcoding STCtransfer
+ /Ycoding STCtransfer
+ /Kcoding STCtransfer
+
+ } ifelse
+
+ counttomark 0 ne
+ {currentdevice putdeviceprops pop}{cleartomark}ifelse
+
+% decativate predefined correction
+
+ {} dup dup currenttransfer setcolortransfer
+
+ }{
+ (%%[ stcolor.ps: currentdevice is not stcolor - ignored ]%%\n) print
+ } ifelse
+}{
+ (%%[ stcolor.ps: not interpreted by AFPL Ghostscript - ignored ]%%\n) print
+} ifelse
diff --git a/Master/tlpkg/tlgs/lib/stocht.ps b/Master/tlpkg/tlgs/lib/stocht.ps
index bf0c5905a11..0a12ed6ecf4 100644
--- a/Master/tlpkg/tlgs/lib/stocht.ps
+++ b/Master/tlpkg/tlgs/lib/stocht.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% helper file to simplify use of Stochastic Halftone - uses ht_ccsto.ps
diff --git a/Master/tlpkg/tlgs/lib/traceimg.ps b/Master/tlpkg/tlgs/lib/traceimg.ps
index eb5cba8cfb2..5f915993699 100644
--- a/Master/tlpkg/tlgs/lib/traceimg.ps
+++ b/Master/tlpkg/tlgs/lib/traceimg.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% traceimg.ps
diff --git a/Master/tlpkg/tlgs/lib/traceop.ps b/Master/tlpkg/tlgs/lib/traceop.ps
index 7fa5bcb4df4..71ade6bd045 100644
--- a/Master/tlpkg/tlgs/lib/traceop.ps
+++ b/Master/tlpkg/tlgs/lib/traceop.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Trace individual operators or procedures.
diff --git a/Master/tlpkg/tlgs/lib/uninfo.ps b/Master/tlpkg/tlgs/lib/uninfo.ps
index a2cff7ed7ef..942fecb7371 100644
--- a/Master/tlpkg/tlgs/lib/uninfo.ps
+++ b/Master/tlpkg/tlgs/lib/uninfo.ps
@@ -1,5 +1,5 @@
%!
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -10,8 +10,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% uninfo.ps: Utilities for "printing" PostScript items, especially dictionaries
diff --git a/Master/tlpkg/tlgs/lib/viewcmyk.ps b/Master/tlpkg/tlgs/lib/viewcmyk.ps
index 33c5bdceb15..97f4c38b3e3 100644
--- a/Master/tlpkg/tlgs/lib/viewcmyk.ps
+++ b/Master/tlpkg/tlgs/lib/viewcmyk.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% viewcmyk.ps
diff --git a/Master/tlpkg/tlgs/lib/viewgif.ps b/Master/tlpkg/tlgs/lib/viewgif.ps
index 0426e2f46c0..3e3afb608d8 100644
--- a/Master/tlpkg/tlgs/lib/viewgif.ps
+++ b/Master/tlpkg/tlgs/lib/viewgif.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% viewgif.ps
diff --git a/Master/tlpkg/tlgs/lib/viewjpeg.ps b/Master/tlpkg/tlgs/lib/viewjpeg.ps
index 54453fe4d83..9738bd784f5 100644
--- a/Master/tlpkg/tlgs/lib/viewjpeg.ps
+++ b/Master/tlpkg/tlgs/lib/viewjpeg.ps
@@ -10,8 +10,8 @@
% 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., 1305 Grant Avenue - Suite 200,
-% Novato, CA 94945, U.S.A., +1(415)492-9861.
+% contact Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA.
% View JPEG files with Ghostscript
%
diff --git a/Master/tlpkg/tlgs/lib/viewmiff.ps b/Master/tlpkg/tlgs/lib/viewmiff.ps
index 90db80b0922..72863655eec 100644
--- a/Master/tlpkg/tlgs/lib/viewmiff.ps
+++ b/Master/tlpkg/tlgs/lib/viewmiff.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% viewmiff.ps
diff --git a/Master/tlpkg/tlgs/lib/viewpbm.ps b/Master/tlpkg/tlgs/lib/viewpbm.ps
index 143a056a68a..7af5a18ec26 100644
--- a/Master/tlpkg/tlgs/lib/viewpbm.ps
+++ b/Master/tlpkg/tlgs/lib/viewpbm.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% viewpbm.ps
diff --git a/Master/tlpkg/tlgs/lib/viewpcx.ps b/Master/tlpkg/tlgs/lib/viewpcx.ps
index 0b549ad90fe..7b34d536285 100644
--- a/Master/tlpkg/tlgs/lib/viewpcx.ps
+++ b/Master/tlpkg/tlgs/lib/viewpcx.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% viewpcx.ps
diff --git a/Master/tlpkg/tlgs/lib/viewps2a.ps b/Master/tlpkg/tlgs/lib/viewps2a.ps
index dafb6d5c3b0..19901d09dce 100644
--- a/Master/tlpkg/tlgs/lib/viewps2a.ps
+++ b/Master/tlpkg/tlgs/lib/viewps2a.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% Display a file produced by ps2ascii with no switch or with -dCOMPLEX.
diff --git a/Master/tlpkg/tlgs/lib/viewpwg.ps b/Master/tlpkg/tlgs/lib/viewpwg.ps
index 4ee0cdb7aed..0f0bae15539 100644
--- a/Master/tlpkg/tlgs/lib/viewpwg.ps
+++ b/Master/tlpkg/tlgs/lib/viewpwg.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2017-2021 Artifex Software, Inc.
+% Copyright (C) 2017-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% viewpwg.ps
diff --git a/Master/tlpkg/tlgs/lib/viewraw.ps b/Master/tlpkg/tlgs/lib/viewraw.ps
index 85438ffa103..3c477b7a981 100644
--- a/Master/tlpkg/tlgs/lib/viewraw.ps
+++ b/Master/tlpkg/tlgs/lib/viewraw.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% viewcmyk.ps
diff --git a/Master/tlpkg/tlgs/lib/viewrgb.ps b/Master/tlpkg/tlgs/lib/viewrgb.ps
index c2c34fec635..0ac1f7db2ce 100644
--- a/Master/tlpkg/tlgs/lib/viewrgb.ps
+++ b/Master/tlpkg/tlgs/lib/viewrgb.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
diff --git a/Master/tlpkg/tlgs/lib/winmaps.ps b/Master/tlpkg/tlgs/lib/winmaps.ps
index 9a4499ac3ee..7dae36f7c9f 100644
--- a/Master/tlpkg/tlgs/lib/winmaps.ps
+++ b/Master/tlpkg/tlgs/lib/winmaps.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -9,8 +9,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% winmaps.ps - make maps between PostScript encodings and Windows
diff --git a/Master/tlpkg/tlgs/lib/zeroline.ps b/Master/tlpkg/tlgs/lib/zeroline.ps
index 37f9fda416a..effc3934154 100644
--- a/Master/tlpkg/tlgs/lib/zeroline.ps
+++ b/Master/tlpkg/tlgs/lib/zeroline.ps
@@ -1,5 +1,5 @@
%!
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -10,8 +10,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% zeroline.ps
diff --git a/Master/tlpkg/tlgs/lib/zugferd.ps b/Master/tlpkg/tlgs/lib/zugferd.ps
index d20c39edc0c..03706f9e0f7 100644
--- a/Master/tlpkg/tlgs/lib/zugferd.ps
+++ b/Master/tlpkg/tlgs/lib/zugferd.ps
@@ -1,6 +1,6 @@
%!PS
-% Copyright (C) 2001-2021 Artifex Software, Inc.
+% Copyright (C) 2001-2023 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -11,8 +11,8 @@
% of the license contained in the file LICENSE in this distribution.
%
% Refer to licensing information at http://www.artifex.com or contact
-% Artifex Software, Inc., 1305 Grant Avenue - Suite 200, Novato,
-% CA 94945, U.S.A., +1(415)492-9861, for further information.
+% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
+% CA 94129, USA, for further information.
%
% ZUGFeRD.ps
% This program will create an (unsigned) ZUGFeRD compliant PDF file.