From c7a3babea27983b091973846b37de5cc9d95e513 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Sun, 15 Sep 2024 18:53:59 +0100 Subject: [PATCH] Scaffolding for tags --- cpdfcommand.ml | 6 ++++++ cpdfdrawcontrol.ml | 6 ++++++ cpdfdrawcontrol.mli | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 3e23bf4..801f323 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -2804,6 +2804,12 @@ let specs = " Find width of a line of text"); ("-draw", Arg.Unit setdraw, " Begin 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"); ("-to", Arg.String Cpdfdrawcontrol.addto, " Move to"); ("-line", Arg.String Cpdfdrawcontrol.addline, " Add line to"); diff --git a/cpdfdrawcontrol.ml b/cpdfdrawcontrol.ml index 1591f8d..d69e41e 100644 --- a/cpdfdrawcontrol.ml +++ b/cpdfdrawcontrol.ml @@ -95,6 +95,12 @@ let setstroke s = let setfill 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 x, y, w, h = Cpdfcoord.parse_rectangle (Pdf.empty ()) s in addop (Cpdfdraw.Rect (x, y, w, h)) diff --git a/cpdfdrawcontrol.mli b/cpdfdrawcontrol.mli index 74f4ad1..789fba7 100644 --- a/cpdfdrawcontrol.mli +++ b/cpdfdrawcontrol.mli @@ -14,6 +14,11 @@ val fontpack_initialised : bool ref val drawops : (string * Cpdfdraw.drawops list) list ref val addop : Cpdfdraw.drawops -> unit 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 addto : string -> unit val addline : string -> unit