Scaffolding for -elt-info
This commit is contained in:
parent
01fcd13251
commit
9e1cf6f78e
|
@ -2841,7 +2841,10 @@ let specs =
|
|||
("-artifact", Arg.Unit (fun _ -> Cpdfdrawcontrol.artifact ()), " Begin an artifact");
|
||||
("-end-artifact", Arg.Unit (fun _ -> Cpdfdrawcontrol.endartifact ()), "End an artifact");
|
||||
("-no-auto-artifacts", Arg.Unit (fun _ -> Cpdfdrawcontrol.autoartifacts false), " Don't mark untagged content as artifacts");
|
||||
("-eltinfo", Arg.String (fun s -> Cpdfdrawcontrol.eltinfo s), " Add element information");
|
||||
("-end-eltinfo", Arg.String (fun s -> Cpdfdrawcontrol.endeltinfo s), " Erase element information");
|
||||
("-namespace", Arg.String (fun s -> Cpdfdrawcontrol.addnamespace (expand_namespace s)), " Set the structure tree namespace");
|
||||
("-rolemap", Arg.String (fun s -> Cpdfdrawcontrol.setrolemap s), " Set a role map");
|
||||
("-rect", Arg.String Cpdfdrawcontrol.addrect, " Draw rectangle");
|
||||
("-to", Arg.String Cpdfdrawcontrol.addto, " Move to");
|
||||
("-line", Arg.String Cpdfdrawcontrol.addline, " Add line to");
|
||||
|
|
19
cpdfdraw.ml
19
cpdfdraw.ml
|
@ -5,6 +5,8 @@ let do_add_artifacts = ref true
|
|||
|
||||
let do_auto_tag = ref true
|
||||
|
||||
let rolemap = ref ""
|
||||
|
||||
type colspec =
|
||||
NoCol
|
||||
| RGB of float * float * float
|
||||
|
@ -65,6 +67,8 @@ type drawops =
|
|||
| BeginArtifact
|
||||
| EndArtifact
|
||||
| Namespace of string
|
||||
| EltInfo of string * string
|
||||
| EndEltInfo of string
|
||||
|
||||
(*let rec string_of_drawop = function
|
||||
| Qq o -> "Qq (" ^ string_of_drawops o ^ ")"
|
||||
|
@ -721,11 +725,16 @@ let write_structure_tree pdf st =
|
|||
| [] -> []
|
||||
| ns -> [("/Namespaces", Pdf.Array (map (function (_, objnum) -> Pdf.Indirect objnum) ns))]
|
||||
in
|
||||
Pdf.Dictionary
|
||||
(namespaces @
|
||||
[("/Type", Pdf.Name "/StructTreeRoot");
|
||||
("/ParentTree", Pdf.Indirect (Pdf.addobj pdf (Pdftree.build_name_tree true pdf parentmap)));
|
||||
("/K", Pdf.Array items)])
|
||||
let rolemap =
|
||||
match !rolemap with
|
||||
| "" -> []
|
||||
| s -> [("/RoleMap", Pdfread.parse_single_object ("<<" ^ s ^ ">>"))]
|
||||
in
|
||||
Pdf.Dictionary
|
||||
(rolemap @ namespaces @
|
||||
[("/Type", Pdf.Name "/StructTreeRoot");
|
||||
("/ParentTree", Pdf.Indirect (Pdf.addobj pdf (Pdftree.build_name_tree true pdf parentmap)));
|
||||
("/K", Pdf.Array items)])
|
||||
in
|
||||
Pdf.addobj_given_num pdf (struct_tree_root, st);
|
||||
Pdf.replace_chain pdf ["/Root"] ("/StructTreeRoot", (Pdf.Indirect struct_tree_root))
|
||||
|
|
|
@ -60,11 +60,15 @@ type drawops =
|
|||
| BeginArtifact
|
||||
| EndArtifact
|
||||
| Namespace of string
|
||||
| EltInfo of string * string
|
||||
| EndEltInfo of string
|
||||
|
||||
val do_add_artifacts : bool ref
|
||||
|
||||
val do_auto_tag : bool ref
|
||||
|
||||
val rolemap : string ref
|
||||
|
||||
(** Calling [draw fast underneath filename bates batespad range pdf drawops] draws on
|
||||
top of all the pages in the range. *)
|
||||
val draw : struct_tree:bool ->
|
||||
|
|
|
@ -123,6 +123,20 @@ let endartifact () =
|
|||
let addnamespace s =
|
||||
addop (Cpdfdraw.Namespace s)
|
||||
|
||||
let eltinfo s =
|
||||
let k, v =
|
||||
match String.split_on_char '=' s with
|
||||
| [h; t] -> (h, t)
|
||||
| _ -> error "Bad -eltinfo format"
|
||||
in
|
||||
addop (Cpdfdraw.EltInfo (k, v))
|
||||
|
||||
let endeltinfo s =
|
||||
addop (Cpdfdraw.EndEltInfo s)
|
||||
|
||||
let setrolemap s =
|
||||
Cpdfdraw.rolemap := s
|
||||
|
||||
let addrect s =
|
||||
let x, y, w, h = Cpdfcoord.parse_rectangle (Pdf.empty ()) s in
|
||||
addop (Cpdfdraw.Rect (x, y, w, h))
|
||||
|
|
|
@ -20,7 +20,10 @@ val addstag : string -> unit
|
|||
val endtag : unit -> unit
|
||||
val endstag : unit -> unit
|
||||
val autotags : bool -> unit
|
||||
val eltinfo : string -> unit
|
||||
val endeltinfo : string -> unit
|
||||
val addnamespace : string -> unit
|
||||
val setrolemap : string -> unit
|
||||
val artifact : unit -> unit
|
||||
val endartifact : unit -> unit
|
||||
val autoartifacts : bool -> unit
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
%Document -rolemap
|
||||
%Document -eltinfo X=, -end-eltinfo X
|
||||
%Document -stretch
|
||||
%Document -redact
|
||||
%Document ?x0 y0 x1 y1 rectangle specifications
|
||||
|
|
Loading…
Reference in New Issue