Fix up /Length

This commit is contained in:
John Whitington 2021-10-05 13:08:46 +01:00
parent 14edc5a5db
commit 19633c9019
1 changed files with 5 additions and 1 deletions

View File

@ -120,7 +120,11 @@ and object_of_json = function
| J.Object ["F", J.Number f] -> P.Real (float_of_string f) | J.Object ["F", J.Number f] -> P.Real (float_of_string f)
| J.Object ["N", J.String n] -> P.Name n | J.Object ["N", J.String n] -> P.Name n
| J.Object ["S", J.Array [dict; J.String data]] -> | J.Object ["S", J.Array [dict; J.String data]] ->
P.Stream (ref (object_of_json dict, P.Got (Pdfio.bytes_of_string data))) (* Fix up the length, in case it's been edited. *)
let d' =
P.add_dict_entry (object_of_json dict) "/Length" (P.Integer (String.length data))
in
P.Stream (ref (d', P.Got (Pdfio.bytes_of_string data)))
| J.Object ["S", J.Array [dict; J.Array parsed_ops]] -> | J.Object ["S", J.Array [dict; J.Array parsed_ops]] ->
Pdfops.stream_of_ops (List.map op_of_json parsed_ops) Pdfops.stream_of_ops (List.map op_of_json parsed_ops)
| J.Object elts -> P.Dictionary (map (fun (n, o) -> (n, object_of_json o)) elts) | J.Object elts -> P.Dictionary (map (fun (n, o) -> (n, object_of_json o)) elts)