This commit is contained in:
John Whitington 2021-11-01 15:40:33 +00:00
parent dc1ef2f5c8
commit d43e7c71da
2 changed files with 18 additions and 1 deletions

View File

@ -1,5 +1,6 @@
2.5 (Upcoming 2022) 2.5 (Upcoming 2022)
o New operation -print-font-encoding
o New -print-dict-entry operation prints values for a given key o New -print-dict-entry operation prints values for a given key
o Extend -remove-dict-entry to allow search o Extend -remove-dict-entry to allow search
o New -replace-dict-entry function to search & replace e.g URLs o New -replace-dict-entry function to search & replace e.g URLs

View File

@ -200,8 +200,10 @@ type op =
| OCGRename | OCGRename
| OCGOrderAll | OCGOrderAll
| StampAsXObject of string | StampAsXObject of string
| PrintFontEncoding of string
let string_of_op = function let string_of_op = function
| PrintFontEncoding _ -> "PrintFontEncoding"
| PrintDictEntry _ -> "PrintDictEntry" | PrintDictEntry _ -> "PrintDictEntry"
| Impose _ -> "Impose" | Impose _ -> "Impose"
| CopyFont _ -> "CopyFont" | CopyFont _ -> "CopyFont"
@ -748,7 +750,7 @@ let banned banlist = function
| SetModify _|SetCreator _|SetProducer _|RemoveDictEntry _ | ReplaceDictEntry _ | PrintDictEntry _ | SetMetadata _ | SetModify _|SetCreator _|SetProducer _|RemoveDictEntry _ | ReplaceDictEntry _ | PrintDictEntry _ | SetMetadata _
| ExtractText | ExtractImages | ExtractFontFile | ExtractText | ExtractImages | ExtractFontFile
| AddPageLabels | RemovePageLabels | OutputJSON | OCGCoalesce | AddPageLabels | RemovePageLabels | OutputJSON | OCGCoalesce
| OCGRename | OCGList | OCGOrderAll | OCGRename | OCGList | OCGOrderAll | PrintFontEncoding _
-> false (* Always allowed *) -> false (* Always allowed *)
(* Combine pages is not allowed because we would not know where to get the (* Combine pages is not allowed because we would not know where to get the
-recrypt from -- the first or second file? *) -recrypt from -- the first or second file? *)
@ -1618,6 +1620,9 @@ let setdictentrysearch s =
with with
e -> error (Printf.sprintf "Failed to parse search term: %s\n" (Printexc.to_string e)) e -> error (Printf.sprintf "Failed to parse search term: %s\n" (Printexc.to_string e))
let setprintfontencoding s =
setop (PrintFontEncoding s) ()
let whingemalformed () = let whingemalformed () =
prerr_string "Command line must be of exactly the form\ncpdf <infile> -gs <path> -gs-malformed-force -o <outfile>\n"; prerr_string "Command line must be of exactly the form\ncpdf <infile> -gs <path> -gs-malformed-force -o <outfile>\n";
exit 1 exit 1
@ -2369,6 +2374,12 @@ and specs =
("-stamp-as-xobject", ("-stamp-as-xobject",
Arg.String setstampasxobject, Arg.String setstampasxobject,
" Stamp a file as a form xobject in another"); " Stamp a file as a form xobject in another");
("-print-font-encoding",
Arg.String setprintfontencoding,
" Print the encoding for a given font");
("-print-font-encoding-page",
Arg.Int setfontpage,
" Set page for -print-font-encoding");
(* These items are undocumented *) (* These items are undocumented *)
("-remove-unused-resources", Arg.Unit (setop RemoveUnusedResources), ""); ("-remove-unused-resources", Arg.Unit (setop RemoveUnusedResources), "");
("-stay-on-error", Arg.Unit setstayonerror, ""); ("-stay-on-error", Arg.Unit setstayonerror, "");
@ -3319,6 +3330,8 @@ let collate (names, pdfs, ranges) =
done; done;
split3 (rev !nis) split3 (rev !nis)
let print_font_encoding pdf fontname pagenumber = ()
(* Main function *) (* Main function *)
let go () = let go () =
match args.op with match args.op with
@ -4230,6 +4243,9 @@ let go () =
Printf.printf "%s\n" xobj_name; Printf.printf "%s\n" xobj_name;
flush stdout; flush stdout;
write_pdf false pdf write_pdf false pdf
| Some (PrintFontEncoding fontname) ->
let pdf = get_single_pdf args.op true in
print_font_encoding pdf fontname args.copyfontpage
(* Advise the user if a combination of command line flags makes little sense, (* Advise the user if a combination of command line flags makes little sense,
or error out if it make no sense at all. *) or error out if it make no sense at all. *)