***remove old pattern matrices code for new transform method

This commit is contained in:
John Whitington 2023-03-23 16:05:55 +00:00
parent 3af1730e14
commit f406397cc8
4 changed files with 20 additions and 21 deletions

View File

@ -128,8 +128,9 @@ let impose_pages fit x y columns rtl btt center margin output_mediabox fast fit_
in in
(* Change the pattern matrices before combining resources *) (* Change the pattern matrices before combining resources *)
let pages, h = let pages, h =
let r = map2 (fun p t -> Cpdfutil.change_pattern_matrices_page pdf t p) pages transforms in (*let r = map2 (fun p t -> Cpdfutil.change_pattern_matrices_page pdf t p) pages transforms in
(r, List.hd r) (r, List.hd r)*)
pages, List.hd pages
in in
let resources' = pair_reduce (Cpdfutil.combine_pdf_resources pdf) (map (fun p -> p.Pdfpage.resources) pages) in let resources' = pair_reduce (Cpdfutil.combine_pdf_resources pdf) (map (fun p -> p.Pdfpage.resources) pages) in
let rest' = pair_reduce (combine_pdf_rests pdf) (map (fun p -> p.Pdfpage.rest) pages) in let rest' = pair_reduce (combine_pdf_rests pdf) (map (fun p -> p.Pdfpage.rest) pages) in

View File

