JSON to outputs
This commit is contained in:
parent
d02ff84dd8
commit
a6256c0331
2
Makefile
2
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
|
||||
|
|
|
@ -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)
|
|
@ -0,0 +1 @@
|
|||
val to_output : Pdfio.output -> bool -> bool -> Pdf.t -> unit
|
|
@ -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 *)
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
(* Read JSON into a PDF *)
|
||||
let read i = Pdf.empty ()
|
|
@ -1 +0,0 @@
|
|||
val read : Pdfio.input -> Pdf.t
|
|
@ -1 +0,0 @@
|
|||
val write : out_channel -> bool -> bool -> Pdf.t -> unit
|
Loading…
Reference in New Issue