diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2024-03-08 01:38:52 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2024-03-08 01:38:52 +0000 |
commit | 9fbffcd0921a99f641de4cf11d25fb17749cca09 (patch) | |
tree | 24856d1fe2cbae81dbc7746153104863af68cc24 /Master/tlpkg/tlgs/lib/pdf_info.ps | |
parent | ec724927af1a4cd789b6b8e4ce76ee10498ee84f (diff) |
gs 10.03.0
git-svn-id: svn://tug.org/texlive/trunk@70494 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlgs/lib/pdf_info.ps')
-rw-r--r-- | Master/tlpkg/tlgs/lib/pdf_info.ps | 627 |
1 files changed, 130 insertions, 497 deletions
diff --git a/Master/tlpkg/tlgs/lib/pdf_info.ps b/Master/tlpkg/tlgs/lib/pdf_info.ps index 2e2aa21ab20..18725ac4eae 100644 --- a/Master/tlpkg/tlgs/lib/pdf_info.ps +++ b/Master/tlpkg/tlgs/lib/pdf_info.ps @@ -144,261 +144,6 @@ cleartomark % discard the dict from --where-- } 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 -%% a circular reference, then stop checking that chain. - -/oforce_no_circular { - dup type /packedarraytype eq { - dup 0 get - currentdict /ProcessedResources known { - dup ProcessedResources exch known { - pop pop //null - } { - dup ProcessedResources 3 1 roll put - oforce - } ifelse - } { - oforce - } ifelse - } { - oforce - } ifelse -} bind def - -/dump-pdf-info { % (fname) -> - - () = ( ) print print ( has ) print - PDFPageCount dup =print 10 mod 1 eq { ( page.\n) } { ( pages\n) } ifelse = flush - - Trailer /Root oget /AcroForm knownoget { - /XFA knownoget { - (File uses XFA forms.\n\n) print - pop - } if - } if - - /DumpXML where { - pop - Trailer /Root oget /Metadata knownoget { - //false resolvestream - { dup 256 string readstring exch print 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 - pop - } if - -} bind def - -% <page index> <page dict> dump-media-sizes - -/dump-media-sizes { - DumpMediaSizes { - () = - % Print out the Page Size info for each page. - (Page ) print =print - dup /UserUnit pget { - ( UserUnit: ) print =print - } if - dup /MediaBox pget { - ( MediaBox: ) print oforce_array ==only - } if - dup /CropBox pget { - ( CropBox: ) print oforce_array ==only - } if - dup /BleedBox pget { - ( BleedBox: ) print oforce_array ==only - } if - dup /TrimBox pget { - ( TrimBox: ) print oforce_array ==only - } if - dup /ArtBox pget { - ( ArtBox: ) print oforce_array ==only - } if - dup /Rotate pget { - ( Rotate = ) print =print - } if - dup /Annots pget { - pop - ( Page contains Annotations) print - } if - dup 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 - } - { - pop pop - } ifelse -} bind def - -% List of standard font names for use when we are showing the FontsNeeded -/StdFontNames [ - /Times-Roman /Helvetica /Courier /Symbol - /Times-Bold /Helvetica-Bold /Courier-Bold /ZapfDingbats - /Times-Italic /Helvetica-Oblique /Courier-Oblique - /Times-BoldItalic /Helvetica-BoldOblique /Courier-BoldOblique -] def - -/res-type-dict 10 dict begin - - /Font { - { - exch pop oforce_no_circular - dup //null ne { - dup /DescendantFonts knownoget { - exch pop 0 get oforce_no_circular - %% Check to see if a potentail circular reference was detected. This could be a - %% false positive caused by other fonts using the same DescendantFont(s), but if - %% so then we've already cehcked them anyway. - dup //null eq { pop << >>} if - } if - dup /FontDescriptor knownoget { - dup /FontFile known 1 index /FontFile2 known or exch /FontFile3 known or - /ShowEmbeddedFonts where { pop pop //false } if { - pop % skip embedded fonts - } { - /BaseFont knownoget { % not embedded - 2 index exch //null put - } if - } ifelse - } { - /BaseFont knownoget { % no FontDescriptor, not embedded - 2 index exch //null put - } if - } ifelse - } { - pop - } ifelse - } forall % traverse the dictionary - } bind def - - /XObject { - { - exch pop oforce_no_circular - dup //null ne { - dup /Subtype knownoget { - /Form eq { - /Resources knownoget { - get-fonts-from-res - } if - } { - pop - } ifelse - } { - pop - } ifelse - } { - pop - } ifelse - } forall - } bind def - - /Pattern { - { - exch pop oforce_no_circular - dup //null ne { - /Resources knownoget { - get-fonts-from-res - } if - } { - pop - } ifelse - } forall - } bind def -currentdict end readonly def - -% <dict for fonts> <<res-dict>> get-fonts-from-res - -/get-fonts-from-res { - oforce_no_circular - dup //null ne { - { - oforce_no_circular - dup //null ne { - //res-type-dict 3 -1 roll - .knownget { - exec - } { - pop - } ifelse - } { - pop pop - } ifelse - } forall - } { - pop - } ifelse -} bind def - -currentdict /res-type-dict undef - -/getPDFfonts { % <dict for fonts> <page dict> getPDFfonts - - /ProcessedResources 10 dict def - dup /Resources pget { get-fonts-from-res } if - /Annots knownoget { - { oforce_no_circular - dup //null ne { - /AP knownoget { - { exch pop oforce_no_circular - dup //null ne { - dup /Resources knownoget { - get-fonts-from-res - } if - { exch pop oforce_no_circular - dup type /dicttype eq { - /Resources knownoget { - get-fonts-from-res - } if - } { - pop - } ifelse - } forall - } { - pop - } ifelse - } forall - } if - } { - pop - } ifelse - } forall - } if - pop - 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> @@ -421,270 +166,158 @@ systemdict /.sort known not { } 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 { - StdFontNames { - 1 index 1 index known { 1 index 1 index undef } if - pop - } forall - } if - - % Now dump the FontsUsed dict into an array so we can sort it. - [ 1 index { pop } forall ] - { 100 string cvs exch 100 string cvs exch lt } .sort - - systemdict /DumpFontsUsed known - { - (\nFont or CIDFont resources used (plain name and ASCIIHEX string representation):) = - { 128 string cvs dup print ( ) print (<) print 128 string cvs {16 8 string cvrs print} forall (>) print (\n) print} forall - } { - DumpFontsNeeded { - dup length 0 gt { - (\nFonts Needed that are not embedded \(system fonts required\):) = - { ( ) print 128 string cvs dup print ( ) print (<) print {16 8 string cvrs print} forall (>) print (\n) print} forall - } { - pop - (\nNo system fonts are needed.) = - } ifelse - } { - pop - } ifelse - } ifelse - pop -} bind 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 oget - dup /Collection oknown { - /Names knownoget { - /EmbeddedFiles knownoget { - pdf_collection_names - } if - } if - } { - pop - } ifelse -} bind def - -% Output all the info about the file -/dump { % (title) -> - - /PDFPageCount pdfpagecount def - dump-pdf-info - % dict will be populated with fonts through a call to 'getPDFfonts' - % per page, then the contents dumped out in 'dump-fonts-used' - 1000 dict - - 1 1 PDFPageCount - { - dup pdfgetpage dup 3 -1 roll - dump-media-sizes - 1 index exch getPDFfonts - } for - - dump-fonts-used - -} bind def - -% Choose between collection vs plain file. -% Enumerate collections and apply the dump procedure. -/enum-pdfs { % - -> - - File (r) file runpdfbegin - pdf_collection_files - dup mark eq { - pop - File dump - runpdfend - } { - runpdfend - ] 0 1 2 index length 1 sub { - 2 copy get exch % [file ... ] file i - 1 add (0123456789) cvs % [file ... ] file (i+1) - File exch ( part ) exch concatstrings concatstrings - exch % [file ... ] (fname part i+1) file - dup type /filetype eq { - runpdfbegin - dump - runpdfend - closefile - } { - 1024 string cvs % .namestring is deprecated -% .namestring - dup (r) file - runpdfbegin - exch dump - runpdfend - deletefile - } ifelse - } for - pop +/knownoget +{ + 2 copy known { + get + true + }{ + pop pop false } ifelse -} bind def +}bind def -/NEWPDF where {/NEWPDF get}{false}ifelse +/PDFContext << >> .PDFInit def +{File (r) file PDFContext .PDFStream} stopped not { - /knownoget - { - 2 copy known { - get - true - }{ - pop pop false - } ifelse - }bind def + PDFContext .PDFInfo + File + () = ( ) print print ( has ) print + dup /NumPages get dup =print 10 mod 1 eq { ( page.\n) } { ( pages\n) } ifelse = flush - /PDFContext << >> .PDFInit def - {File (r) file PDFContext .PDFStream} stopped not + /DumpXML where {/DumpXML get}{//false}ifelse { - - PDFContext .PDFInfo - File - () = ( ) print print ( has ) print - dup /NumPages get dup =print 10 mod 1 eq { ( page.\n) } { ( pages\n) } ifelse = flush - - /DumpXML where {/DumpXML get}{//false}ifelse + (\n*** DumpXML is no longer supported. ***\n\n) print + }if + + 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 + (\n) print flush + + /EmbeddedFonts 10 dict def + /UnEmbeddedFonts 10 dict def + /FontNumbers 10 dict def + + /NumPages get 0 1 3 -1 roll 1 sub + { + dup + PDFContext exch .PDFPageInfoExt exch + DumpMediaSizes { + (Page ) print 1 add =print + dup /UserUnit knownoget {( UserUnit: ) print =print} if + dup /MediaBox knownoget {( MediaBox: ) print ==only} if + dup /CropBox knownoget {( CropBox: ) print ==only} if + dup /BleedBox knownoget {( BleedBox: ) print ==only} if + dup /TrimBox knownoget {( TrimBox: ) print ==only} if + dup /ArtBox knownoget {( ArtBox: ) print ==only} if + dup /Rotate knownoget not {0}if ( Rotate = ) print =print + dup /Annots knownoget {{( Page contains Annotations) print} if} if + dup /UsesTransparency knownoget {{( Page uses transparency features) print} if} if + dup /Spots knownoget { + (\n Page Spot colors: ) = + {( ) print (') print 256 string cvs print (') =} forall + } if + (\n) print flush + (\n) print flush + } { - (\n*** DumpXML is no longer supported. ***\n\n) print - }if - - 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 - (\n) print flush - - /EmbeddedFonts 10 dict def - /UnEmbeddedFonts 10 dict def - /FontNumbers 10 dict def + pop + } ifelse - /NumPages get 0 1 3 -1 roll 1 sub + /Fonts knownoget { - dup - PDFContext exch .PDFPageInfoExt exch - DumpMediaSizes { - (Page ) print 1 add =print - dup /UserUnit knownoget {( UserUnit: ) print =print} if - dup /MediaBox knownoget {( MediaBox: ) print ==only} if - dup /CropBox knownoget {( CropBox: ) print ==only} if - dup /BleedBox knownoget {( BleedBox: ) print ==only} if - dup /TrimBox knownoget {( TrimBox: ) print ==only} if - dup /ArtBox knownoget {( ArtBox: ) print ==only} if - dup /Rotate knownoget not {0}if ( Rotate = ) print =print - dup /Annots knownoget {{( Page contains Annotations) print} if} if - dup /UsesTransparency knownoget {{( Page uses transparency features) print} if} if - dup /Spots knownoget { - (\n Page Spot colors: ) = - {( ) print (') print 256 string cvs print (') =} forall - } if - (\n) print flush - (\n) print flush - } - { - pop - } ifelse - - /Fonts knownoget { + dup /ObjectNum known { - dup /ObjectNum known + %% Fonts with an ObjectNumber may have been previously referenced on another page + dup /ObjectNum get + dup FontNumbers exch known { - %% Fonts with an ObjectNumber may have been previously referenced on another page - dup /ObjectNum get - dup FontNumbers exch known - { - pop - %% found the ObjectNumber in the FontNumbers dictionary so we've seen this one. - //false - } - { - %% Not seen before, add the number to the array and process this font - FontNumbers exch dup put - //true - }ifelse - }{ - %% Fonts without an ObjectNumber are defined inline and so must be unique + pop + %% found the ObjectNumber in the FontNumbers dictionary so we've seen this one. + //false + } + { + %% Not seen before, add the number to the array and process this font + FontNumbers exch dup put //true - } ifelse + }ifelse + }{ + %% Fonts without an ObjectNumber are defined inline and so must be unique + //true + } ifelse + { + % First time we've seen the font + dup /Descendants known { - % First time we've seen the font - dup /Descendants known + dup /BaseFont get + EmbeddedFonts exch dup put % We class the Type 0 font as 'embedded', but it's really the descendant which is embedded or not. + dup /Descendants get + 1 index /BaseFont get + 2 index /Embedded get { - dup /BaseFont get - EmbeddedFonts exch dup put % We class the Type 0 font as 'embedded', but it's really the descendant which is embedded or not. - dup /Descendants get - 1 index /BaseFont get - 2 index /Embedded get - { - EmbeddedFonts exch dup put - } - { - UnEmbeddedFonts exch dup put - }ifelse - pop + EmbeddedFonts exch dup put } { - dup /BaseFont get - 1 index /Embedded get - { - EmbeddedFonts exch dup put - } - { - UnEmbeddedFonts exch dup put - } ifelse + UnEmbeddedFonts exch dup put }ifelse pop } { - pop - } ifelse - }forall - } if - } for + dup /BaseFont get + 1 index /Embedded get + { + EmbeddedFonts exch dup put + } + { + UnEmbeddedFonts exch dup put + } ifelse + }ifelse + pop + } + { + pop + } ifelse + }forall + } if + } for - /DumpFontsUsed where {/DumpFontsUsed get}{//false}ifelse + /DumpFontsUsed where {/DumpFontsUsed get}{//false}ifelse + { + [ + UnEmbeddedFonts {pop} forall + /ShowEmbeddedFonts where {/ShowEmbeddedFonts get}{//false}ifelse { - [ - UnEmbeddedFonts {pop} forall - /ShowEmbeddedFonts where {/ShowEmbeddedFonts get}{//false}ifelse - { - EmbeddedFonts {pop} forall - } if - ] - dup length 0 gt { - { 100 string cvs exch 100 string cvs exch lt } .sort - (\nFont or CIDFont resources used (plain name and ASCIIHEX string representation):) = - { 128 string cvs dup print ( ) print (<) print 128 string cvs {16 8 string cvrs print} forall (>) print (\n) print} forall - } if - } + EmbeddedFonts {pop} forall + } if + ] + dup length 0 gt { + { 100 string cvs exch 100 string cvs exch lt } .sort + (\nFont or CIDFont resources used (plain name and ASCIIHEX string representation):) = + { 128 string cvs dup print ( ) print (<) print 128 string cvs {16 8 string cvrs print} forall (>) print (\n) print} forall + } if + } + { + [ + DumpFontsNeeded { - [ - DumpFontsNeeded - { - UnEmbeddedFonts {pop} forall - } if - ] - dup length 0 gt { - { 100 string cvs exch 100 string cvs exch lt } .sort - (\nFonts Needed that are not embedded \(system fonts required\):) = - { ( ) print 128 string cvs dup print ( ) print (<) print {16 8 string cvrs print} forall (>) print (\n) print} forall - } if - }ifelse - } if - PDFContext .PDFClose -} -{ - enum-pdfs -} ifelse + UnEmbeddedFonts {pop} forall + } if + ] + dup length 0 gt { + { 100 string cvs exch 100 string cvs exch lt } .sort + (\nFonts Needed that are not embedded \(system fonts required\):) = + { ( ) print 128 string cvs dup print ( ) print (<) print {16 8 string cvrs print} forall (>) print (\n) print} forall + } if + }ifelse +} if +PDFContext .PDFClose + end quit |