diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 53cd1ed..5a12448 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -4502,11 +4502,15 @@ let go () = let pdf = get_single_pdf args.op false in Cpdfua.mark pdf; write_pdf false pdf + | "PDF/UA-2" -> + let pdf = get_single_pdf args.op false in + Cpdfua.mark2 2024 pdf; + write_pdf false pdf | _ -> error "Unknown standard" end | Some (RemoveMark standard) -> begin match standard with - | "PDF/UA-1" -> + | "PDF/UA-1" | "PDF/UA-2" -> let pdf = get_single_pdf args.op false in Cpdfua.remove_mark pdf; write_pdf false pdf diff --git a/cpdfua.ml b/cpdfua.ml index 6ae466a..a45c92a 100644 --- a/cpdfua.ml +++ b/cpdfua.ml @@ -1351,6 +1351,10 @@ let test_matterhorn_json pdf testname = let pdfua_marker = Cpdfmetadata.(E (((rdf, "Description"), [((rdf, "about"), ""); ((Cpdfxmlm.ns_xmlns, "pdfuaid"), pdfuaid)]), [E (((pdfuaid, "part"), []), [D "1"])])) +let pdfua2_marker year = + Cpdfmetadata.(E (((rdf, "Description"), [((rdf, "about"), ""); ((Cpdfxmlm.ns_xmlns, "pdfuaid"), pdfuaid)]), [E (((pdfuaid, "part"), []), [D "2"]); + E (((pdfuaid, "rev"), []), [D (string_of_int year)])])) + let rec insert_as_rdf_description fragment = function | Cpdfmetadata.E (((_, "RDF"), _) as rdftag, rdfs) -> Cpdfmetadata.E (rdftag, fragment::rdfs) @@ -1360,7 +1364,7 @@ let rec insert_as_rdf_description fragment = function let rec delete_pdfua_marker tree = let is_pdfuaid = function - | Cpdfmetadata.E (((pdfuaid, "part"), _), _) when pdfuaid = Cpdfmetadata.pdfuaid -> true + | Cpdfmetadata.E (((pdfuaid, ("part" | "rev" | "amd" | "corr")), _), _) when pdfuaid = Cpdfmetadata.pdfuaid -> true | _ -> false in match tree with @@ -1370,7 +1374,7 @@ let rec delete_pdfua_marker tree = Cpdfmetadata.E (x, map delete_pdfua_marker children) | x -> x -let mark pdf = +let mark_inner pdfua_marker pdf = let pdf2 = if Cpdfmetadata.get_metadata pdf = None then Cpdfmetadata.create_metadata pdf else pdf in pdf.Pdf.objects <- pdf2.Pdf.objects; pdf.Pdf.trailerdict <- pdf2.Pdf.trailerdict; @@ -1390,6 +1394,10 @@ let mark pdf = pdf.Pdf.root <- pdf3.Pdf.root | None -> assert false +let mark = mark_inner pdfua_marker + +let mark2 year = mark_inner (pdfua2_marker year) + let remove_mark pdf = match Cpdfmetadata.get_metadata pdf with | Some metadata -> diff --git a/cpdfua.mli b/cpdfua.mli index ca9ddab..a2c9876 100644 --- a/cpdfua.mli +++ b/cpdfua.mli @@ -5,6 +5,8 @@ val test_matterhorn_json : Pdf.t -> string -> Cpdfyojson.Safe.t val mark : Pdf.t -> unit +val mark2 : int -> Pdf.t -> unit + val remove_mark : Pdf.t -> unit val extract_struct_tree : Pdf.t -> Cpdfyojson.Safe.t