Support for PDF/UA-2 markers
This commit is contained in:
parent
ab7073cad8
commit
b0c630d822
|
@ -4502,11 +4502,15 @@ let go () =
|
||||||
let pdf = get_single_pdf args.op false in
|
let pdf = get_single_pdf args.op false in
|
||||||
Cpdfua.mark pdf;
|
Cpdfua.mark pdf;
|
||||||
write_pdf false 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"
|
| _ -> error "Unknown standard"
|
||||||
end
|
end
|
||||||
| Some (RemoveMark standard) ->
|
| Some (RemoveMark standard) ->
|
||||||
begin match standard with
|
begin match standard with
|
||||||
| "PDF/UA-1" ->
|
| "PDF/UA-1" | "PDF/UA-2" ->
|
||||||
let pdf = get_single_pdf args.op false in
|
let pdf = get_single_pdf args.op false in
|
||||||
Cpdfua.remove_mark pdf;
|
Cpdfua.remove_mark pdf;
|
||||||
write_pdf false pdf
|
write_pdf false pdf
|
||||||
|
|
12
cpdfua.ml
12
cpdfua.ml
|
@ -1351,6 +1351,10 @@ let test_matterhorn_json pdf testname =
|
||||||
let pdfua_marker =
|
let pdfua_marker =
|
||||||
Cpdfmetadata.(E (((rdf, "Description"), [((rdf, "about"), ""); ((Cpdfxmlm.ns_xmlns, "pdfuaid"), pdfuaid)]), [E (((pdfuaid, "part"), []), [D "1"])]))
|
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
|
let rec insert_as_rdf_description fragment = function
|
||||||
| Cpdfmetadata.E (((_, "RDF"), _) as rdftag, rdfs) ->
|
| Cpdfmetadata.E (((_, "RDF"), _) as rdftag, rdfs) ->
|
||||||
Cpdfmetadata.E (rdftag, fragment::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 rec delete_pdfua_marker tree =
|
||||||
let is_pdfuaid = function
|
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
|
| _ -> false
|
||||||
in
|
in
|
||||||
match tree with
|
match tree with
|
||||||
|
@ -1370,7 +1374,7 @@ let rec delete_pdfua_marker tree =
|
||||||
Cpdfmetadata.E (x, map delete_pdfua_marker children)
|
Cpdfmetadata.E (x, map delete_pdfua_marker children)
|
||||||
| x -> x
|
| 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
|
let pdf2 = if Cpdfmetadata.get_metadata pdf = None then Cpdfmetadata.create_metadata pdf else pdf in
|
||||||
pdf.Pdf.objects <- pdf2.Pdf.objects;
|
pdf.Pdf.objects <- pdf2.Pdf.objects;
|
||||||
pdf.Pdf.trailerdict <- pdf2.Pdf.trailerdict;
|
pdf.Pdf.trailerdict <- pdf2.Pdf.trailerdict;
|
||||||
|
@ -1390,6 +1394,10 @@ let mark pdf =
|
||||||
pdf.Pdf.root <- pdf3.Pdf.root
|
pdf.Pdf.root <- pdf3.Pdf.root
|
||||||
| None -> assert false
|
| None -> assert false
|
||||||
|
|
||||||
|
let mark = mark_inner pdfua_marker
|
||||||
|
|
||||||
|
let mark2 year = mark_inner (pdfua2_marker year)
|
||||||
|
|
||||||
let remove_mark pdf =
|
let remove_mark pdf =
|
||||||
match Cpdfmetadata.get_metadata pdf with
|
match Cpdfmetadata.get_metadata pdf with
|
||||||
| Some metadata ->
|
| Some metadata ->
|
||||||
|
|
|
@ -5,6 +5,8 @@ val test_matterhorn_json : Pdf.t -> string -> Cpdfyojson.Safe.t
|
||||||
|
|
||||||
val mark : Pdf.t -> unit
|
val mark : Pdf.t -> unit
|
||||||
|
|
||||||
|
val mark2 : int -> Pdf.t -> unit
|
||||||
|
|
||||||
val remove_mark : Pdf.t -> unit
|
val remove_mark : Pdf.t -> unit
|
||||||
|
|
||||||
val extract_struct_tree : Pdf.t -> Cpdfyojson.Safe.t
|
val extract_struct_tree : Pdf.t -> Cpdfyojson.Safe.t
|
||||||
|
|
Loading…
Reference in New Issue