diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 6414e60..eb41b7d 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -2056,17 +2056,21 @@ let addsopacity f = let addtext s = let font = match args.font with StandardFont s -> s | _ -> error "-text: not a standard font" in addop (Cpdfdraw.Font (font, args.fontsize)); + addop (Cpdfdraw.SetLeading (args.fontsize *. 1.2)); addop (Cpdfdraw.Text s) -let addblock s = - addop (Cpdfdraw.Block ()) - let addurl s = addop (Cpdfdraw.URL s) let addendurl () = addop Cpdfdraw.EndURL +let addleading f = + addop (Cpdfdraw.SetLeading f) + +let addnewline () = + addop Cpdfdraw.Newline + let setstderrtostdout () = Pdfe.logger := (fun s -> print_string s; flush stdout) @@ -2905,12 +2909,12 @@ and specs = ("-opacity", Arg.Float addopacity, " Set opacity"); ("-sopacity", Arg.Float addsopacity, " Set stroke opacity"); ("-text", Arg.String addtext, " Draw text and move position. "); - ("-block", Arg.String addblock, " Set up text block"); ("-url", Arg.String addurl, " Begin URL"); ("-endurl", Arg.Unit addendurl, " End URL"); + ("-leading", Arg.Float addleading, " Set leading"); + ("-nl", Arg.Unit addnewline, " New line"); (* Getting information before or whilst drawing *) - (*("-textwidth", ...., "Get width of line of text"); - ("-blocklines", ...., "Get number of lines of text block");*) + (*("-textwidth", ...., "Get width of line of text");*) (* These items are undocumented *) ("-debug", Arg.Unit setdebug, ""); ("-debug-crypt", Arg.Unit setdebugcrypt, ""); diff --git a/cpdfdraw.ml b/cpdfdraw.ml index 5995fe0..1bc2c44 100644 --- a/cpdfdraw.ml +++ b/cpdfdraw.ml @@ -41,7 +41,8 @@ type drawops = | SOpacity of float | Font of Pdftext.standard_font * float | Text of string - | Block of unit (* to fix *) + | Newline + | SetLeading of float | URL of string | EndURL @@ -136,6 +137,10 @@ let rec ops_of_drawop pdf = function implode (map char_of_int (option_map (Pdftext.charcode_extractor_of_font_real !current_font) (Pdftext.codepoints_of_utf8 s))) in [Pdfops.Op_BT; Pdfops.Op_Tj charcodes; Pdfops.Op_ET] + | SetLeading f -> + [Pdfops.Op_TL f] + | Newline -> + [Pdfops.Op_T'] and ops_of_drawops pdf drawops = flatten (map (ops_of_drawop pdf) drawops) diff --git a/cpdfdraw.mli b/cpdfdraw.mli index af5c20f..9b73492 100644 --- a/cpdfdraw.mli +++ b/cpdfdraw.mli @@ -39,7 +39,8 @@ type drawops = | SOpacity of float | Font of Pdftext.standard_font * float | Text of string - | Block of unit (* to fix *) + | Newline + | SetLeading of float | URL of string | EndURL