mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2025-06-05 22:09:39 +02:00
Scaffolding for -remove-obj
This commit is contained in:
@ -223,6 +223,7 @@ type op =
|
||||
| ReplaceStream of string
|
||||
| PrintObj of string
|
||||
| ReplaceObj of string * string
|
||||
| RemoveObj of string
|
||||
| Verify of string
|
||||
| MarkAs of Cpdfua.subformat
|
||||
| RemoveMark of Cpdfua.subformat
|
||||
@ -393,6 +394,7 @@ let string_of_op = function
|
||||
| Redact -> "Redact"
|
||||
| Rasterize -> "Rasterize"
|
||||
| OutputImage -> "OutputImage"
|
||||
| RemoveObj _ -> "RemoveObj"
|
||||
|
||||
(* Inputs: filename, pagespec. *)
|
||||
type input_kind =
|
||||
@ -964,7 +966,7 @@ let banned banlist = function
|
||||
| ExtractText | ExtractImages | ExtractFontFile _
|
||||
| AddPageLabels | RemovePageLabels | OutputJSON | OCGCoalesce
|
||||
| OCGRename | OCGList | OCGOrderAll | PrintFontEncoding _ | TableOfContents | Typeset _ | Composition _
|
||||
| TextWidth _ | SetAnnotations _ | CopyAnnotations _ | ExtractStream _ | ReplaceStream _ | PrintObj _ | ReplaceObj _
|
||||
| TextWidth _ | SetAnnotations _ | CopyAnnotations _ | ExtractStream _ | ReplaceStream _ | PrintObj _ | ReplaceObj _ | RemoveObj _
|
||||
| Verify _ | MarkAs _ | RemoveMark _ | ExtractStructTree | ReplaceStructTree _ | SetLanguage _
|
||||
| PrintStructTree | Rasterize | OutputImage | RemoveStructTree | MarkAsArtifact
|
||||
-> false (* Always allowed *)
|
||||
@ -3032,6 +3034,7 @@ let specs =
|
||||
("-obj", Arg.String setprintobj, " Print object");
|
||||
("-obj-json", Arg.String setprintobjjson, " Print object in JSON format");
|
||||
("-replace-obj", Arg.String setreplaceobj, " Replace object");
|
||||
("-remove-obj", Arg.String (fun s -> setop (RemoveObj s) ()), " Remove object");
|
||||
("-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-single", Arg.String (fun s -> args.verify_single <- Some s), " Verify a single test");
|
||||
@ -4866,6 +4869,9 @@ let go () =
|
||||
let pdfobj = pdf_or_json b in
|
||||
Cpdftweak.replace_obj pdf a pdfobj;
|
||||
write_pdf false pdf
|
||||
| Some (RemoveObj s) ->
|
||||
let pdf = get_single_pdf args.op true in
|
||||
Cpdftweak.remove_obj pdf s
|
||||
| Some (Verify standard) ->
|
||||
begin match standard with
|
||||
| "PDF/UA-1(matterhorn)" ->
|
||||
|
@ -313,6 +313,8 @@ let replace_obj pdf objspec obj =
|
||||
try Pdf.replace_chain pdf (split_chain objspec) obj with
|
||||
_ -> raise (Pdf.PDFError "Chain not found")
|
||||
|
||||
let remove_obj pdf objspec = ()
|
||||
|
||||
(* Replace a stream from a file e.g 4=data.dat replaces contents of object 4.
|
||||
The stream dictionary is altered only to correct the length. *)
|
||||
let replace_stream pdf objspec filename =
|
||||
|
@ -32,3 +32,6 @@ val replace_stream : Pdf.t -> string -> string -> unit
|
||||
|
||||
(** [replace_obj pdf objspec obj] replace the object at [objspec] (which must exist) with [obj]. *)
|
||||
val replace_obj : Pdf.t -> string -> Pdf.pdfobject -> unit
|
||||
|
||||
(** [remove_obj pdf objspec] removes the object described by the object specification. *)
|
||||
val remove_obj : Pdf.t -> string -> unit
|
||||
|
Reference in New Issue
Block a user