Changes for shift_boxes in cpdflib
This commit is contained in:
parent
8684ec3092
commit
17c8e1ae1a
|
@ -4041,10 +4041,7 @@ let go () =
|
|||
let pdf = get_single_pdf args.op false in
|
||||
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
||||
let dxdylist = Cpdfcoord.parse_coordinates pdf args.coord in
|
||||
let dx, dy = match dxdylist with (a, b)::_ -> a, b | _ -> 0.0, 0.0 in
|
||||
let f (xmin, ymin, xmax, ymax) = (xmin +. dx, ymin +. dy, xmax +. dx, ymax +. dy) in
|
||||
let fpage _ p = Cpdfpage.change_boxes f pdf p in
|
||||
write_pdf false (Cpdfpage.process_pages (Pdfpage.ppstub fpage) pdf range)
|
||||
write_pdf false (Cpdfpage.shift_boxes dxdylist pdf range)
|
||||
| Some Scale ->
|
||||
let pdf = get_single_pdf args.op false in
|
||||
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
||||
|
|
|
@ -310,6 +310,11 @@ let change_boxes f pdf page =
|
|||
make_mediabox (f (Pdf.parse_rectangle pdf page.Pdfpage.mediabox));
|
||||
Pdfpage.rest = rest'}
|
||||
|
||||
let shift_boxes dxdylist pdf range =
|
||||
let dx, dy = match dxdylist with (a, b)::_ -> a, b | _ -> 0.0, 0.0 in
|
||||
let f (xmin, ymin, xmax, ymax) = (xmin +. dx, ymin +. dy, xmax +. dx, ymax +. dy) in
|
||||
let fpage _ p = change_boxes f pdf p in
|
||||
process_pages (Pdfpage.ppstub fpage) pdf range
|
||||
|
||||
(* Scale contents *)
|
||||
let scale_page_contents ?(fast=false) scale position pdf pnum page =
|
||||
|
|
|
@ -23,6 +23,8 @@ val hard_box : Pdf.t -> int list -> string -> bool -> bool -> Pdf.t
|
|||
for all pages in pdf. *)
|
||||
val shift_pdf : ?fast:bool -> (float * float) list -> Pdf.t -> int list -> Pdf.t
|
||||
|
||||
val shift_boxes : (float * float) list -> Pdf.t -> int list -> Pdf.t
|
||||
|
||||
(** Change a page's media box so its minimum x and y are 0, making other
|
||||
operations simpler to think about. Any shift that is done is reflected in
|
||||
other boxes (clip etc.) *)
|
||||
|
|
Loading…
Reference in New Issue