This commit is contained in:
John Whitington 2021-12-15 13:01:51 +00:00
parent e769b12493
commit e821b1722c
3 changed files with 25 additions and 4 deletions

View File

@ -5,6 +5,7 @@ New features:
o Can read as well as write PDFs in JSON format with -j o Can read as well as write PDFs in JSON format with -j
o New operation -typeset typesets a text file as a PDF o New operation -typeset typesets a text file as a PDF
o New operation -table-of-contents makes table of contents from bookmarks o New operation -table-of-contents makes table of contents from bookmarks
o New operations -impose and -impose-xy for document imposition
o New operation -print-font-table gives (charcode, unicode, glyph name) triples o New operation -print-font-table gives (charcode, unicode, glyph name) triples
o New -print-dict-entry operation prints values for a given key o New -print-dict-entry operation prints values for a given key
o New -replace-dict-entry function to search & replace e.g URLs o New -replace-dict-entry function to search & replace e.g URLs
@ -13,7 +14,6 @@ o Prepend NOT to a page range to invert it
o Output annotations in JSON form with -list-annotations-json o Output annotations in JSON form with -list-annotations-json
o Output bookmarks in JSON format with -list-bookmarks-json o Output bookmarks in JSON format with -list-bookmarks-json
o Load bookmarks in JSON format with -add-bookmarks-json o Load bookmarks in JSON format with -add-bookmarks-json
o New operations -impose and -impose-xy for document imposition
o New option -collate to collate pages when merging o New option -collate to collate pages when merging
o Text added in existing fonts is now encoding-aware (plus new raw mode) o Text added in existing fonts is now encoding-aware (plus new raw mode)
o Option -debug-force now properly documented as -decrypt-force o Option -debug-force now properly documented as -decrypt-force
@ -26,6 +26,7 @@ o When adding text or graphics, may choose CYMK or Grey instead of RGB
o The -list-fonts operation now obeys the range o The -list-fonts operation now obeys the range
o Can now search for a font by real name with -font o Can now search for a font by real name with -font
o Basic merging of AcroForms when merging documents o Basic merging of AcroForms when merging documents
o Add -idir-only-pdfs to restrict -idir to just files ending in .pdf
Internal changes: Internal changes:

View File

@ -477,7 +477,8 @@ type args =
mutable replace_dict_entry_value : Pdf.pdfobject; mutable replace_dict_entry_value : Pdf.pdfobject;
mutable dict_entry_search : Pdf.pdfobject option; mutable dict_entry_search : Pdf.pdfobject option;
mutable toc_title : string; mutable toc_title : string;
mutable toc_bookmark : bool} mutable toc_bookmark : bool;
mutable idir_only_pdfs : bool}
let args = let args =
{op = None; {op = None;
@ -595,7 +596,8 @@ let args =
replace_dict_entry_value = Pdf.Null; replace_dict_entry_value = Pdf.Null;
dict_entry_search = None; dict_entry_search = None;
toc_title = "Table of Contents"; toc_title = "Table of Contents";
toc_bookmark = true} toc_bookmark = true;
idir_only_pdfs = false}
let reset_arguments () = let reset_arguments () =
args.op <- None; args.op <- None;
@ -698,7 +700,8 @@ let reset_arguments () =
args.replace_dict_entry_value <- Pdf.Null; args.replace_dict_entry_value <- Pdf.Null;
args.dict_entry_search <- None; args.dict_entry_search <- None;
args.toc_title <- "Table of Contents"; args.toc_title <- "Table of Contents";
args.toc_bookmark <- true args.toc_bookmark <- true;
args.idir_only_pdfs <- false
(* Do not reset original_filename or cpdflin or was_encrypted or (* Do not reset original_filename or cpdflin or was_encrypted or
* was_decrypted_with_owner or recrypt or producer or creator or path_to_* or * was_decrypted_with_owner or recrypt or producer or creator or path_to_* or
* gs_malformed or gs_quiet, since we want these to work across ANDs. Or * gs_malformed or gs_quiet, since we want these to work across ANDs. Or
@ -1231,6 +1234,16 @@ let set_json_input s =
let set_input_dir s = let set_input_dir s =
let names = sort compare (leafnames_of_dir s) in let names = sort compare (leafnames_of_dir s) in
let names =
if args.idir_only_pdfs then
option_map
(fun x ->
if String.length x > 4 && String.lowercase_ascii (String.sub x (String.length x - 4) 4) = ".pdf"
then Some x else None)
names
else
names
in
args.inputs <- args.inputs <-
(rev (rev
(map (map
@ -1644,6 +1657,9 @@ let settableofcontentstitle s =
let settocnobookmark () = let settocnobookmark () =
args.toc_bookmark <- false args.toc_bookmark <- false
let setidironlypdfs () =
args.idir_only_pdfs <- true
let whingemalformed () = let whingemalformed () =
prerr_string "Command line must be of exactly the form\ncpdf <infile> -gs <path> -gs-malformed-force -o <outfile>\n"; prerr_string "Command line must be of exactly the form\ncpdf <infile> -gs <path> -gs-malformed-force -o <outfile>\n";
exit 1 exit 1
@ -1665,6 +1681,9 @@ and specs =
("-idir", ("-idir",
Arg.String set_input_dir, Arg.String set_input_dir,
" Add a directory of files"); " Add a directory of files");
("-idir-only-pdfs",
Arg.Unit setidironlypdfs,
" Have -idir ignore files not ending in .pdf");
("-pw", ("-pw",
Arg.String setdashpassword, Arg.String setdashpassword,
" Supply a password explicitly -pw=<password>"); " Supply a password explicitly -pw=<password>");

View File

@ -11,6 +11,7 @@
%Document new colourspaces for -add-text -add-rectangle %Document new colourspaces for -add-text -add-rectangle
%Document -table-of-contents, -table-of-contents-title (inc. newlines), -font. Mention -upright. %Document -table-of-contents, -table-of-contents-title (inc. newlines), -font. Mention -upright.
%Document -typeset %Document -typeset
%Document -idir-only-pdfs must precede -idir
\documentclass{book} \documentclass{book}
% Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf etc. % Edit here to produce cpdfmanual.pdf, cpdflibmanual.pdf, pycpdfmanual.pdf etc.
\usepackage{comment}\excludecomment{cpdflib}\excludecomment{pycpdflib} \usepackage{comment}\excludecomment{cpdflib}\excludecomment{pycpdflib}