More progress on -chop
This commit is contained in:
parent
f573ba8e09
commit
d3449af2c0
1
Changes
1
Changes
|
@ -11,6 +11,7 @@ o Identify PDF/A, PDF/X, PDF/E, PDF/VT, PDF/UA in -info
|
||||||
o Identify AcroForm in -info
|
o Identify AcroForm in -info
|
||||||
o Extract font files from a document
|
o Extract font files from a document
|
||||||
o List images on a page with -list-images[-json]
|
o List images on a page with -list-images[-json]
|
||||||
|
o Chop pages up into sections with -chop
|
||||||
|
|
||||||
Extended features:
|
Extended features:
|
||||||
|
|
||||||
|
|
17
cpdfchop.ml
17
cpdfchop.ml
|
@ -2,11 +2,24 @@ open Pdfutil
|
||||||
open Cpdferror
|
open Cpdferror
|
||||||
|
|
||||||
(* Resources - what to do with each. Bookmarks? Annotations - must be duplicated... *)
|
(* Resources - what to do with each. Bookmarks? Annotations - must be duplicated... *)
|
||||||
(* Test how the sharing affects other cpdf operations. *)
|
(* Test how the sharing affects other cpdf operations - especially with -fast! *)
|
||||||
|
(* Allow different orders - btt / ltr etc. *)
|
||||||
|
|
||||||
(* Chop a single page into pieces. We prefer the cropbox when available. We set
|
(* Chop a single page into pieces. We prefer the cropbox when available. We set
|
||||||
mediabox only, and delete any other boxes. *)
|
mediabox only, and delete any other boxes. *)
|
||||||
let chop_boxes x y p = [p; p]
|
(* FIXME check non-zero based boxes *)
|
||||||
|
let chop_boxes x y p =
|
||||||
|
if x < 1 || y < 1 then Cpdferror.error "chop_boxes bad specification" else
|
||||||
|
let move_page p dx dy = Printf.printf "move_page %f %f\n" dx dy; p in
|
||||||
|
let minx, miny, maxx, maxy = 0., 0., 540., 666. in
|
||||||
|
let w, h = (maxx -. minx) /. float_of_int x, (maxy -. miny) /. float_of_int y in
|
||||||
|
let ps = ref [] in
|
||||||
|
for ty = 0 to x do
|
||||||
|
for tx = 0 to y do
|
||||||
|
ps =| move_page p (w *. float_of_int tx) (h *. float_of_int ty *. ~-.1.)
|
||||||
|
done
|
||||||
|
done;
|
||||||
|
rev !ps
|
||||||
|
|
||||||
(* Chop pages in the range into pieces *)
|
(* Chop pages in the range into pieces *)
|
||||||
let chop ~x ~y pdf range =
|
let chop ~x ~y pdf range =
|
||||||
|
|
Loading…
Reference in New Issue