Scaffolding for tags

This commit is contained in:
John Whitington 2024-09-15 18:53:59 +01:00
parent de68538857
commit c7a3babea2
3 changed files with 17 additions and 0 deletions

View File

@ -2804,6 +2804,12 @@ let specs =
" Find width of a line of text"); " Find width of a line of text");
("-draw", Arg.Unit setdraw, " Begin drawing"); ("-draw", Arg.Unit setdraw, " Begin drawing");
("-draw-struct-tree", Arg.Unit setdrawstructtree, " Build structure trees when drawing."); ("-draw-struct-tree", Arg.Unit setdrawstructtree, " Build structure trees when drawing.");
("-tag", Arg.String Cpdfdrawcontrol.addtag, " Begin structure item");
("-stag", Arg.String Cpdfdrawcontrol.addstag, " Begin struture branch");
("-end-tag", Arg.Unit Cpdfdrawcontrol.endtag, " End structure item");
("-end-stag", Arg.Unit Cpdfdrawcontrol.endstag, " End structure branch");
("-auto-tags", Arg.Unit (fun _ -> Cpdfdrawcontrol.autotags true), " Auto-tag paragraphs and figures");
("-no-auto-tags", Arg.Unit (fun _ -> Cpdfdrawcontrol.autotags false), " Don't auto-tag paragraphs and figures");
("-rect", Arg.String Cpdfdrawcontrol.addrect, " Draw rectangle"); ("-rect", Arg.String Cpdfdrawcontrol.addrect, " Draw rectangle");
("-to", Arg.String Cpdfdrawcontrol.addto, " Move to"); ("-to", Arg.String Cpdfdrawcontrol.addto, " Move to");
("-line", Arg.String Cpdfdrawcontrol.addline, " Add line to"); ("-line", Arg.String Cpdfdrawcontrol.addline, " Add line to");

View File

@ -95,6 +95,12 @@ let setstroke s =
let setfill s = let setfill s =
addop (Cpdfdraw.SetFill (col_of_string s)) addop (Cpdfdraw.SetFill (col_of_string s))
let addtag t = ()
let addstag t = ()
let endtag () = ()
let endstag () = ()
let autotags b = ()
let addrect s = let addrect s =
let x, y, w, h = Cpdfcoord.parse_rectangle (Pdf.empty ()) s in let x, y, w, h = Cpdfcoord.parse_rectangle (Pdf.empty ()) s in
addop (Cpdfdraw.Rect (x, y, w, h)) addop (Cpdfdraw.Rect (x, y, w, h))

View File

@ -14,6 +14,11 @@ val fontpack_initialised : bool ref
val drawops : (string * Cpdfdraw.drawops list) list ref val drawops : (string * Cpdfdraw.drawops list) list ref
val addop : Cpdfdraw.drawops -> unit val addop : Cpdfdraw.drawops -> unit
val parse_colour : string -> Cpdfaddtext.colour val parse_colour : string -> Cpdfaddtext.colour
val addtag : string -> unit
val addstag : string -> unit
val endtag : unit -> unit
val endstag : unit -> unit
val autotags : bool -> unit
val addrect : string -> unit val addrect : string -> unit
val addto : string -> unit val addto : string -> unit
val addline : string -> unit val addline : string -> unit