diff --git a/Changes b/Changes index 812d149..1cca564 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ 2.9 (to come) +New features: + +* -remove-struct-tree removes whole structure tree + Extended features: o -obj JSON output diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 2eba76a..ab32cb3 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -229,6 +229,7 @@ type op = | PrintStructTree | ExtractStructTree | ReplaceStructTree of string + | RemoveStructTree | SetLanguage of string | Redact | Rasterize @@ -385,6 +386,7 @@ let string_of_op = function | PrintStructTree -> "PrintStructTree" | ExtractStructTree -> "ExtractStructTree" | ReplaceStructTree _ -> "ReplaceStructTree" + | RemoveStructTree -> "RemoveStructTree" | SetLanguage _ -> "SetLanguage" | Redact -> "Redact" | Rasterize -> "Rasterize" @@ -959,7 +961,7 @@ let banned banlist = function | OCGRename | OCGList | OCGOrderAll | PrintFontEncoding _ | TableOfContents | Typeset _ | Composition _ | TextWidth _ | SetAnnotations _ | CopyAnnotations _ | ExtractStream _ | ReplaceStream _ | PrintObj _ | ReplaceObj _ | Verify _ | MarkAs _ | RemoveMark _ | ExtractStructTree | ReplaceStructTree _ | SetLanguage _ - | PrintStructTree | Rasterize | OutputImage + | PrintStructTree | Rasterize | OutputImage | RemoveStructTree -> false (* Always allowed *) (* Combine pages is not allowed because we would not know where to get the -recrypt from -- the first or second file? *) @@ -4891,6 +4893,10 @@ let go () = let json = Cpdfyojson.Safe.from_file s in Cpdfua.replace_struct_tree pdf json; write_pdf false pdf + | Some RemoveStructTree -> + let pdf = get_single_pdf args.op false in + Cpdfua.remove_struct_tree pdf; + write_pdf false pdf | Some (SetLanguage s) -> let pdf = get_single_pdf args.op false in Cpdfmetadata.set_language pdf s; diff --git a/cpdfmanual.pdf b/cpdfmanual.pdf index bdde6e3..00edfdf 100644 Binary files a/cpdfmanual.pdf and b/cpdfmanual.pdf differ diff --git a/cpdfua.ml b/cpdfua.ml index 1fc2b20..e296d7c 100644 --- a/cpdfua.ml +++ b/cpdfua.ml @@ -1850,3 +1850,5 @@ let create_pdfua2 title pagesize pages = let pdf = {pdf with Pdf.major = 2; Pdf.minor = 0} in mark2 2024 pdf; pdf + +let remove_struct_tree pdf = () diff --git a/cpdfua.mli b/cpdfua.mli index b2912ae..8d1d1b5 100644 --- a/cpdfua.mli +++ b/cpdfua.mli @@ -31,6 +31,9 @@ val extract_struct_tree : Pdf.t -> Cpdfyojson.Safe.t (** Reapply an edited JSON structure tree to its PDF. *) val replace_struct_tree : Pdf.t -> Cpdfyojson.Safe.t -> unit +(** Remove a structure tree entirely from a file, including unmarking marked content. *) +val remove_struct_tree : Pdf.t -> unit + (** Make a blank PDF/UA-1 PDF given a title, paper size, and number of pages. *) val create_pdfua1 : string -> Pdfpaper.t -> int -> Pdf.t