From ebc40c8ee4fc90b37296b27a913e5b23841e26a3 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Tue, 12 Oct 2021 16:03:22 +0100 Subject: [PATCH] more --- cpdfjson.ml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cpdfjson.ml b/cpdfjson.ml index 7589e98..12adc61 100644 --- a/cpdfjson.ml +++ b/cpdfjson.ml @@ -202,11 +202,16 @@ let rec json_of_object pdf fcs no_stream_data = function | _ -> ()) elts; `Assoc (map (fun (k, v) -> (k, json_of_object pdf fcs no_stream_data v)) elts) - | P.Stream ({contents = (P.Dictionary dict, stream)} as mut) as thestream -> + | P.Stream ({contents = (P.Dictionary dict as d, stream)} as mut) as thestream -> P.getstream thestream; let str = - if no_stream_data then "<>" else - match !mut with (_, P.Got b) -> Pdfio.string_of_bytes b | _ -> error "failure: toget" + match P.lookup_direct pdf "/FunctionType" d with + | Some _ -> + Pdfcodec.decode_pdfstream_until_unknown pdf thestream; + begin match !mut with (_, P.Got b) -> Pdfio.string_of_bytes b | _ -> error "/FunctionType: failure: decomp" end + | None -> + if no_stream_data then "<>" else + match !mut with (_, P.Got b) -> Pdfio.string_of_bytes b | _ -> error "failure: toget" in json_of_object pdf fcs no_stream_data (P.Dictionary [("S", P.Array [P.Dictionary dict; P.String str])]) | P.Stream _ -> error "error: stream with not-a-dictionary"