more
This commit is contained in:
parent
b4c07ea798
commit
4e2bd4ce5d
|
@ -421,7 +421,7 @@ let unescape_string s =
|
|||
implode (unescape_chars [] (explode s))
|
||||
|
||||
let
|
||||
addtexts ?embedinfo linewidth outline fast fontname font bates batespad
|
||||
addtexts linewidth outline fast fontname (cpdffont : Cpdfembed.cpdffont) bates batespad
|
||||
colour position linespacing fontsize underneath text pages cropbox opacity
|
||||
justification midline topline filename extract_text_font_size shift
|
||||
?(raw=false) pdf
|
||||
|
@ -429,6 +429,14 @@ let
|
|||
let time = Cpdfstrftime.current_time () in
|
||||
if pages = [] then error "addtexts: empty page range" else
|
||||
let realfontname = ref fontname in
|
||||
let font =
|
||||
match cpdffont with
|
||||
| Cpdfembed.PreMadeFontPack f -> Some (hd (fst f))
|
||||
| Cpdfembed.EmbedInfo {fontfile; fontname; encoding} ->
|
||||
let embedded = Cpdfembed.embed_truetype pdf ~fontfile ~fontname ~codepoints:[] ~encoding in
|
||||
Some (hd (fst embedded))
|
||||
| Cpdfembed.ExistingNamedFont _ -> None
|
||||
in
|
||||
let fontpdfobj =
|
||||
match font with
|
||||
| Some (Pdftext.StandardFont _ as font) ->
|
||||
|
@ -521,9 +529,8 @@ let
|
|||
!pdf;
|
||||
voffset := !voffset +. (linespacing *. fontsize))
|
||||
lines;
|
||||
begin match embedinfo with
|
||||
| None -> ()
|
||||
| Some (_, fontfile, fontname, encoding) ->
|
||||
begin match cpdffont with
|
||||
| Cpdfembed.EmbedInfo {fontfile; fontname; encoding} ->
|
||||
let charcodes =
|
||||
match Hashtbl.find used fontname with
|
||||
| exception Not_found -> []
|
||||
|
@ -537,6 +544,7 @@ let
|
|||
let objnum = match fontpdfobj with Pdf.Indirect i -> i | _ -> failwith "bad fontpdfobj" in
|
||||
let font = hd (fst (Cpdfembed.embed_truetype !pdf ~fontfile ~fontname ~codepoints ~encoding)) in
|
||||
ignore (Pdftext.write_font ~objnum !pdf font)
|
||||
| _ -> ()
|
||||
end;
|
||||
!pdf
|
||||
|
||||
|
|
|
@ -19,12 +19,11 @@ type justification =
|
|||
position linespacing fontsize underneath text pages orientation
|
||||
relative_to_cropbox midline_adjust topline filename pdf]. For details see cpdfmanual.pdf *)
|
||||
val addtexts :
|
||||
?embedinfo:(Pdf.t * Pdfio.bytes * string * Pdftext.encoding) ->
|
||||
float -> (*linewidth*)
|
||||
bool -> (*outline*)
|
||||
bool -> (*fast*)
|
||||
string -> (*fontname*)
|
||||
Pdftext.font option -> (*font*)
|
||||
Cpdfembed.cpdffont -> (*font*)
|
||||
int -> (* bates number *)
|
||||
int option -> (* bates padding width *)
|
||||
color -> (*colour*)
|
||||
|
|
|
@ -3743,9 +3743,9 @@ let go () =
|
|||
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
||||
write_pdf false (Cpdfdraft.draft args.removeonly args.boxes range pdf)
|
||||
| Some (AddText text) ->
|
||||
(*let pdf = get_single_pdf args.op false in
|
||||
let pdf = get_single_pdf args.op false in
|
||||
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
||||
let cpdffont = embed_font pdf in
|
||||
let cpdffont = embed_font () in
|
||||
warn_prerotate range pdf;
|
||||
let pdf =
|
||||
if args.prerotate then prerotate range pdf else pdf
|
||||
|
@ -3756,13 +3756,12 @@ let go () =
|
|||
in
|
||||
write_pdf false
|
||||
(Cpdfaddtext.addtexts
|
||||
cpdffont args.linewidth args.outline args.fast args.fontname
|
||||
font args.bates args.batespad args.color args.position
|
||||
args.linewidth args.outline args.fast args.fontname
|
||||
cpdffont args.bates args.batespad args.color args.position
|
||||
args.linespacing args.fontsize args.underneath text range
|
||||
args.relative_to_cropbox args.opacity
|
||||
args.justification args.midline args.topline filename
|
||||
args.extract_text_font_size args.coord ~raw:(args.encoding = Raw) pdf)*)
|
||||
()
|
||||
args.extract_text_font_size args.coord ~raw:(args.encoding = Raw) pdf)
|
||||
| Some RemoveText ->
|
||||
let pdf = get_single_pdf args.op false in
|
||||
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
||||
|
|
Loading…
Reference in New Issue