mirror of
				https://github.com/johnwhitington/cpdf-source.git
				synced 2025-06-05 22:09:39 +02:00 
			
		
		
		
	Scaffolding for -chop-h, -chop-v
This commit is contained in:
		| @@ -67,3 +67,7 @@ let chop ~x ~y ~columns ~btt ~rtl pdf range = | |||||||
|            pages) |            pages) | ||||||
|   in |   in | ||||||
|     Pdfpage.change_pages ~changes true pdf pages_out |     Pdfpage.change_pages ~changes true pdf pages_out | ||||||
|  |  | ||||||
|  |  | ||||||
|  | let chop_hv ~is_h ~p ~columns pdf range = | ||||||
|  |   pdf | ||||||
|   | |||||||
| @@ -2,3 +2,5 @@ | |||||||
|  |  | ||||||
| (** Chop a page into pieces. *) | (** Chop a page into pieces. *) | ||||||
| val chop : x:int -> y:int -> columns:bool -> btt:bool -> rtl:bool -> Pdf.t -> int list -> Pdf.t | val chop : x:int -> y:int -> columns:bool -> btt:bool -> rtl:bool -> Pdf.t -> int list -> Pdf.t | ||||||
|  |  | ||||||
|  | val chop_hv : is_h:bool -> p:float -> columns:bool -> Pdf.t -> int list -> Pdf.t | ||||||
|   | |||||||
| @@ -231,6 +231,7 @@ type op = | |||||||
|   | Draw |   | Draw | ||||||
|   | Composition of bool |   | Composition of bool | ||||||
|   | Chop of int * int |   | Chop of int * int | ||||||
|  |   | ChopHV of bool * float | ||||||
|   | ProcessImages |   | ProcessImages | ||||||
|   | ExtractStream of int |   | ExtractStream of int | ||||||
|   | PrintObj of int |   | PrintObj of int | ||||||
| @@ -372,6 +373,7 @@ let string_of_op = function | |||||||
|   | Draw -> "Draw" |   | Draw -> "Draw" | ||||||
|   | Composition _ -> "Composition" |   | Composition _ -> "Composition" | ||||||
|   | Chop _ -> "Chop" |   | Chop _ -> "Chop" | ||||||
|  |   | ChopHV _ -> "ChopHV" | ||||||
|   | ProcessImages -> "ProcessImages" |   | ProcessImages -> "ProcessImages" | ||||||
|   | ExtractStream _ -> "ExtractStream" |   | ExtractStream _ -> "ExtractStream" | ||||||
|   | PrintObj _ -> "PrintObj" |   | PrintObj _ -> "PrintObj" | ||||||
| @@ -903,7 +905,7 @@ let banned banlist = function | |||||||
|   | Decrypt | Encrypt | CombinePages _ -> true (* Never allowed *) |   | Decrypt | Encrypt | CombinePages _ -> true (* Never allowed *) | ||||||
|   | AddBookmarks _ | PadBefore | PadAfter | PadEvery _ | PadMultiple _ | PadMultipleBefore _ |   | AddBookmarks _ | PadBefore | PadAfter | PadEvery _ | PadMultiple _ | PadMultipleBefore _ | ||||||
|   | Merge | Split | SplitOnBookmarks _ | SplitMax _ | Spray | RotateContents _ | Rotate _ |   | Merge | Split | SplitOnBookmarks _ | SplitMax _ | Spray | RotateContents _ | Rotate _ | ||||||
|   | Rotateby _ | Upright | VFlip | HFlip | Impose _ | Chop _ -> |   | Rotateby _ | Upright | VFlip | HFlip | Impose _ | Chop _ | ChopHV _ -> | ||||||
|       mem Pdfcrypt.NoAssemble banlist |       mem Pdfcrypt.NoAssemble banlist | ||||||
|   | TwoUp|TwoUpStack|RemoveBookmarks|AddRectangle|RemoveText| |   | TwoUp|TwoUpStack|RemoveBookmarks|AddRectangle|RemoveText| | ||||||
|     Draft|Shift|ShiftBoxes | Scale|ScaleToFit|RemoveAttachedFiles| |     Draft|Shift|ShiftBoxes | Scale|ScaleToFit|RemoveAttachedFiles| | ||||||
| @@ -1648,6 +1650,12 @@ let setchop s = | |||||||
|   let x, y = Cpdfcoord.parse_coordinate empty s in |   let x, y = Cpdfcoord.parse_coordinate empty s in | ||||||
|   setop (Chop (int_of_float x, int_of_float y)) () |   setop (Chop (int_of_float x, int_of_float y)) () | ||||||
|  |  | ||||||
|  | let setchopv x = | ||||||
|  |   setop (ChopHV (false, x)) () | ||||||
|  |  | ||||||
|  | let setchoph y = | ||||||
|  |   setop (ChopHV (true, y)) () | ||||||
|  |  | ||||||
| let setreplacedictentry s = | let setreplacedictentry s = | ||||||
|   setop (ReplaceDictEntry s) () |   setop (ReplaceDictEntry s) () | ||||||
|  |  | ||||||
| @@ -2311,6 +2319,12 @@ and specs = | |||||||
|    ("-chop", |    ("-chop", | ||||||
|       Arg.String setchop, |       Arg.String setchop, | ||||||
|       " Chop x by y"); |       " Chop x by y"); | ||||||
|  |    ("-chop-h", | ||||||
|  |       Arg.Float setchoph, | ||||||
|  |       " Chop horizontally"); | ||||||
|  |    ("-chop-v", | ||||||
|  |       Arg.Float setchopv, | ||||||
|  |       " Chop horizontally"); | ||||||
|    ("-chop-columns", |    ("-chop-columns", | ||||||
|       Arg.Unit (fun () -> args.impose_columns <- true), |       Arg.Unit (fun () -> args.impose_columns <- true), | ||||||
|       " Chop in columns rather than rows"); |       " Chop in columns rather than rows"); | ||||||
| @@ -4446,6 +4460,10 @@ let go () = | |||||||
|       let pdf = get_single_pdf args.op false in |       let pdf = get_single_pdf args.op false in | ||||||
|       let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in |       let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in | ||||||
|         write_pdf false (Cpdfchop.chop ~x ~y ~columns:args.impose_columns ~btt:args.impose_btt ~rtl:args.impose_rtl pdf range) |         write_pdf false (Cpdfchop.chop ~x ~y ~columns:args.impose_columns ~btt:args.impose_btt ~rtl:args.impose_rtl pdf range) | ||||||
|  |   | Some (ChopHV (is_h, p)) -> | ||||||
|  |       let pdf = get_single_pdf args.op false in | ||||||
|  |       let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in | ||||||
|  |         write_pdf false (Cpdfchop.chop_hv ~is_h ~p ~columns:args.impose_columns pdf range) | ||||||
|   | Some ProcessImages -> |   | Some ProcessImages -> | ||||||
|       let pdf = get_single_pdf args.op false in |       let pdf = get_single_pdf args.op false in | ||||||
|       let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in |       let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user