@ -88,9 +88,9 @@ let shift_page ?(fast=false) dxdylist pdf pnum page =
let transform_op = let transform_op =
Pdfops.Op_cm (Pdftransform.matrix_of_op (Pdftransform.Translate (dx, dy))) Pdfops.Op_cm (Pdftransform.matrix_of_op (Pdftransform.Translate (dx, dy)))
in in
let page = (*let page =
Cpdfutil.change_pattern_matrices_page pdf (Pdftransform.mktranslate ~-.dx ~-.dy) page Cpdfutil.change_pattern_matrices_page pdf (Pdftransform.mktranslate ~-.dx ~-.dy) page
in in*)
Cpdfutil.transform_annotations pdf (Pdftransform.mktranslate dx dy) page.Pdfpage.rest; Cpdfutil.transform_annotations pdf (Pdftransform.mktranslate dx dy) page.Pdfpage.rest;
(Pdfpage.prepend_operators pdf [transform_op] ~fast page, pnum, Pdftransform.mktranslate dx dy) (Pdfpage.prepend_operators pdf [transform_op] ~fast page, pnum, Pdftransform.mktranslate dx dy)
@ -162,7 +162,7 @@ let scale_page_contents ?(fast=false) scale position pdf pnum page =
Pdftransform.Scale ((sx, sy), scale, scale)] Pdftransform.Scale ((sx, sy), scale, scale)]
in in
let transform_op = Pdfops.Op_cm transform in let transform_op = Pdfops.Op_cm transform in
let page = Cpdfutil.change_pattern_matrices_page pdf transform page in (*let page = Cpdfutil.change_pattern_matrices_page pdf transform page in*)
Cpdfutil.transform_annotations pdf transform page.Pdfpage.rest; Cpdfutil.transform_annotations pdf transform page.Pdfpage.rest;
(Pdfpage.prepend_operators pdf [transform_op] ~fast page, pnum, transform) (Pdfpage.prepend_operators pdf [transform_op] ~fast page, pnum, transform)
@ -259,7 +259,7 @@ let transform_boxes tr pdf page =
let transform_contents ?(fast=false) tr pdf page = let transform_contents ?(fast=false) tr pdf page =
let transform_op = Pdfops.Op_cm tr in let transform_op = Pdfops.Op_cm tr in
let page = Cpdfutil.change_pattern_matrices_page pdf (Pdftransform.matrix_invert tr) page in (*let page = Cpdfutil.change_pattern_matrices_page pdf (Pdftransform.matrix_invert tr) page in*)
Cpdfutil.transform_annotations pdf tr page.Pdfpage.rest; Cpdfutil.transform_annotations pdf tr page.Pdfpage.rest;
Pdfpage.prepend_operators pdf [transform_op] ~fast page Pdfpage.prepend_operators pdf [transform_op] ~fast page
@ -315,12 +315,12 @@ let rotate_page_contents ~fast rotpoint r pdf pnum page =
let tr = let tr =
Pdftransform.matrix_of_op Pdftransform.matrix_of_op
(Pdftransform.Rotate (rotation_point, -.(rad_of_deg r))) (Pdftransform.Rotate (rotation_point, -.(rad_of_deg r)))
in let tr2 = (*in let tr2 =
Pdftransform.matrix_of_op Pdftransform.matrix_of_op
(Pdftransform.Rotate (rotation_point, rad_of_deg r)) (Pdftransform.Rotate (rotation_point, rad_of_deg r))*)
in in
let transform_op = Pdfops.Op_cm tr in let transform_op = Pdfops.Op_cm tr in
let page = Cpdfutil.change_pattern_matrices_page pdf tr2 page in (*let page = Cpdfutil.change_pattern_matrices_page pdf tr2 page in*)
Cpdfutil.transform_annotations pdf tr page.Pdfpage.rest; Cpdfutil.transform_annotations pdf tr page.Pdfpage.rest;
(Pdfpage.prepend_operators pdf [transform_op] ~fast page, pnum, tr) (Pdfpage.prepend_operators pdf [transform_op] ~fast page, pnum, tr)
@ -338,8 +338,8 @@ let scale_pdf ?(fast=false) sxsylist pdf range =
and matrix = Pdftransform.matrix_of_op (Pdftransform.Scale ((0., 0.), sx, sy)) in and matrix = Pdftransform.matrix_of_op (Pdftransform.Scale ((0., 0.), sx, sy)) in
let transform_op = let transform_op =
Pdfops.Op_cm matrix Pdfops.Op_cm matrix
and page = (*and page =
Cpdfutil.change_pattern_matrices_page pdf (Pdftransform.matrix_invert matrix) page Cpdfutil.change_pattern_matrices_page pdf (Pdftransform.matrix_invert matrix) page*)
in in
Cpdfutil.transform_annotations pdf matrix page.Pdfpage.rest; Cpdfutil.transform_annotations pdf matrix page.Pdfpage.rest;
(Pdfpage.prepend_operators pdf ~fast [transform_op] page, pnum, matrix) (Pdfpage.prepend_operators pdf ~fast [transform_op] page, pnum, matrix)
@ -384,7 +384,7 @@ let scale_to_fit_pdf ?(fast=false) position input_scale xylist op pdf range =
in in
Cpdfutil.transform_annotations pdf matrix page.Pdfpage.rest; Cpdfutil.transform_annotations pdf matrix page.Pdfpage.rest;
(Pdfpage.prepend_operators pdf [Pdfops.Op_cm matrix] ~fast (Pdfpage.prepend_operators pdf [Pdfops.Op_cm matrix] ~fast
(Cpdfutil.change_pattern_matrices_page pdf (Pdftransform.matrix_invert matrix) page), pnum, matrix) ((*Cpdfutil.change_pattern_matrices_page pdf (Pdftransform.matrix_invert matrix)*) page), pnum, matrix)
in in
process_pages scale_page_to_fit pdf range process_pages scale_page_to_fit pdf range
@ -422,7 +422,7 @@ let flip_page ?(fast=false) transform_op pdf pnum page =
Pdf.parse_rectangle pdf page.Pdfpage.mediabox Pdf.parse_rectangle pdf page.Pdfpage.mediabox
in in
let tr = transform_op minx miny maxx maxy in let tr = transform_op minx miny maxx maxy in
let page = Cpdfutil.change_pattern_matrices_page pdf tr page in (*let page = Cpdfutil.change_pattern_matrices_page pdf tr page in*)
Cpdfutil.transform_annotations pdf tr page.Pdfpage.rest; Cpdfutil.transform_annotations pdf tr page.Pdfpage.rest;
(Pdfpage.prepend_operators pdf [Pdfops.Op_cm tr] ~fast page, pnum, tr) (Pdfpage.prepend_operators pdf [Pdfops.Op_cm tr] ~fast page, pnum, tr)
@ -515,7 +515,7 @@ let do_stamp relative_to_cropbox fast position topline midline scale_to_fit isov
in in
Cpdfutil.transform_annotations pdf matrix o.Pdfpage.rest; Cpdfutil.transform_annotations pdf matrix o.Pdfpage.rest;
let r = Pdfpage.prepend_operators pdf [Pdfops.Op_cm matrix] ~fast o in let r = Pdfpage.prepend_operators pdf [Pdfops.Op_cm matrix] ~fast o in
Cpdfutil.change_pattern_matrices_page pdf matrix r (*Cpdfutil.change_pattern_matrices_page pdf matrix*) r
else else
let sw = sxmax -. sxmin and sh = symax -. symin let sw = sxmax -. sxmin and sh = symax -. symin
and w = txmax -. txmin and h = tymax -. tymin in and w = txmax -. txmin and h = tymax -. tymin in
@ -527,7 +527,7 @@ let do_stamp relative_to_cropbox fast position topline midline scale_to_fit isov
in in
Cpdfutil.transform_annotations pdf matrix o.Pdfpage.rest; Cpdfutil.transform_annotations pdf matrix o.Pdfpage.rest;
let r = Pdfpage.prepend_operators pdf [Pdfops.Op_cm matrix] ~fast o in let r = Pdfpage.prepend_operators pdf [Pdfops.Op_cm matrix] ~fast o in
Cpdfutil.change_pattern_matrices_page pdf matrix r (*Cpdfutil.change_pattern_matrices_page pdf matrix*) r
in in
{u with {u with
Pdfpage.content = Pdfpage.content =

View File

@ -40,7 +40,7 @@ let process_xobjects pdf page f =
elts elts
| _ -> () | _ -> ()
(* The content transformed by altering any use of [Op_cm]. But we must also (*(* The content transformed by altering any use of [Op_cm]. But we must also
alter any /Matrix entries in pattern dictionaries *) alter any /Matrix entries in pattern dictionaries *)
let change_pattern_matrices_resources pdf tr resources = let change_pattern_matrices_resources pdf tr resources =
try try
@ -95,7 +95,7 @@ let change_pattern_matrices_page pdf tr page =
| _ -> raise (Pdf.PDFError "change_pattern_matrices_page")) | _ -> raise (Pdf.PDFError "change_pattern_matrices_page"))
elts; elts;
page page
| _ -> page | _ -> page*)
(* Union two resource dictionaries from the same PDF. *) (* Union two resource dictionaries from the same PDF. *)
let combine_pdf_resources pdf a b = let combine_pdf_resources pdf a b =

