From 6357f8f610f367643159c5f5925bf05b82a106f0 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Wed, 15 Nov 2023 17:26:43 +0000 Subject: [PATCH] Skeleton for -chop --- Makefile | 4 ++-- cpdfchop.ml | 5 +++++ cpdfchop.mli | 4 ++++ cpdfcommand.ml | 10 +++++++--- 4 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 cpdfchop.ml create mode 100644 cpdfchop.mli diff --git a/Makefile b/Makefile index 58998a2..4abb4ab 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,8 @@ DOC = cpdfunicodedata cpdferror cpdfdebug cpdfjson cpdfstrftime cpdfcoord \ cpdfbookmarks cpdfpage cpdftruetype cpdfremovetext cpdfextracttext \ cpdfembed cpdffont cpdftype cpdfaddtext cpdfpad cpdfocg \ cpdfsqueeze cpdfdraft cpdfspot cpdfpagelabels cpdfcreate cpdfannot \ - cpdfxobject cpdfimpose cpdftweak cpdftexttopdf cpdftoc cpdfjpeg \ - cpdfpng cpdfimage cpdfdraw cpdfcomposition cpdfshape \ + cpdfxobject cpdfimpose cpdfchop cpdftweak cpdftexttopdf cpdftoc \ + cpdfjpeg cpdfpng cpdfimage cpdfdraw cpdfcomposition cpdfshape \ cpdfcolours cpdfdrawcontrol cpdfcommand MODS = $(NONDOC) $(DOC) diff --git a/cpdfchop.ml b/cpdfchop.ml new file mode 100644 index 0000000..faf582c --- /dev/null +++ b/cpdfchop.ml @@ -0,0 +1,5 @@ +open Pdfutil +open Cpdferror + +(* Chop pages into pieces *) +let chop ~x ~y pdf range = pdf diff --git a/cpdfchop.mli b/cpdfchop.mli new file mode 100644 index 0000000..df6a08f --- /dev/null +++ b/cpdfchop.mli @@ -0,0 +1,4 @@ +(** Chop *) + +(** Chop *) +val chop : x:int -> y:int -> Pdf.t -> int list -> Pdf.t diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 9cc6b18..87c11f3 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -2,8 +2,8 @@ let demo = false let noncomp = false let major_version = 2 -let minor_version = 6 -let version_date = "(patch 2, 25th October 2023)" +let minor_version = 7 +let version_date = "(devel, 15th November 2023)" open Pdfutil open Pdfio @@ -229,6 +229,7 @@ type op = | TextWidth of string | Draw | Composition of bool + | Chop of int * int let string_of_op = function | PrintFontEncoding _ -> "PrintFontEncoding" @@ -365,6 +366,7 @@ let string_of_op = function | TextWidth _ -> "TextWidth" | Draw -> "Draw" | Composition _ -> "Composition" + | Chop _ -> "Chop" (* Inputs: filename, pagespec. *) type input_kind = @@ -853,7 +855,7 @@ let banned banlist = function | Decrypt | Encrypt | CombinePages _ -> true (* Never allowed *) | AddBookmarks _ | PadBefore | PadAfter | PadEvery _ | PadMultiple _ | PadMultipleBefore _ | Merge | Split | SplitOnBookmarks _ | SplitMax _ | Spray | RotateContents _ | Rotate _ - | Rotateby _ | Upright | VFlip | HFlip | Impose _ -> + | Rotateby _ | Upright | VFlip | HFlip | Impose _ | Chop _ -> mem Pdfcrypt.NoAssemble banlist | TwoUp|TwoUpStack|RemoveBookmarks|AddRectangle|RemoveText| Draft|Shift|Scale|ScaleToFit|RemoveAttachedFiles| @@ -4369,6 +4371,8 @@ let go () = | _ -> 0 in Cpdfcomposition.show_composition filesize json pdf + | Some (Chop (x, y)) -> + () (* Advise the user if a combination of command line flags makes little sense, or error out if it make no sense at all. *)