This commit is contained in:
John Whitington 2021-10-26 16:39:26 +01:00
parent 609943e78c
commit d7e9a79e73
1 changed files with 8 additions and 11 deletions

15
cpdf.ml
View File

@ -2933,7 +2933,9 @@ let impose_pages fit x y columns rtl btt center margin output_mediabox fast fit_
| [] -> assert false
| (h::_) as pages ->
let transforms =
impose_transforms fit x y columns rtl btt center margin h.Pdfpage.mediabox output_mediabox fit_extra_hspace fit_extra_vspace (length pages)
impose_transforms
fit x y columns rtl btt center margin h.Pdfpage.mediabox
output_mediabox fit_extra_hspace fit_extra_vspace (length pages)
in
(* Change the pattern matrices before combining resources *)
let pages, h =
@ -2946,20 +2948,15 @@ let impose_pages fit x y columns rtl btt center margin output_mediabox fast fit_
let transform_stream transform contents =
(* If fast, no mismatched q/Q protection and no parsing of operators. *)
if fast then
let before = Pdfops.stream_of_ops [Pdfops.Op_q; Pdfops.Op_cm transform] in
let after = Pdfops.stream_of_ops [Pdfops.Op_Q] in
[before] @ contents @ [after]
[Pdfops.stream_of_ops [Pdfops.Op_q; Pdfops.Op_cm transform]] @ contents @ [Pdfops.stream_of_ops [Pdfops.Op_Q]]
else
(* If slow, use protect from Pdfpage. *)
let ops = Pdfpage.protect pdf resources' contents @ Pdfops.parse_operators pdf resources' contents in
[Pdfops.stream_of_ops
([Pdfops.Op_q] @ [Pdfops.Op_cm transform] @ ops @ [Pdfops.Op_Q])]
[Pdfops.stream_of_ops ([Pdfops.Op_q] @ [Pdfops.Op_cm transform] @ ops @ [Pdfops.Op_Q])]
in
flatten
(map2
(fun p t ->
transform_annotations pdf t p.Pdfpage.rest;
transform_stream t p.Pdfpage.content)
(fun p t -> transform_annotations pdf t p.Pdfpage.rest; transform_stream t p.Pdfpage.content)
pages
transforms)
in