Added -topline
This commit is contained in:
parent
e53e49bc96
commit
45603fc725
1
Changes
1
Changes
|
@ -2,6 +2,7 @@ Version 2.2
|
||||||
|
|
||||||
o -keep-l keeps existing linearization status
|
o -keep-l keeps existing linearization status
|
||||||
o -remove-dict-entry te remove the contents of a dictionary entry
|
o -remove-dict-entry te remove the contents of a dictionary entry
|
||||||
|
o -topline in addition to -midline
|
||||||
|
|
||||||
Version 2.1 (November 2014)
|
Version 2.1 (November 2014)
|
||||||
|
|
||||||
|
|
15
cpdf.ml
15
cpdf.ml
|
@ -1696,7 +1696,8 @@ let unescape_string s =
|
||||||
|
|
||||||
let
|
let
|
||||||
addtexts metrics linewidth outline fast fontname font bates colour position linespacing
|
addtexts metrics linewidth outline fast fontname font bates colour position linespacing
|
||||||
fontsize underneath text pages orientation cropbox opacity justification midline filename pdf
|
fontsize underneath text pages orientation cropbox opacity justification
|
||||||
|
midline topline filename pdf
|
||||||
=
|
=
|
||||||
(*flprint "addtexts:\n";
|
(*flprint "addtexts:\n";
|
||||||
iter (Printf.printf "%C ") (explode text);
|
iter (Printf.printf "%C ") (explode text);
|
||||||
|
@ -1749,6 +1750,18 @@ let
|
||||||
| _ ->
|
| _ ->
|
||||||
ops_baseline_adjustment := 0.
|
ops_baseline_adjustment := 0.
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
if topline then
|
||||||
|
begin match font with
|
||||||
|
| Some font ->
|
||||||
|
let baseline_adjustment =
|
||||||
|
(fontsize *. float (Pdfstandard14.baseline_adjustment font) *. 2.0) /. 1000.
|
||||||
|
in
|
||||||
|
ops_baseline_adjustment := baseline_adjustment;
|
||||||
|
voffset := !voffset +. baseline_adjustment
|
||||||
|
| _ ->
|
||||||
|
ops_baseline_adjustment := 0.
|
||||||
|
end
|
||||||
else
|
else
|
||||||
ops_baseline_adjustment := 0.;
|
ops_baseline_adjustment := 0.;
|
||||||
iter
|
iter
|
||||||
|
|
3
cpdf.mli
3
cpdf.mli
|
@ -292,7 +292,7 @@ val calculate_position :
|
||||||
|
|
||||||
(** Call [add_texts metrics linewidth outline fast fontname font bates colour
|
(** Call [add_texts metrics linewidth outline fast fontname font bates colour
|
||||||
position linespacing fontsize underneath text pages orientation
|
position linespacing fontsize underneath text pages orientation
|
||||||
relative_to_cropbox midline_adjust filename pdf]. For details see cpdfmanual.pdf *)
|
relative_to_cropbox midline_adjust topline filename pdf]. For details see cpdfmanual.pdf *)
|
||||||
val addtexts :
|
val addtexts :
|
||||||
bool -> (*metrics*)
|
bool -> (*metrics*)
|
||||||
float -> (*linewidth*)
|
float -> (*linewidth*)
|
||||||
|
@ -313,6 +313,7 @@ val addtexts :
|
||||||
float ->(*opacity*)
|
float ->(*opacity*)
|
||||||
justification ->(*justification*)
|
justification ->(*justification*)
|
||||||
bool ->(*midline adjust?*)
|
bool ->(*midline adjust?*)
|
||||||
|
bool ->(*topline adjust?*)
|
||||||
string ->(*filename*)
|
string ->(*filename*)
|
||||||
Pdf.t ->(*pdf*)
|
Pdf.t ->(*pdf*)
|
||||||
Pdf.t
|
Pdf.t
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
(* cpdf command line tools *)
|
(* cpdf command line tools *)
|
||||||
let demo = false
|
let demo = true
|
||||||
let noncomp = false
|
let noncomp = false
|
||||||
let major_version = 2
|
let major_version = 2
|
||||||
let minor_version = 2
|
let minor_version = 2
|
||||||
let version_date = "(build of 7th January 2015)"
|
let version_date = "(build of 20th January 2015)"
|
||||||
|
|
||||||
open Pdfutil
|
open Pdfutil
|
||||||
open Pdfio
|
open Pdfio
|
||||||
|
@ -316,6 +316,7 @@ type args =
|
||||||
mutable underneath : bool;
|
mutable underneath : bool;
|
||||||
mutable linespacing : float;
|
mutable linespacing : float;
|
||||||
mutable midline : bool;
|
mutable midline : bool;
|
||||||
|
mutable topline : bool;
|
||||||
mutable justification : Cpdf.justification;
|
mutable justification : Cpdf.justification;
|
||||||
mutable bates : int;
|
mutable bates : int;
|
||||||
mutable prerotate : bool;
|
mutable prerotate : bool;
|
||||||
|
@ -394,6 +395,7 @@ let args =
|
||||||
underneath = false;
|
underneath = false;
|
||||||
linespacing = 1.;
|
linespacing = 1.;
|
||||||
midline = false;
|
midline = false;
|
||||||
|
topline = false;
|
||||||
justification = Cpdf.LeftJustify;
|
justification = Cpdf.LeftJustify;
|
||||||
bates = 0;
|
bates = 0;
|
||||||
prerotate = false;
|
prerotate = false;
|
||||||
|
@ -472,6 +474,7 @@ let reset_arguments () =
|
||||||
args.underneath <- false;
|
args.underneath <- false;
|
||||||
args.linespacing <- 1.;
|
args.linespacing <- 1.;
|
||||||
args.midline <- false;
|
args.midline <- false;
|
||||||
|
args.topline <- false;
|
||||||
args.justification <- Cpdf.LeftJustify;
|
args.justification <- Cpdf.LeftJustify;
|
||||||
args.bates <- 0;
|
args.bates <- 0;
|
||||||
args.prerotate <- false;
|
args.prerotate <- false;
|
||||||
|
@ -1127,6 +1130,9 @@ let setlinespacing f =
|
||||||
let setmidline () =
|
let setmidline () =
|
||||||
args.midline <- true
|
args.midline <- true
|
||||||
|
|
||||||
|
let settopline () =
|
||||||
|
args.topline <- true
|
||||||
|
|
||||||
let setscaletofitscale f =
|
let setscaletofitscale f =
|
||||||
args.scale <- f
|
args.scale <- f
|
||||||
|
|
||||||
|
@ -1640,6 +1646,9 @@ and specs =
|
||||||
("-midline",
|
("-midline",
|
||||||
Arg.Unit setmidline,
|
Arg.Unit setmidline,
|
||||||
" Adjust text to midline rather than baseline");
|
" Adjust text to midline rather than baseline");
|
||||||
|
("-topline",
|
||||||
|
Arg.Unit settopline,
|
||||||
|
" Adjust text to topline rather than baseline");
|
||||||
("-relative-to-cropbox",
|
("-relative-to-cropbox",
|
||||||
Arg.Unit setrelativetocropbox,
|
Arg.Unit setrelativetocropbox,
|
||||||
" Add text relative to Crop Box not Media Box");
|
" Add text relative to Crop Box not Media Box");
|
||||||
|
@ -3458,7 +3467,7 @@ let go () =
|
||||||
false args.linewidth args.outline args.fast args.fontname font args.bates
|
false args.linewidth args.outline args.fast args.fontname font args.bates
|
||||||
args.color args.position args.linespacing args.fontsize
|
args.color args.position args.linespacing args.fontsize
|
||||||
args.underneath text range args.orientation args.relative_to_cropbox args.opacity
|
args.underneath text range args.orientation args.relative_to_cropbox args.opacity
|
||||||
args.justification args.midline filename pdf)
|
args.justification args.midline args.topline filename 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 pdf (get_pagespec ()) in
|
let range = parse_pagespec pdf (get_pagespec ()) in
|
||||||
|
|
Loading…
Reference in New Issue