DUP page ranges
This commit is contained in:
parent
847b120090
commit
2d794a2a99
1
Changes
1
Changes
|
@ -1,5 +1,6 @@
|
|||
2.5 (Upcoming 2022)
|
||||
|
||||
o Append e.g DUP2 to a page range to make 1,2,3 --> 1,1,2,2,3,3 etc.
|
||||
o The -list-fonts operation now obeys the range
|
||||
o New operation -print-font-table gives (charcode, unicode, glyph name) triples
|
||||
o Can now search for a font by real name with -font
|
||||
|
|
|
@ -92,7 +92,11 @@ let fixup_negatives endpage = function
|
|||
let invert_range endpage r =
|
||||
option_map (fun p -> if mem p r then None else Some p) (ilist 1 endpage)
|
||||
|
||||
let duplicate_range n r =
|
||||
flatten (map (fun x -> many x n) r)
|
||||
|
||||
let rec parse_pagespec_inner endpage pdf spec =
|
||||
let spec = if spec = "" then "all" else spec in
|
||||
let spec = space_string spec in
|
||||
if endpage < 1 then raise (Pdf.PDFError "This PDF file has no pages and is therefore malformed") else
|
||||
let numbers =
|
||||
|
@ -100,6 +104,14 @@ let rec parse_pagespec_inner endpage pdf spec =
|
|||
match explode spec with
|
||||
| 'N'::'O'::'T'::r ->
|
||||
invert_range endpage (parse_pagespec_inner endpage pdf (implode r))
|
||||
| x::'D'::'U'::'P'::r ->
|
||||
duplicate_range (int_of_string (implode [x])) (parse_pagespec_inner endpage pdf (implode r))
|
||||
| x::y::'D'::'U'::'P'::r ->
|
||||
duplicate_range (int_of_string (implode [x; y])) (parse_pagespec_inner endpage pdf (implode r))
|
||||
| x::y::z::'D'::'U'::'P'::r ->
|
||||
duplicate_range (int_of_string (implode [x; y; z])) (parse_pagespec_inner endpage pdf (implode r))
|
||||
| x::y::z::a::'D'::'U'::'P'::r ->
|
||||
duplicate_range (int_of_string (implode [x; y; z; a])) (parse_pagespec_inner endpage pdf (implode r))
|
||||
| _ ->
|
||||
match rev (explode spec) with
|
||||
| ['n'; 'e'; 'v'; 'e'] ->
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
{- The word all is the same as 1-end.}
|
||||
{- A range must contain no spaces.}
|
||||
{- A tilde (~) defines a page number counting from the end of the document rather than the beginning. Page ~1 is the last page, ~2 the penultimate page etc.}
|
||||
{- Prepending NOT to a whole page range inverts it.}
|
||||
{- Prepending NOT to a whole page range inverts it, once the whole is parsed. }
|
||||
{- Appending DUP2 to a whole page range duplicates each page twice (or 3, or 4 etc. times), once the whole is parsed. }
|
||||
}
|
||||
*)
|
||||
|
||||
|
|
Loading…
Reference in New Issue