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