diff --git a/cpdfcommand.ml b/cpdfcommand.ml index db6e65f..f6df9c1 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -220,6 +220,7 @@ type op = | ExtractStream of int | PrintObj of int | Verify of string + | MarkAs of string let string_of_op = function | PrintFontEncoding _ -> "PrintFontEncoding" @@ -363,6 +364,7 @@ let string_of_op = function | ExtractStream _ -> "ExtractStream" | PrintObj _ -> "PrintObj" | Verify _ -> "Verify" + | MarkAs _ -> "MarkAs" (* Inputs: filename, pagespec. *) type input_kind = @@ -883,7 +885,7 @@ let banned banlist = function | AddPageLabels | RemovePageLabels | OutputJSON | OCGCoalesce | OCGRename | OCGList | OCGOrderAll | PrintFontEncoding _ | TableOfContents | Typeset _ | Composition _ | TextWidth _ | SetAnnotations _ | CopyAnnotations _ | ExtractStream _ | PrintObj _ - | Verify _ + | Verify _ | MarkAs _ -> false (* Always allowed *) (* Combine pages is not allowed because we would not know where to get the -recrypt from -- the first or second file? *) @@ -2807,6 +2809,7 @@ and specs = ("-obj", Arg.Int setprintobj, "Print 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"); + ("-marks-as", Arg.String (fun s -> setop (MarkAs s) ()), "Mark as conforming to a standard"); (* These items are undocumented *) ("-debug", Arg.Unit setdebug, ""); ("-debug-crypt", Arg.Unit (fun () -> args.debugcrypt <- true), ""); @@ -4442,6 +4445,14 @@ let go () = else Cpdfua.test_matterhorn_print pdf | _ -> error "Unknown verification type." end + | Some (MarkAs standard) -> + begin match standard with + | "PDF/UA-1" -> + let pdf = get_single_pdf args.op false in + Cpdfua.mark pdf; + write_pdf false pdf + | _ -> error "Unknown standard" + end (* Advise the user if a combination of command line flags makes little sense, or error out if it make no sense at all. *) diff --git a/cpdfmetadata.ml b/cpdfmetadata.ml index 0a72241..34e0e9e 100644 --- a/cpdfmetadata.ml +++ b/cpdfmetadata.ml @@ -56,6 +56,11 @@ let xmp_template = |} +let pdfua_marker = +{| + 1 + "|} + (* Set or replace metadata *) let set_metadata_from_bytes keepversion data pdf = let metadata_stream = diff --git a/cpdfua.ml b/cpdfua.ml index ceba5e6..cc19c56 100644 --- a/cpdfua.ml +++ b/cpdfua.ml @@ -230,3 +230,5 @@ let test_matterhorn_json pdf = (fun (name, error, section, extra) -> `Assoc [("name", `String name); ("section", `String section); ("error", `String error); ("extra", extra)]) (test_matterhorn pdf)) + +let mark pdf = () diff --git a/cpdfua.mli b/cpdfua.mli index b10d9b6..4ca88dd 100644 --- a/cpdfua.mli +++ b/cpdfua.mli @@ -2,3 +2,5 @@ val test_matterhorn_print : Pdf.t -> unit val test_matterhorn_json : Pdf.t -> Cpdfyojson.Safe.t + +val mark : Pdf.t -> unit