mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2025-06-05 22:09:39 +02:00
more
This commit is contained in:
24
cpdf.ml
24
cpdf.ml
@ -2768,33 +2768,39 @@ let combine_pdf_rests pdf a b =
|
|||||||
Pdf.Dictionary (unknown_keys_a @ unknown_keys_b @ combined_known_entries)
|
Pdf.Dictionary (unknown_keys_a @ unknown_keys_b @ combined_known_entries)
|
||||||
|
|
||||||
(* Calculate the transformation matrices for a single imposed output page. *)
|
(* Calculate the transformation matrices for a single imposed output page. *)
|
||||||
let impose_transforms n x y columns rtl btt center margin spacing linewidth mediabox =
|
let impose_transforms n fx fy columns rtl btt center margin spacing linewidth mediabox len =
|
||||||
let width, height =
|
let width, height =
|
||||||
match Pdf.parse_rectangle mediabox with
|
match Pdf.parse_rectangle mediabox with
|
||||||
xmin, ymin, xmax, ymax -> xmax -. xmin, ymax -. ymin
|
xmin, ymin, xmax, ymax -> xmax -. xmin, ymax -. ymin
|
||||||
in
|
in
|
||||||
let trs = ref [] in
|
let trs = ref [] in
|
||||||
|
let len = ref len in
|
||||||
|
let extra_x = ref 0. in
|
||||||
|
let extra_y = ref 0. in
|
||||||
let addtr px py =
|
let addtr px py =
|
||||||
trs := Pdftransform.matrix_of_transform [Pdftransform.Translate (px, py)]::!trs
|
trs := Pdftransform.matrix_of_transform [Pdftransform.Translate (px +. !extra_x, py +. !extra_y)]::!trs
|
||||||
in
|
in
|
||||||
let x = int_of_float x in
|
let x = int_of_float fx in
|
||||||
let y = int_of_float y in
|
let y = int_of_float fy in
|
||||||
let order row col =
|
let order row col =
|
||||||
(if btt then y - row - 1 else row),
|
((if btt then y - row - 1 else row), (if rtl then x - col - 1 else col))
|
||||||
(if rtl then x - col - 1 else col)
|
|
||||||
in
|
in
|
||||||
if columns then
|
if columns then
|
||||||
for col = 0 to x - 1 do
|
for col = 0 to x - 1 do
|
||||||
|
if center && !len < y then if !extra_y = 0. then extra_y := (height *. float_of_int (y - !len)) /. 2.;
|
||||||
for row = y - 1 downto 0 do
|
for row = y - 1 downto 0 do
|
||||||
let row, col = order row col in
|
let row, col = order row col in
|
||||||
addtr (width *. float_of_int col) (height *. float_of_int row)
|
if !len > 0 then addtr (width *. float_of_int col) (height *. float_of_int row);
|
||||||
|
len := !len - 1
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
for row = y - 1 downto 0 do
|
for row = y - 1 downto 0 do
|
||||||
|
if center && !len < x then if !extra_x = 0. then extra_x := (width *. float_of_int (x - !len)) /. 2.;
|
||||||
for col = 0 to x - 1 do
|
for col = 0 to x - 1 do
|
||||||
let row, col = order row col in
|
let row, col = order row col in
|
||||||
addtr (width *. float_of_int col) (height *. float_of_int row)
|
if !len > 0 then addtr (width *. float_of_int col) (height *. float_of_int row);
|
||||||
|
len := !len - 1
|
||||||
done
|
done
|
||||||
done;
|
done;
|
||||||
rev !trs
|
rev !trs
|
||||||
@ -2805,7 +2811,7 @@ let impose_pages n x y columns rtl btt center margin spacing linewidth mediabox'
|
|||||||
| [] -> assert false
|
| [] -> assert false
|
||||||
| (h::_) as pages ->
|
| (h::_) as pages ->
|
||||||
let transforms =
|
let transforms =
|
||||||
take (impose_transforms n x y columns rtl btt center margin spacing linewidth h.Pdfpage.mediabox) (length pages)
|
impose_transforms n x y columns rtl btt center margin spacing linewidth h.Pdfpage.mediabox (length pages)
|
||||||
in
|
in
|
||||||
(* Change the pattern matrices before combining resources *)
|
(* Change the pattern matrices before combining resources *)
|
||||||
let pages, h =
|
let pages, h =
|
||||||
|
Reference in New Issue
Block a user