summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlgs/lib/pdf_info.ps
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlgs/lib/pdf_info.ps')
-rw-r--r--Master/tlpkg/tlgs/lib/pdf_info.ps155
1 files changed, 26 insertions, 129 deletions
diff --git a/Master/tlpkg/tlgs/lib/pdf_info.ps b/Master/tlpkg/tlgs/lib/pdf_info.ps
index 35951e9a736..0b4654ab073 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-2020 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -69,81 +69,6 @@ cleartomark % discard the dict from --where--
% ---- No more executable code on the top level after this line -----
% ---- except 2 lines at the very end -----
-% Write a character to the standard output.
-/putchar [ % int -> -
- (%stdout) (w) file
- /exch cvx /write cvx
-] cvx bind def
-
-% Write U+xxxx to the standard output as UTF-8.
-/put-ucode { % int -> -
- dup 16#80 ge {
- dup 16#800 ge {
- dup 16#10000 ge {
- dup -18 bitshift 16#f0 or putchar
- dup -12 bitshift 16#3f and 16#80 or putchar
- } {
- dup -12 bitshift 16#e0 or putchar
- } ifelse
- dup -6 bitshift 16#3f and 16#80 or putchar
- } {
- dup -6 bitshift 16#C0 or putchar
- } ifelse
- 16#3f and 16#80 or
- } if
- putchar
-} bind def
-
-% PDFDocEncoding to U+xxxx decoding table.
-/doc-to-ucode [
- 0 1 23 {} for
- 16#2d8 16#2c7 16#2c6 16#2d9 16#2dd 16#2db 16#2da 16#2dc
- 32 1 127 {} for
- 16#2022 16#2020 16#2021 16#2026 16#2014 16#2013 16#192
- 16#2044 16#2039 16#203a 16#2212 16#2030 16#201e 16#201c
- 16#201d 16#2018 16#2019 16#201a 16#2122 16#fb01 16#fb02
- 16#141 16#152 16#160 16#178 16#17d 16#131 16#142 16#153
- 16#161 16#17e 0 16#20ac
- 161 1 255 {} for
-] readonly def
-
-% Convert a doc string from PDFDocEncoding or UTF-16BE to UTF-8
-% and write it to standard output.
-/write-doc-string { % (string) -> -
- 1024 string cvs <feff> anchorsearch {
- pop
- 0 exch % hi16 (str)
- 0 2 2 index length 2 sub {
- 2 copy 2 copy % hi16 (str) i (str) i (str) i
- get 256 mul 3 1 roll % hi16 (str) i hi*256 (str) i
- 1 add get add % hi16 (str) i 256*hi+lo
- dup 16#fc00 and dup % hi16 (str) i 256*hi+lo tag tag
- 16#d800 eq { % High surrogate
- pop
- 16#3ff and
- 10 bitshift
- 16#10000 add % hi16 (str) i hi16'
- 4 1 roll % hi16' hi16 (str) i
- pop exch pop % hi16' (str)
- } {
- 16#dc00 eq { % Low surrogate
- 16#3ff and % hi16 (str) i (256*hi+lo)&0x3ff
- 4 -1 roll add % (str) i (256*hi+lo)&0x3ff+hi16
- put-ucode % (str) i
- pop 0 exch % 0 (str)
- } { % BMP plane
- put-ucode % hi16 (str) i
- pop % hi16 (str)
- } ifelse
- } ifelse
- } for
- pop pop % -
- } {
- { //doc-to-ucode exch get put-ucode
- } forall
- } ifelse
-} bind def
-
%% When checking Resources for Font objects, we must ensure that we don't end
%% up following a circular reference. Circular references in Resources should
%% not, of course, be present but we've seen a number of cases. If we do detect
@@ -167,6 +92,19 @@ cleartomark % discard the dict from --where--
} ifelse
} bind def
+/printXML { % <string> printXML -
+ % print non-blank lines without trailing spaces
+ dup dup length 1 sub -1 0 {
+ 1 index 1 index get 32 eq {
+ 0 exch getinterval exch
+ } {
+ exch = exit % non-blank on this line
+ }
+ ifelse
+ } for
+ pop pop % clean up
+} bind def
+
/dump-pdf-info { % (fname) -> -
() = ( ) print print ( has ) print
PDFPageCount dup =print 10 mod 1 eq { ( page.\n) } { ( pages\n) } ifelse = flush
@@ -182,24 +120,24 @@ cleartomark % discard the dict from --where--
pop
Trailer /Root oget /Metadata knownoget {
//false resolvestream
- { dup 256 string readstring exch print not { exit } if } loop
+ { dup 256 string readline exch printXML not { exit } if } loop
pop % done with the stream
- (\n_____________________________________________________________) =
+ (_____________________________________________________________) =
flush
} if
} if
% Print out the "Info" dictionary if present
Trailer /Info knownoget {
- dup /Title knownoget { (Title: ) print write-doc-string () = flush } if
- dup /Author knownoget { (Author: ) print write-doc-string () = flush } if
- dup /Subject knownoget { (Subject: ) print write-doc-string () = flush } if
- dup /Keywords knownoget { (Keywords: ) print write-doc-string () = flush } if
- dup /Creator knownoget { (Creator: ) print write-doc-string () = flush } if
- dup /Producer knownoget { (Producer: ) print write-doc-string () = flush } if
- dup /CreationDate knownoget { (CreationDate: ) print write-doc-string () = flush } if
- dup /ModDate knownoget { (ModDate: ) print write-doc-string () = flush } if
- dup /Trapped knownoget { (Trapped: ) print write-doc-string () = flush } if
+ dup /Title knownoget { (Title: ) print = flush } if
+ dup /Author knownoget { (Author: ) print = flush } if
+ dup /Subject knownoget { (Subject: ) print = flush } if
+ dup /Keywords knownoget { (Keywords: ) print = flush } if
+ dup /Creator knownoget { (Creator: ) print = flush } if
+ dup /Producer knownoget { (Producer: ) print = flush } if
+ dup /CreationDate knownoget { (CreationDate: ) print = flush } if
+ dup /ModDate knownoget { (ModDate: ) print = flush } if
+ dup /Trapped knownoget { (Trapped: ) print = flush } if
pop
} if
@@ -236,27 +174,9 @@ cleartomark % discard the dict from --where--
pop
( Page contains Annotations) print
} if
- dup pageusestransparency {
+ pageusestransparency {
( Page uses transparency features) print
} if
- dup pagespotcolors
- dup length 0 gt {
- (\n Page Spot colors: ) =
- << /Black 0 /Cyan 0 /Magenta 0 /Yellow 0 >> exch
- {
- pop % discard the value
- 1 index 1 index known not { % check if colorant is a standard one
- ( ) print
- (') print =print (') =
- } {
- pop % ignore this standard colorant
- } ifelse
- } forall
- pop % discard dict of standard colorants
- } {
- pop
- } ifelse
- pop % done with pagedict
() = flush
}
{
@@ -273,7 +193,6 @@ cleartomark % discard the dict from --where--
] def
/res-type-dict 10 dict begin
-
/Font {
{
exch pop oforce_no_circular
@@ -399,28 +318,6 @@ currentdict /res-type-dict undef
currentdict /ProcessedResources undef
} bind def
-% If running with -dSAFER, .sort may not be present. Define a (slower) PS alternative
-systemdict /.sort known not {
-% <array> <lt-proc> .sort <array>
- /.sort
- { 1 index length 1 sub -1 1
- { 2 index exch 2 copy get 3 copy % arr proc arr i arr[i] arr i arr[i]
- 0 1 3 index 1 sub
- { 3 index 1 index get % arr proc arr i arr[i] arr imax amax j arr[j]
- 2 index 1 index 10 index exec
- { % ... amax < arr[j]
- 4 2 roll
- }
- if pop pop
- }
- for % arr proc arr i arr[i] arr imax amax
- 4 -1 roll exch 4 1 roll put put
- }
- for
- pop
- } bind def
-} if
-
/dump-fonts-used { % <dict for fonts> dump-fonts-used -
% If DumpFontsUsed is not true, then remove the 'standard' fonts from the list
systemdict /DumpFontsUsed known not {