This commit is contained in:
John Whitington 2023-05-01 16:19:09 +01:00
parent 0cfc6f0afd
commit a8d8f447bf
2 changed files with 34 additions and 23 deletions

View File

@ -213,13 +213,7 @@ let pagelabel pdf num =
num num
(Pdfpagelabels.complete (Pdfpagelabels.read pdf)) (Pdfpagelabels.complete (Pdfpagelabels.read pdf))
let addtext let replace_pairs pdf endpage extract_text_font_size filename bates batespad num page =
time lines linewidth outline fast colour fontname encoding bates batespad
fontsize font fontpdfobj underneath position hoffset voffset text pages
cropbox opacity justification filename extract_text_font_size shift pdf
=
let endpage = Pdfpage.endpage pdf in
let replace_pairs pdf filename bates batespad num page =
[ [
"%PageDiv2", (fun () -> string_of_int ((num + 1) / 2)); "%PageDiv2", (fun () -> string_of_int ((num + 1) / 2));
"%Page", (fun () -> string_of_int num); "%Page", (fun () -> string_of_int num);
@ -239,7 +233,13 @@ let addtext
if String.length numstring >= w if String.length numstring >= w
then numstring then numstring
else implode (many '0' (w - String.length numstring)) ^ numstring))] else implode (many '0' (w - String.length numstring)) ^ numstring))]
in
let addtext
time lines linewidth outline fast colour fontname encoding bates batespad
fontsize font fontpdfobj underneath position hoffset voffset text pages
cropbox opacity justification filename extract_text_font_size shift pdf
=
let endpage = Pdfpage.endpage pdf in
let shifts = Cpdfcoord.parse_coordinates pdf shift in let shifts = Cpdfcoord.parse_coordinates pdf shift in
let addtext_page num page = let addtext_page num page =
let shift_x, shift_y = List.nth shifts (num - 1) in let shift_x, shift_y = List.nth shifts (num - 1) in
@ -298,13 +298,13 @@ let addtext
in in
let unique_fontname = Pdf.unique_key "F" fontdict in let unique_fontname = Pdf.unique_key "F" fontdict in
let ops, urls, x, y, hoffset, voffset, text, joffset = let ops, urls, x, y, hoffset, voffset, text, joffset =
let text = process_text time text (replace_pairs pdf filename bates batespad num page) in let text = process_text time text (replace_pairs pdf endpage extract_text_font_size filename bates batespad num page) in
let text, urls = get_urls_line text in let text, urls = get_urls_line text in
let expanded_lines = let expanded_lines =
map map
(function text -> (function text ->
process_text time text (replace_pairs pdf filename bates batespad num page)) process_text time text (replace_pairs pdf endpage extract_text_font_size filename bates batespad num page))
lines lines
in in
let expanded_lines = (* process URLs for justification too *) let expanded_lines = (* process URLs for justification too *)

View File

@ -45,6 +45,17 @@ val addtexts :
Pdf.t ->(*pdf*) Pdf.t ->(*pdf*)
Pdf.t Pdf.t
val replace_pairs :
Pdf.t ->
int ->
float option ->
string ->
int ->
int option -> int -> Pdfpage.t -> (string * (unit -> string)) list
val process_text :
Cpdfstrftime.t -> string -> (string * (unit -> string)) list -> string
(* Add a rectangle to the page *) (* Add a rectangle to the page *)
val addrectangle : val addrectangle :
bool -> bool ->