From 9fbd8a1650797f144f6479ad3eea63ff4dc989ec Mon Sep 17 00:00:00 2001 From: John Whitington Date: Wed, 15 Mar 2023 16:37:25 +0000 Subject: [PATCH] more --- cpdfmanual.tex | 1 + cpdfmetadata.ml | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cpdfmanual.tex b/cpdfmanual.tex index ec3d515..26d1eb5 100644 --- a/cpdfmanual.tex +++ b/cpdfmanual.tex @@ -8,6 +8,7 @@ %Document -composition[-json] %Document discourage GhostScript usage, since it can strip data (-gs-malformed, embed missing fonts) %Document [ ] pagespecs +%Document extensions to -info \documentclass{book} % Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf, % dotnetcpdflibmanual.pdf, jcpdflibmanual.pdf jscpdflibmanual.pdf etc. diff --git a/cpdfmetadata.ml b/cpdfmetadata.ml index 857dcb8..97a5473 100644 --- a/cpdfmetadata.ml +++ b/cpdfmetadata.ml @@ -165,6 +165,16 @@ let getstring encoding pdf = | Stripped -> get_info false pdf | UTF8 -> get_info_utf8 pdf +let get_catalog_item name pdf = + match Pdf.lookup_direct pdf "/Root" pdf.Pdf.trailerdict with + | Some catalog -> + begin try + implode (tl (explode (Pdfwrite.string_of_pdf (unopt (Pdf.lookup_direct pdf name catalog))))) + with + _ -> "" + end + | _ -> "" + let output_info encoding pdf = let getstring = getstring encoding pdf in Printf.printf "Version: %i.%i\n" pdf.Pdf.major pdf.Pdf.minor; @@ -177,7 +187,9 @@ let output_info encoding pdf = Printf.printf "Producer: %s\n" (getstring "/Producer"); Printf.printf "Created: %s\n" (getstring "/CreationDate"); Printf.printf "Modified: %s\n" (getstring "/ModDate"); - Printf.printf "Trapped: %s\n" (getstring "/Trapped") + Printf.printf "Trapped: %s\n" (getstring "/Trapped"); + Printf.printf "PageMode: %s\n" (get_catalog_item "/PageMode" pdf); + Printf.printf "PageLayout: %s\n" (get_catalog_item "/PageLayout" pdf) type xmltree = E of Cpdfxmlm.tag * xmltree list