cache time
This commit is contained in:
parent
c122df5dc5
commit
f2a1daff3e
11
cpdf.ml
11
cpdf.ml
|
@ -581,10 +581,10 @@ let pagelabel pdf num =
|
||||||
num
|
num
|
||||||
(Pdfpagelabels.complete (Pdfpagelabels.read pdf))
|
(Pdfpagelabels.complete (Pdfpagelabels.read pdf))
|
||||||
|
|
||||||
let rec process_text text m =
|
let rec process_text time text m =
|
||||||
match m with
|
match m with
|
||||||
| [] -> Cpdfstrftime.strftime text
|
| [] -> Cpdfstrftime.strftime ~time text
|
||||||
| (s, r)::t -> process_text (string_replace_all_lazy s r text) t
|
| (s, r)::t -> process_text time (string_replace_all_lazy s r text) t
|
||||||
|
|
||||||
let expand_date = function
|
let expand_date = function
|
||||||
| "now" -> Cpdfstrftime.strftime "D:%Y%m%d%H%M%S"
|
| "now" -> Cpdfstrftime.strftime "D:%Y%m%d%H%M%S"
|
||||||
|
@ -1806,6 +1806,7 @@ let addtext
|
||||||
underneath position hoffset voffset text pages orientation cropbox opacity
|
underneath position hoffset voffset text pages orientation cropbox opacity
|
||||||
justification filename extract_text_font_size shift pdf
|
justification filename extract_text_font_size shift pdf
|
||||||
=
|
=
|
||||||
|
let time = Cpdfstrftime.current_time () in
|
||||||
let endpage = Pdfpage.endpage pdf in
|
let endpage = Pdfpage.endpage pdf in
|
||||||
let replace_pairs pdf filename bates batespad num page =
|
let replace_pairs pdf filename bates batespad num page =
|
||||||
[
|
[
|
||||||
|
@ -1854,7 +1855,7 @@ let addtext
|
||||||
in
|
in
|
||||||
let unique_fontname = Pdf.unique_key "F" fontdict in
|
let unique_fontname = Pdf.unique_key "F" fontdict in
|
||||||
let ops =
|
let ops =
|
||||||
let text = process_text text (replace_pairs pdf filename bates batespad num page) in
|
let text = process_text time text (replace_pairs pdf filename bates batespad num page) in
|
||||||
let calc_textwidth text =
|
let calc_textwidth text =
|
||||||
match font with
|
match font with
|
||||||
| Some f ->
|
| Some f ->
|
||||||
|
@ -1882,7 +1883,7 @@ let addtext
|
||||||
let expanded_lines =
|
let expanded_lines =
|
||||||
map
|
map
|
||||||
(function text ->
|
(function text ->
|
||||||
process_text text (replace_pairs pdf filename bates batespad num page))
|
process_text time text (replace_pairs pdf filename bates batespad num page))
|
||||||
lines
|
lines
|
||||||
in
|
in
|
||||||
let textwidth = calc_textwidth text
|
let textwidth = calc_textwidth text
|
||||||
|
|
|
@ -15,5 +15,7 @@ type t =
|
||||||
_tm_yday : int;
|
_tm_yday : int;
|
||||||
_tm_isdst : bool}
|
_tm_isdst : bool}
|
||||||
|
|
||||||
|
val current_time : unit -> t
|
||||||
|
|
||||||
(** If time omitted, the current time is used. *)
|
(** If time omitted, the current time is used. *)
|
||||||
val strftime : ?time:t -> string -> string
|
val strftime : ?time:t -> string -> string
|
||||||
|
|
Loading…
Reference in New Issue