From b6c54398290ff2b1f110d3f7ccbc981ac4332253 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Mon, 27 Dec 2021 15:20:07 +0000 Subject: [PATCH] Clean up duplicated ppstub --- cpdfaddtext.ml | 10 +++------- cpdfannot.ml | 6 +----- cpdfcommand.ml | 3 --- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/cpdfaddtext.ml b/cpdfaddtext.ml index 0e53c81..e614d6c 100644 --- a/cpdfaddtext.ml +++ b/cpdfaddtext.ml @@ -6,10 +6,6 @@ type color = | RGB of float * float * float | CYMK of float * float * float * float -(* For uses of process_pages which don't need to deal with matrices, this - function transforms into one which returns the identity matrix *) -let ppstub f n p = (f n p, n, Pdftransform.i_matrix) - (* \section{Superimpose text, page numbers etc.} *) (* Process UTF8 text to /WinAnsiEncoding string (for standard 14) or whatever @@ -413,7 +409,7 @@ let addtext if metrics then (ignore (Cpdfpage.iter_pages (fun a b -> ignore (addtext_page a b)) pdf pages); pdf) else - Cpdfpage.process_pages (ppstub addtext_page) pdf pages + Cpdfpage.process_pages (Cpdfutil.ppstub addtext_page) pdf pages (* Prev is a list of lists of characters *) let split_at_newline t = @@ -578,7 +574,7 @@ let removetext range pdf = let ops = Pdfops.parse_operators pdf page.Pdfpage.resources page.Pdfpage.content in [Pdfops.stream_of_ops (remove_stamps [] ops)]} in - Cpdfpage.process_pages (ppstub removetext_page) pdf range + Cpdfpage.process_pages (Cpdfutil.ppstub removetext_page) pdf range let addrectangle fast (w, h) colour outline linewidth opacity position relative_to_cropbox @@ -642,7 +638,7 @@ let addrectangle then Pdfpage.prepend_operators pdf ops ~fast:fast page else Pdfpage.postpend_operators pdf ops ~fast:fast page in - Cpdfpage.process_pages (ppstub addrectangle_page) pdf range + Cpdfpage.process_pages (Cpdfutil.ppstub addrectangle_page) pdf range open Pdfutil let rec remove_all_text_ops pdf resources content = diff --git a/cpdfannot.ml b/cpdfannot.ml index e74faea..1510395 100644 --- a/cpdfannot.ml +++ b/cpdfannot.ml @@ -1,9 +1,5 @@ open Pdfutil -(* For uses of process_pages which don't need to deal with matrices, this - function transforms into one which returns the identity matrix *) -let ppstub f n p = (f n p, n, Pdftransform.i_matrix) - (* \section{List annotations} *) let get_annotation_string encoding pdf annot = match Pdf.lookup_direct pdf "/Contents" annot with @@ -185,4 +181,4 @@ let remove_annotations range pdf = else page in - Cpdfpage.process_pages (ppstub remove_annotations_page) pdf range + Cpdfpage.process_pages (Cpdfutil.ppstub remove_annotations_page) pdf range diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 78aa23e..06cb947 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -871,9 +871,6 @@ let rec decrypt_if_necessary (_, _, user_pw, owner_pw, was_dec_with_owner, _) op if args.debugcrypt then Printf.printf "Failed to decrypt with user password: raising soft_error"; soft_error "Failed to decrypt file: wrong password?" -(* Duplicated from cpdf.ml -> fix *) -let ppstub f n p = (f n p, n, Pdftransform.i_matrix) - (* Output Page Count *) let output_page_count pdf = Printf.printf "%i\n" (Pdfpage.endpage pdf)