Expose JSON

This commit is contained in:
John Whitington 2024-02-07 20:41:53 +00:00
parent 17c8e1ae1a
commit a4e3ca0bfa
2 changed files with 6 additions and 0 deletions

View File

@ -294,6 +294,9 @@ let json_of_font (pagenum, name, subtype, basefont, encoding) =
("basefont", if basefont = "" then `Null else `String basefont);
("encoding", if encoding = "" then `Null else `String encoding)]
let json_fonts pdf range =
`List (map json_of_font (list_fonts pdf range))
let print_fonts ?(json=false) pdf range =
if json
then flprint (Cpdfyojson.Safe.pretty_to_string (`List (map json_of_font (list_fonts pdf range))))

View File

@ -8,6 +8,9 @@ val print_fonts : ?json:bool -> Pdf.t -> int list -> unit
(** Return font list. Page number, name, subtype, basefont, encoding. *)
val list_fonts : Pdf.t -> int list -> (int * string * string * string * string) list
(** Return font list in JSON format *)
val json_fonts : Pdf.t -> int list -> Cpdfyojson.Safe.t
(** {2 Miscellany.} *)
(** Embed missing fonts *)