Scaffold for -replace-obj
This commit is contained in:
parent
1386d4d0f1
commit
8a22c7181d
|
@ -219,6 +219,7 @@ type op =
|
||||||
| ProcessImages
|
| ProcessImages
|
||||||
| ExtractStream of string
|
| ExtractStream of string
|
||||||
| PrintObj of string
|
| PrintObj of string
|
||||||
|
| ReplaceObj of string * string
|
||||||
| Verify of string
|
| Verify of string
|
||||||
| MarkAs of string
|
| MarkAs of string
|
||||||
| RemoveMark of string
|
| RemoveMark of string
|
||||||
|
@ -368,6 +369,7 @@ let string_of_op = function
|
||||||
| ProcessImages -> "ProcessImages"
|
| ProcessImages -> "ProcessImages"
|
||||||
| ExtractStream _ -> "ExtractStream"
|
| ExtractStream _ -> "ExtractStream"
|
||||||
| PrintObj _ -> "PrintObj"
|
| PrintObj _ -> "PrintObj"
|
||||||
|
| ReplaceObj _ -> "ReplaceObj"
|
||||||
| Verify _ -> "Verify"
|
| Verify _ -> "Verify"
|
||||||
| MarkAs _ -> "MarkAs"
|
| MarkAs _ -> "MarkAs"
|
||||||
| RemoveMark _ -> "RemoveMark"
|
| RemoveMark _ -> "RemoveMark"
|
||||||
|
@ -897,7 +899,7 @@ let banned banlist = function
|
||||||
| ExtractText | ExtractImages | ExtractFontFile _
|
| ExtractText | ExtractImages | ExtractFontFile _
|
||||||
| AddPageLabels | RemovePageLabels | OutputJSON | OCGCoalesce
|
| AddPageLabels | RemovePageLabels | OutputJSON | OCGCoalesce
|
||||||
| OCGRename | OCGList | OCGOrderAll | PrintFontEncoding _ | TableOfContents | Typeset _ | Composition _
|
| OCGRename | OCGList | OCGOrderAll | PrintFontEncoding _ | TableOfContents | Typeset _ | Composition _
|
||||||
| TextWidth _ | SetAnnotations _ | CopyAnnotations _ | ExtractStream _ | PrintObj _
|
| TextWidth _ | SetAnnotations _ | CopyAnnotations _ | ExtractStream _ | PrintObj _ | ReplaceObj _
|
||||||
| Verify _ | MarkAs _ | RemoveMark _ | ExtractStructTree | ReplaceStructTree _ | SetLanguage _
|
| Verify _ | MarkAs _ | RemoveMark _ | ExtractStructTree | ReplaceStructTree _ | SetLanguage _
|
||||||
| PrintStructTree
|
| PrintStructTree
|
||||||
-> false (* Always allowed *)
|
-> false (* Always allowed *)
|
||||||
|
@ -1863,6 +1865,11 @@ let setextractstreamdecomp s =
|
||||||
let setprintobj s =
|
let setprintobj s =
|
||||||
args.op <- Some (PrintObj s)
|
args.op <- Some (PrintObj s)
|
||||||
|
|
||||||
|
let setreplaceobj s =
|
||||||
|
match String.split_on_char '=' s with
|
||||||
|
| [a; b] -> args.op <- Some (ReplaceObj (a, b))
|
||||||
|
| _ -> error "replace_obj: bad specification"
|
||||||
|
|
||||||
let specs =
|
let specs =
|
||||||
[("-version",
|
[("-version",
|
||||||
Arg.Unit (setop Version),
|
Arg.Unit (setop Version),
|
||||||
|
@ -2826,6 +2833,7 @@ let specs =
|
||||||
("-extract-stream", Arg.String setextractstream, " Extract a stream");
|
("-extract-stream", Arg.String setextractstream, " Extract a stream");
|
||||||
("-extract-stream-decompress", Arg.String setextractstreamdecomp, " Extract a stream, decompressing");
|
("-extract-stream-decompress", Arg.String setextractstreamdecomp, " Extract a stream, decompressing");
|
||||||
("-obj", Arg.String setprintobj, " Print object");
|
("-obj", Arg.String setprintobj, " Print object");
|
||||||
|
("-replace-obj", Arg.String setreplaceobj, "Replace object");
|
||||||
("-json", Arg.Unit (fun () -> args.format_json <- true), " Format output as JSON");
|
("-json", Arg.Unit (fun () -> args.format_json <- true), " Format output as JSON");
|
||||||
("-verify", Arg.String (fun s -> setop (Verify s) ()), " Verify conformance to a standard");
|
("-verify", Arg.String (fun s -> setop (Verify s) ()), " Verify conformance to a standard");
|
||||||
("-verify-single", Arg.String (fun s -> args.verify_single <- Some s), " Verify a single test");
|
("-verify-single", Arg.String (fun s -> args.verify_single <- Some s), " Verify a single test");
|
||||||
|
@ -3466,6 +3474,9 @@ let print_obj pdf objspec =
|
||||||
| [] -> simple_obj 0
|
| [] -> simple_obj 0
|
||||||
| _ -> simple_obj (int_of_string objspec)
|
| _ -> simple_obj (int_of_string objspec)
|
||||||
|
|
||||||
|
let replace_obj pdf objspec obj =
|
||||||
|
()
|
||||||
|
|
||||||
(* Main function *)
|
(* Main function *)
|
||||||
let go () =
|
let go () =
|
||||||
check_bookmarks_mistake ();
|
check_bookmarks_mistake ();
|
||||||
|
@ -4490,6 +4501,9 @@ let go () =
|
||||||
| Some (PrintObj s) ->
|
| Some (PrintObj s) ->
|
||||||
let pdf = get_single_pdf args.op true in
|
let pdf = get_single_pdf args.op true in
|
||||||
print_obj pdf s
|
print_obj pdf s
|
||||||
|
| Some (ReplaceObj (a, b)) ->
|
||||||
|
let pdf = get_single_pdf args.op false in
|
||||||
|
replace_obj pdf a b
|
||||||
| Some (Verify standard) ->
|
| Some (Verify standard) ->
|
||||||
begin match standard with
|
begin match standard with
|
||||||
| "PDF/UA-1(matterhorn)" ->
|
| "PDF/UA-1(matterhorn)" ->
|
||||||
|
|
Loading…
Reference in New Issue