diff --git a/cpdffont.ml b/cpdffont.ml index cd52e1d..7c75d3d 100644 --- a/cpdffont.ml +++ b/cpdffont.ml @@ -114,7 +114,7 @@ let missing_font ?l pdf page (name, dict) = in match l with | None -> Printf.printf "%i, %s, %s, %s, %s\n" page name subtype basefont encoding - | Some r -> r := Printf.sprintf "%i %s %s %s %s" page name subtype basefont encoding::!r + | Some r -> r := (page, name, subtype, basefont, encoding)::!r let missing_fonts ?l pdf range = Cpdfpage.iter_pages diff --git a/cpdffont.mli b/cpdffont.mli index 6ae10f9..27e1fba 100644 --- a/cpdffont.mli +++ b/cpdffont.mli @@ -20,9 +20,9 @@ val embed_missing_fonts : string -> bool -> string -> string -> unit val copy_font : Pdf.t -> string -> int -> int list -> Pdf.t -> Pdf.t (** Report missing fonts *) -val missing_fonts : ?l:string list ref -> Pdf.t -> int list -> unit +val missing_fonts : ?l:(int * string * string * string * string) list ref -> Pdf.t -> int list -> unit -val missing_fonts_return : Pdf.t -> int list -> string list +val missing_fonts_return : Pdf.t -> int list -> (int * string * string * string * string) list (** Print a font table to Standard Output. *) val print_font_table : Pdf.t -> string -> int -> unit diff --git a/cpdfua.ml b/cpdfua.ml index 96eff92..1cec903 100644 --- a/cpdfua.ml +++ b/cpdfua.ml @@ -28,23 +28,23 @@ let print_children (E (n, cs)) = flprint "\n" (* Read attributes. *) -let rec read_single d = - match d with +let rec read_single pdf d = + match Pdf.direct pdf d with | Pdf.Dictionary d -> map fst d - | Pdf.Stream s -> read_single (fst !s) + | Pdf.Stream s -> read_single pdf (fst !s) | Pdf.Name n -> [n] - | x -> error "read_single" + | x -> error ("read_single: " ^ Pdfwrite.string_of_pdf x) let read_a pdf n stnode = match Pdf.lookup_direct pdf n stnode with | Some (Pdf.Array attrs) -> let attrs = keep (function Pdf.Integer _ -> false | _ -> true) attrs in - flatten (map read_single attrs) + flatten (map (read_single pdf) attrs) | Some (Pdf.Name n) -> [n] | Some (Pdf.Dictionary d) -> - read_single (Pdf.Dictionary d) + read_single pdf (Pdf.Dictionary d) | Some (Pdf.Stream s) -> - read_single (Pdf.Stream s) + read_single pdf (Pdf.Stream s) | Some _ -> [] | None -> [] @@ -974,11 +974,12 @@ let matterhorn_31_008 _ _ pdf = (* For a font used by text intended to be rendered the font program is not embedded. *) -(* NB This, for now, reports all unembedded fonts. *) +(* NB This, for now, reports all unembedded fonts, save for Type 3 ones... *) let matterhorn_31_009 _ _ pdf = let l = Cpdffont.missing_fonts_return pdf (ilist 1 (Pdfpage.endpage pdf)) in + let l = lose (function (_, _, "/Type3", _, _) -> true | _ -> false) l in if l <> [] then - raise (MatterhornError (`List (map (fun x -> `String x) l))) + raise (MatterhornError (`List (map (fun (a, b, c, d, e) -> `String (Printf.sprintf "%i %s %s %s %s" a b c d e)) l))) (* For a font used by text the font program is embedded but it does not contain glyphs for all of the glyphs referenced by the text used for rendering. *)