View File

@ -4,12 +4,10 @@ val process_xobjects : Pdf.t ->
Pdf.pdfobject -> Pdf.pdfobject list -> Pdf.pdfobject list) -> Pdf.pdfobject -> Pdf.pdfobject list -> Pdf.pdfobject list) ->
unit unit
val change_pattern_matrices_page : Pdf.t -> Pdftransform.transform_matrix -> Pdfpage.t -> Pdfpage.t (*val change_pattern_matrices_page : Pdf.t -> Pdftransform.transform_matrix -> Pdfpage.t -> Pdfpage.t*)
val combine_pdf_resources : Pdf.t -> Pdf.pdfobject -> Pdf.pdfobject -> Pdf.pdfobject val combine_pdf_resources : Pdf.t -> Pdf.pdfobject -> Pdf.pdfobject -> Pdf.pdfobject
val transform_annotations : Pdf.t -> Pdftransform.transform_matrix -> Pdf.pdfobject -> unit val transform_annotations : Pdf.t -> Pdftransform.transform_matrix -> Pdf.pdfobject -> unit
val ppstub : val ppstub : ('a -> 'b -> 'c) -> 'a -> 'b -> 'c * 'a * Pdftransform.transform_matrix
('a -> 'b -> 'c) ->
'a -> 'b -> 'c * 'a * Pdftransform.transform_matrix