From 7846b70c392ff0b6ffc07f85ff110436e3a8bf83 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Thu, 14 Oct 2021 20:51:25 +0100 Subject: [PATCH] more --- cpdfjson.ml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cpdfjson.ml b/cpdfjson.ml index fb8eba0..8ad4b33 100644 --- a/cpdfjson.ml +++ b/cpdfjson.ml @@ -215,16 +215,17 @@ let rec json_of_object pdf fcs no_stream_data pcs = function `Assoc (map (fun (k, v) -> (k, json_of_object pdf fcs no_stream_data pcs v)) elts) | P.Stream ({contents = (P.Dictionary dict as d, stream)} as mut) as thestream -> P.getstream thestream; - let str = + let str, dict' = match P.lookup_direct pdf "/FunctionType" d, pcs with | Some _, true -> Pdfcodec.decode_pdfstream_until_unknown pdf thestream; - begin match !mut with (_, P.Got b) -> Pdfio.string_of_bytes b | _ -> error "/FunctionType: failure: decomp" end + let dict = P.remove_dict_entry d "/Filter" in + begin match !mut with (_, P.Got b) -> (Pdfio.string_of_bytes b, dict) | _ -> error "/FunctionType: failure: decomp" end | _ -> - if no_stream_data then "<>" else - match !mut with (_, P.Got b) -> Pdfio.string_of_bytes b | _ -> error "failure: toget" + if no_stream_data then ("<>", d) else + match !mut with (_, P.Got b) -> (Pdfio.string_of_bytes b, d) | _ -> error "failure: toget" in - json_of_object pdf fcs no_stream_data pcs (P.Dictionary [("S", P.Array [P.Dictionary dict; P.String str])]) + json_of_object pdf fcs no_stream_data pcs (P.Dictionary [("S", P.Array [dict'; P.String str])]) | P.Stream _ -> error "error: stream with not-a-dictionary" | P.Indirect i -> begin match P.lookup_obj pdf i with