diff --git a/Makefile b/Makefile index d8a54d1..57c0f88 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Build the cpdf command line tools and top level MODS = cpdfstream tjutil tjutf16 tjllist tjparserMonad tjjson xmlm \ - cpdfwriteJSON cpdfreadJSON cpdfstrftime cpdfcoord \ + cpdfJSON cpdfstrftime cpdfcoord \ cpdfpagespec cpdfposition cpdf cpdfcommand SOURCES = $(foreach x,$(MODS),$(x).ml $(x).mli) cpdfcommandrun.ml diff --git a/cpdfwriteJSON.ml b/cpdfJSON.ml similarity index 98% rename from cpdfwriteJSON.ml rename to cpdfJSON.ml index fe00c40..2caf6fb 100644 --- a/cpdfwriteJSON.ml +++ b/cpdfJSON.ml @@ -232,9 +232,10 @@ let json_of_pdf parse_content no_stream_data pdf = (fun (objnum, jsonobj) -> J.Array [J.Number (soi objnum); jsonobj]) pairs_parsed) -let write fh parse_content no_stream_data pdf = +(* FIXME Proper streaming to output, rather than making a big string first. *) +let to_output output parse_content no_stream_data pdf = let b = Buffer.create 256 in let formatter = Format.formatter_of_buffer b in J.format formatter (json_of_pdf parse_content no_stream_data pdf); Format.pp_print_flush formatter (); - output_string fh (Buffer.contents b) + output.Pdfio.output_string (Buffer.contents b) diff --git a/cpdfJSON.mli b/cpdfJSON.mli new file mode 100644 index 0000000..97eafa6 --- /dev/null +++ b/cpdfJSON.mli @@ -0,0 +1 @@ +val to_output : Pdfio.output -> bool -> bool -> Pdf.t -> unit diff --git a/cpdfcommand.ml b/cpdfcommand.ml index d8fd9d2..f4aa021 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -3447,10 +3447,10 @@ let write_json output pdf = | NoOutputSpecified -> error "-output-json: no output name specified" | Stdout -> - CpdfwriteJSON.write stdout args.jsonparsecontentstreams args.jsonnostreamdata pdf + CpdfJSON.to_output (Pdfio.output_of_channel stdout) args.jsonparsecontentstreams args.jsonnostreamdata pdf | File filename -> let f = open_out filename in - CpdfwriteJSON.write f args.jsonparsecontentstreams args.jsonnostreamdata pdf; + CpdfJSON.to_output (Pdfio.output_of_channel f) args.jsonparsecontentstreams args.jsonnostreamdata pdf; close_out f (* Main function *) diff --git a/cpdfreadJSON.ml b/cpdfreadJSON.ml deleted file mode 100644 index 9e0bd3d..0000000 --- a/cpdfreadJSON.ml +++ /dev/null @@ -1,2 +0,0 @@ -(* Read JSON into a PDF *) -let read i = Pdf.empty () diff --git a/cpdfreadJSON.mli b/cpdfreadJSON.mli deleted file mode 100644 index 8af8967..0000000 --- a/cpdfreadJSON.mli +++ /dev/null @@ -1 +0,0 @@ -val read : Pdfio.input -> Pdf.t diff --git a/cpdfwriteJSON.mli b/cpdfwriteJSON.mli deleted file mode 100644 index 77861bc..0000000 --- a/cpdfwriteJSON.mli +++ /dev/null @@ -1 +0,0 @@ -val write : out_channel -> bool -> bool -> Pdf.t -> unit