From b33864548aba0fd23379f9778376d60ef647567b Mon Sep 17 00:00:00 2001 From: John Whitington Date: Thu, 6 Feb 2020 17:06:36 +0000 Subject: [PATCH] Decompress and keep colourspace functions --- cpdfwriteJSON.ml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/cpdfwriteJSON.ml b/cpdfwriteJSON.ml index 6c8cbad..feda764 100644 --- a/cpdfwriteJSON.ml +++ b/cpdfwriteJSON.ml @@ -23,11 +23,17 @@ let rec json_of_object pdf fcs no_stream_data = function | _ -> ()) elts; J.Object (List.map (fun (k, v) -> (k, json_of_object pdf fcs no_stream_data v)) elts) - | P.Stream {contents = (Pdf.Dictionary dict, stream)} as thestream -> + | P.Stream ({contents = (Pdf.Dictionary dict as d, stream)} as mut) as thestream -> Pdf.getstream thestream; let str = - if no_stream_data then "<>" else - match stream with Pdf.Got b -> Pdfio.string_of_bytes b | Pdf.ToGet _ -> "failure: toget" + begin match Pdf.lookup_direct pdf "/FunctionType" d with + | Some _ -> + Pdfcodec.decode_pdfstream_until_unknown pdf thestream; + begin match !mut with (_, Pdf.Got b) -> Pdfio.string_of_bytes b | _ -> "failure: decomp" end + | None -> + if no_stream_data then "<>" else + match stream with Pdf.Got b -> Pdfio.string_of_bytes b | Pdf.ToGet _ -> "failure: toget" + end in json_of_object pdf fcs no_stream_data (P.Array [P.Dictionary dict; P.String str]) | P.Stream _ -> J.String "error: stream with not-a-dictioary"