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