First two examples out
This commit is contained in:
parent
b4f8500ef5
commit
d6fc80235f
|
@ -11,7 +11,6 @@ let rec json_of_object fcs = function
|
||||||
| P.Name n -> J.String n
|
| P.Name n -> J.String n
|
||||||
| P.Array objs -> J.Array (List.map (json_of_object fcs) objs)
|
| P.Array objs -> J.Array (List.map (json_of_object fcs) objs)
|
||||||
| P.Dictionary elts ->
|
| P.Dictionary elts ->
|
||||||
(* Detect contents stream object numbers for second pass *)
|
|
||||||
List.iter (function ("/Contents", P.Indirect i) -> fcs i | _ -> ()) elts;
|
List.iter (function ("/Contents", P.Indirect i) -> fcs i | _ -> ()) elts;
|
||||||
J.Object (List.map (fun (k, v) -> (k, json_of_object fcs v)) elts)
|
J.Object (List.map (fun (k, v) -> (k, json_of_object fcs v)) elts)
|
||||||
| P.Stream {contents = (Pdf.Dictionary dict, stream)} as thestream ->
|
| P.Stream {contents = (Pdf.Dictionary dict, stream)} as thestream ->
|
||||||
|
@ -21,25 +20,10 @@ let rec json_of_object fcs = function
|
||||||
| P.Stream _ -> J.String "error: stream with not-a-dictioary"
|
| P.Stream _ -> J.String "error: stream with not-a-dictioary"
|
||||||
| P.Indirect i -> J.Number (string_of_int i)
|
| P.Indirect i -> J.Number (string_of_int i)
|
||||||
|
|
||||||
|
let sof = string_of_float
|
||||||
|
let soi = string_of_int
|
||||||
|
|
||||||
let json_of_op = function
|
let json_of_op = function
|
||||||
| O.Op_w w -> J.Array [J.String "w"]
|
|
||||||
| O.Op_J j -> J.Array [J.String "J"]
|
|
||||||
| O.Op_j j -> J.Array [J.String "j"]
|
|
||||||
| O.Op_M m -> J.Array [J.String "m"]
|
|
||||||
| O.Op_d (fl, y) ->J.Array [J.String "d"]
|
|
||||||
| O.Op_ri s -> J.Array [J.String "ri"]
|
|
||||||
| O.Op_i i -> J.Array [J.String "i"]
|
|
||||||
| O.Op_gs s -> J.Array [J.String "gs"]
|
|
||||||
| O.Op_q -> J.Array [J.String "q"]
|
|
||||||
| O.Op_Q -> J.Array [J.String "Q"]
|
|
||||||
| O.Op_cm t ->J.Array [J.String "cm"]
|
|
||||||
| O.Op_m (a, b) ->J.Array [J.String "m"]
|
|
||||||
| O.Op_l (a, b) ->J.Array [J.String "l"]
|
|
||||||
| O.Op_c (a, b, c, d, e, k) ->J.Array [J.String "c"]
|
|
||||||
| O.Op_v (a, b, c, d) ->J.Array [J.String "v"]
|
|
||||||
| O.Op_y (a, b, c, d) -> J.Array [J.String "y"]
|
|
||||||
| O.Op_h -> J.Array [J.String "h"]
|
|
||||||
| O.Op_re (a, b, c, d) -> J.Array [J.String "re"]
|
|
||||||
| O.Op_S -> J.Array [J.String "S"]
|
| O.Op_S -> J.Array [J.String "S"]
|
||||||
| O.Op_s -> J.Array [J.String "s"]
|
| O.Op_s -> J.Array [J.String "s"]
|
||||||
| O.Op_f -> J.Array [J.String "f"]
|
| O.Op_f -> J.Array [J.String "f"]
|
||||||
|
@ -54,7 +38,49 @@ let json_of_op = function
|
||||||
| O.Op_W' -> J.Array [J.String "W'"]
|
| O.Op_W' -> J.Array [J.String "W'"]
|
||||||
| O.Op_BT -> J.Array [J.String "BT"]
|
| O.Op_BT -> J.Array [J.String "BT"]
|
||||||
| O.Op_ET -> J.Array [J.String "ET"]
|
| O.Op_ET -> J.Array [J.String "ET"]
|
||||||
| O.Op_Tc c ->J.Array [J.String "Tc"]
|
| O.Op_q -> J.Array [J.String "q"]
|
||||||
|
| O.Op_Q -> J.Array [J.String "Q"]
|
||||||
|
| O.Op_h -> J.Array [J.String "h"]
|
||||||
|
| O.Op_T' -> J.Array [J.String "T'"]
|
||||||
|
| O.Op_EMC -> J.Array [J.String "EMC"]
|
||||||
|
| O.Op_BX -> J.Array [J.String "BX"]
|
||||||
|
| O.Op_EX -> J.Array [J.String "EX"]
|
||||||
|
|
||||||
|
| O.Op_re (a, b, c, d) ->
|
||||||
|
J.Array [J.Number (sof a); J.Number (sof b); J.Number (sof c); J.Number (sof d); J.String "re"]
|
||||||
|
| O.Op_k (c, m, y, k) ->
|
||||||
|
J.Array [J.Number (sof c); J.Number (sof m); J.Number (sof y); J.Number (sof k); J.String "k"]
|
||||||
|
| O.Op_m (a, b) -> J.Array [J.Number (sof a); J.Number (sof b); J.String "m"]
|
||||||
|
| O.Op_l (a, b) -> J.Array [J.Number (sof a); J.Number (sof b); J.String "l"]
|
||||||
|
| O.Op_BDC (s, obj) -> J.Array [J.String s; J.String (Pdfwrite.string_of_pdf obj); J.String "BDC"]
|
||||||
|
| O.Op_gs s -> J.Array [J.String s; J.String "gs"]
|
||||||
|
| O.Op_Do s -> J.Array [J.String s; J.String "Do"]
|
||||||
|
| O.Op_CS s -> J.Array [J.String s; J.String "CS"]
|
||||||
|
| O.Op_SCN fs -> J.Array ((List.map (fun x -> J.Number (sof x)) fs) @ [J.String "SCN"])
|
||||||
|
| O.Op_j j -> J.Array [J.Number (soi j); J.String "j"]
|
||||||
|
| O.Op_cm t ->
|
||||||
|
J.Array
|
||||||
|
[J.Number (sof t.Pdftransform.a);
|
||||||
|
J.Number (sof t.Pdftransform.b);
|
||||||
|
J.Number (sof t.Pdftransform.c);
|
||||||
|
J.Number (sof t.Pdftransform.d);
|
||||||
|
J.Number (sof t.Pdftransform.e);
|
||||||
|
J.Number (sof t.Pdftransform.f);
|
||||||
|
J.String "cm"]
|
||||||
|
| O.Op_d (fl, y) ->
|
||||||
|
J.Array [J.Array (List.map (fun x -> J.Number (sof x)) fl); J.Number (sof y); J.String "d"]
|
||||||
|
|
||||||
|
| _ -> J.Array [J.String "UNIMPLEMENTED"]
|
||||||
|
|
||||||
|
(* | O.Op_w w -> J.Array [J.String "w"]
|
||||||
|
| O.Op_J j -> J.Array [J.String "J"]
|
||||||
|
| O.Op_M m -> J.Array [J.String "m"]
|
||||||
|
| O.Op_ri s -> J.Array [J.String "ri"]
|
||||||
|
| O.Op_i i -> J.Array [J.String "i"]
|
||||||
|
| O.Op_c (a, b, c, d, e, k) ->J.Array [J.String "c"]
|
||||||
|
| O.Op_v (a, b, c, d) ->J.Array [J.String "v"]
|
||||||
|
| O.Op_y (a, b, c, d) -> J.Array [J.String "y"]
|
||||||
|
| O.Op_Tc c -> J.Array [J.String "Tc"]
|
||||||
| O.Op_Tw w -> J.Array [J.String "Tw"]
|
| O.Op_Tw w -> J.Array [J.String "Tw"]
|
||||||
| O.Op_Tz z -> J.Array [J.String "Tz"]
|
| O.Op_Tz z -> J.Array [J.String "Tz"]
|
||||||
| O.Op_TL l -> J.Array [J.String "TL"]
|
| O.Op_TL l -> J.Array [J.String "TL"]
|
||||||
|
@ -64,18 +90,15 @@ let json_of_op = function
|
||||||
| O.Op_Td (k, k') ->J.Array [J.String "Td"]
|
| O.Op_Td (k, k') ->J.Array [J.String "Td"]
|
||||||
| O.Op_TD (k, k') ->J.Array [J.String "TD"]
|
| O.Op_TD (k, k') ->J.Array [J.String "TD"]
|
||||||
| O.Op_Tm t ->J.Array [J.String "Tm"]
|
| O.Op_Tm t ->J.Array [J.String "Tm"]
|
||||||
| O.Op_T' -> J.Array [J.String "T'"]
|
|
||||||
| O.Op_Tj s -> J.Array [J.String "Tj"]
|
| O.Op_Tj s -> J.Array [J.String "Tj"]
|
||||||
| O.Op_TJ pdfobject -> J.Array [J.String "TJ"]
|
| O.Op_TJ pdfobject -> J.Array [J.String "TJ"]
|
||||||
| O.Op_' s -> J.Array [J.String "'"]
|
| O.Op_' s -> J.Array [J.String "'"]
|
||||||
| O.Op_'' (k, k', s) -> J.Array [J.String "''"]
|
| O.Op_'' (k, k', s) -> J.Array [J.String "''"]
|
||||||
| O.Op_d0 (k, k') ->J.Array [J.String "d0"]
|
| O.Op_d0 (k, k') ->J.Array [J.String "d0"]
|
||||||
| O.Op_d1 (a, b, c, d, e, k) ->J.Array [J.String "d1"]
|
| O.Op_d1 (a, b, c, d, e, k) ->J.Array [J.String "d1"]
|
||||||
| O.Op_CS s -> J.Array [J.String "CS"]
|
|
||||||
| O.Op_cs s -> J.Array [J.String "cs"]
|
| O.Op_cs s -> J.Array [J.String "cs"]
|
||||||
| O.Op_SC fs -> J.Array [J.String "SC"]
|
| O.Op_SC fs -> J.Array [J.String "SC"]
|
||||||
| O.Op_sc fs -> J.Array [J.String "sc"]
|
| O.Op_sc fs -> J.Array [J.String "sc"]
|
||||||
| O.Op_SCN fs -> J.Array [J.String "SCN"]
|
|
||||||
| O.Op_scn fs -> J.Array [J.String "scn"]
|
| O.Op_scn fs -> J.Array [J.String "scn"]
|
||||||
| O.Op_SCNName (s, fs) ->J.Array [J.String "SCNName"]
|
| O.Op_SCNName (s, fs) ->J.Array [J.String "SCNName"]
|
||||||
| O.Op_scnName (s, fs) ->J.Array [J.String "scnName"]
|
| O.Op_scnName (s, fs) ->J.Array [J.String "scnName"]
|
||||||
|
@ -84,18 +107,12 @@ let json_of_op = function
|
||||||
| O.Op_RG (r, g, b) ->J.Array [J.String "RG"]
|
| O.Op_RG (r, g, b) ->J.Array [J.String "RG"]
|
||||||
| O.Op_rg (r, g, b) ->J.Array [J.String "rg"]
|
| O.Op_rg (r, g, b) ->J.Array [J.String "rg"]
|
||||||
| O.Op_K (c, m, y, k) ->J.Array [J.String "K"]
|
| O.Op_K (c, m, y, k) ->J.Array [J.String "K"]
|
||||||
| O.Op_k (c, m, y, k) ->J.Array [J.String "k"]
|
|
||||||
| O.Op_sh s -> J.Array [J.String "sh"]
|
| O.Op_sh s -> J.Array [J.String "sh"]
|
||||||
| O.InlineImage (dict, data) -> J.Array [J.String "InlineImage"]
|
| O.InlineImage (dict, data) -> J.Array [J.String "InlineImage"]
|
||||||
| O.Op_Do s -> J.Array [J.String "Do"]
|
|
||||||
| O.Op_MP s -> J.Array [J.String "MP"]
|
| O.Op_MP s -> J.Array [J.String "MP"]
|
||||||
| O.Op_DP (s, obj) ->J.Array [J.String "DP"]
|
| O.Op_DP (s, obj) ->J.Array [J.String "DP"]
|
||||||
| O.Op_BMC s -> J.Array [J.String "BMC"]
|
| O.Op_BMC s -> J.Array [J.String "BMC"]
|
||||||
| O.Op_BDC (s, obj) ->J.Array [J.String "BDC"]
|
| O.Op_Unknown _ ->J.Array [J.String "Unknown"] *)
|
||||||
| O.Op_EMC -> J.Array [J.String "EMC"]
|
|
||||||
| O.Op_BX -> J.Array [J.String "BX"]
|
|
||||||
| O.Op_EX ->J.Array [J.String "EX"]
|
|
||||||
| O.Op_Unknown _ ->J.Array [J.String "Unknown"]
|
|
||||||
|
|
||||||
let parse_content_stream str =
|
let parse_content_stream str =
|
||||||
let ops = Pdfops.parse_stream (Pdf.empty ()) (Pdf.Dictionary []) [Pdfio.bytes_of_string str] in
|
let ops = Pdfops.parse_stream (Pdf.empty ()) (Pdf.Dictionary []) [Pdfio.bytes_of_string str] in
|
||||||
|
|
Loading…
Reference in New Issue