diff --git a/cpdffont.ml b/cpdffont.ml index c7f851f..67bd829 100644 --- a/cpdffont.ml +++ b/cpdffont.ml @@ -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)))) diff --git a/cpdffont.mli b/cpdffont.mli index 45efc3e..db23b3f 100644 --- a/cpdffont.mli +++ b/cpdffont.mli @@ -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 *)