mirror of
				https://github.com/johnwhitington/cpdf-source.git
				synced 2025-06-05 22:09:39 +02:00 
			
		
		
		
	JSON to outputs
This commit is contained in:
		
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							| @@ -1,6 +1,6 @@ | |||||||
| # Build the cpdf command line tools and top level | # Build the cpdf command line tools and top level | ||||||
| MODS = cpdfstream tjutil tjutf16 tjllist tjparserMonad tjjson xmlm \ | MODS = cpdfstream tjutil tjutf16 tjllist tjparserMonad tjjson xmlm \ | ||||||
|        cpdfwriteJSON cpdfreadJSON cpdfstrftime cpdfcoord \ |        cpdfJSON cpdfstrftime cpdfcoord \ | ||||||
|        cpdfpagespec cpdfposition cpdf cpdfcommand |        cpdfpagespec cpdfposition cpdf cpdfcommand | ||||||
|  |  | ||||||
| SOURCES = $(foreach x,$(MODS),$(x).ml $(x).mli) cpdfcommandrun.ml | 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]) |           (fun (objnum, jsonobj) -> J.Array [J.Number (soi objnum); jsonobj]) | ||||||
|           pairs_parsed) |           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 b = Buffer.create 256 in | ||||||
|   let formatter = Format.formatter_of_buffer b in |   let formatter = Format.formatter_of_buffer b in | ||||||
|     J.format formatter (json_of_pdf parse_content no_stream_data pdf); |     J.format formatter (json_of_pdf parse_content no_stream_data pdf); | ||||||
|     Format.pp_print_flush formatter (); |     Format.pp_print_flush formatter (); | ||||||
|     output_string fh (Buffer.contents b) |     output.Pdfio.output_string (Buffer.contents b) | ||||||
							
								
								
									
										1
									
								
								cpdfJSON.mli
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								cpdfJSON.mli
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1 @@ | |||||||
|  | val to_output : Pdfio.output -> bool -> bool -> Pdf.t -> unit | ||||||
| @@ -3447,10 +3447,10 @@ let write_json output pdf = | |||||||
|   | NoOutputSpecified -> |   | NoOutputSpecified -> | ||||||
|       error "-output-json: no output name specified" |       error "-output-json: no output name specified" | ||||||
|   | Stdout -> |   | Stdout -> | ||||||
|       CpdfwriteJSON.write stdout args.jsonparsecontentstreams args.jsonnostreamdata pdf |       CpdfJSON.to_output (Pdfio.output_of_channel stdout) args.jsonparsecontentstreams args.jsonnostreamdata pdf | ||||||
|   | File filename -> |   | File filename -> | ||||||
|       let f = open_out filename in |       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 |         close_out f | ||||||
|  |  | ||||||
| (* Main function *) | (* 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 |  | ||||||
		Reference in New Issue
	
	Block a user