PDF/UA command line expansions gone
This commit is contained in:
parent
e1dc48c178
commit
46f2bb0171
|
@ -2670,7 +2670,7 @@ let specs =
|
|||
Arg.String (fun s -> args.subformat <- Some Cpdfua.PDFUA1; args.title <- Some s; setop CreatePDF ()),
|
||||
" Create a new PDF/UA-1 with the given title");
|
||||
("-create-pdf-ua-2",
|
||||
Arg.String (fun s -> args.subformat <- Some Cpdfua.PDFUA1; args.title <- Some s; setop CreatePDF ()),
|
||||
Arg.String (fun s -> args.subformat <- Some Cpdfua.PDFUA2; args.title <- Some s; setop CreatePDF ()),
|
||||
" Create a new PDF/UA-2 with the given title");
|
||||
("-create-pdf-pages",
|
||||
Arg.Int setcreatepdfpages,
|
||||
|
@ -3556,28 +3556,6 @@ let print_obj pdf objspec =
|
|||
| [] -> simple_obj 0
|
||||
| _ -> simple_obj (int_of_string objspec)
|
||||
|
||||
(* Empty string is trailerdict. Begins with / and it's a chain separated by commas. *)
|
||||
let replace_obj pdf objspec obj =
|
||||
let rec find_max_existing to_fake chain =
|
||||
if chain = [] then (chain, to_fake) else
|
||||
match Pdf.lookup_chain pdf pdf.Pdf.trailerdict chain with
|
||||
| None -> find_max_existing (hd (rev chain)::to_fake) (rev (tl (rev chain)))
|
||||
| _ -> (chain, to_fake)
|
||||
in
|
||||
let rec wrap_obj obj = function
|
||||
| [] -> obj
|
||||
| h::t -> Pdf.Dictionary [(h, wrap_obj obj t)]
|
||||
in
|
||||
let chain, to_fake = find_max_existing [] (split_chain objspec) in
|
||||
let chain, key, obj =
|
||||
match to_fake with
|
||||
| [] -> (rev (tl (rev chain)), hd (rev chain), obj)
|
||||
| h::t -> (chain, h, wrap_obj obj t)
|
||||
in
|
||||
if chain = [] then
|
||||
pdf.Pdf.trailerdict <- Pdf.add_dict_entry pdf.Pdf.trailerdict key obj
|
||||
else
|
||||
Pdf.replace_chain pdf chain (key, obj)
|
||||
|
||||
(* Main function *)
|
||||
let go () =
|
||||
|
@ -4624,7 +4602,7 @@ let go () =
|
|||
| Some (ReplaceObj (a, b)) ->
|
||||
let pdf = get_single_pdf args.op false in
|
||||
let pdfobj = Cpdfjson.object_of_json (Cpdfyojson.Safe.from_string b) in
|
||||
replace_obj pdf a pdfobj;
|
||||
Pdf.replace_obj pdf a pdfobj;
|
||||
write_pdf false pdf
|
||||
| Some (Verify standard) ->
|
||||
begin match standard with
|
||||
|
|
42
cpdfua.ml
42
cpdfua.ml
|
@ -1604,32 +1604,26 @@ let print_struct_tree pdf =
|
|||
~get_children:(fun (E2 (_, _, cs)) -> cs)
|
||||
(remove_empty (remove_slashes st)))
|
||||
|
||||
let cpdfua_args title =
|
||||
[ "-create-pdf";
|
||||
"AND"; "-set-title"; title;
|
||||
"AND"; "-create-metadata";
|
||||
"AND"; "-set-language"; "en-US";
|
||||
"AND"; "-display-doc-title"; "true";
|
||||
"AND"; "-replace-obj"; "/Root/MarkInfo/Marked=true";
|
||||
"AND"; "-replace-obj"; "/Root/StructTreeRoot/Type={\"N\":\"/StructTreeRoot\"}";
|
||||
"AND"; "-set-version"; "7";
|
||||
"AND"; "-mark-as"; "PDF/UA-1"]
|
||||
|
||||
let create_cpdfua1 title pagesize pages =
|
||||
let pdf = Cpdfcreate.blank_document_paper pagesize pages in
|
||||
pdf
|
||||
|
||||
let cpdfua2_args title =
|
||||
[ "-create-pdf";
|
||||
"AND"; "-set-title"; title;
|
||||
"AND"; "-create-metadata";
|
||||
"AND"; "-set-language"; "en-US";
|
||||
"AND"; "-display-doc-title"; "true";
|
||||
"AND"; "-replace-obj"; "/Root/MarkInfo/Marked=true";
|
||||
"AND"; "-replace-obj"; "/Root/StructTreeRoot/Type={\"N\":\"/StructTreeRoot\"}";
|
||||
"AND"; "-set-version"; "10";
|
||||
"AND"; "-mark-as"; "PDF/UA-2"]
|
||||
let pdf = Cpdfmetadata.set_pdf_info ~xmp_also:false ~xmp_just_set:false ("/Title", Pdf.String title, 0) pdf in
|
||||
let pdf = Cpdfmetadata.create_metadata pdf in
|
||||
Cpdfmetadata.set_language pdf "en-US";
|
||||
let pdf = Cpdfmetadata.set_viewer_preference ("/DisplayDocTitle", Pdf.Boolean true, 0) pdf in
|
||||
Pdf.replace_obj pdf "/Root/MarkInfo/Marked" (Pdf.Boolean true);
|
||||
Pdf.replace_obj pdf "/Root/StructTreeRoot/Type" (Pdf.Name "/StructTreeRoot");
|
||||
let pdf = {pdf with Pdf.major = 1; Pdf.minor = 7} in
|
||||
mark pdf;
|
||||
pdf
|
||||
|
||||
let create_cpdfua2 title pagesize pages =
|
||||
let pdf = Cpdfcreate.blank_document_paper pagesize pages in
|
||||
pdf
|
||||
let pdf = Cpdfmetadata.set_pdf_info ~xmp_also:false ~xmp_just_set:false ("/Title", Pdf.String title, 0) pdf in
|
||||
let pdf = Cpdfmetadata.create_metadata pdf in
|
||||
Cpdfmetadata.set_language pdf "en-US";
|
||||
let pdf = Cpdfmetadata.set_viewer_preference ("/DisplayDocTitle", Pdf.Boolean true, 0) pdf in
|
||||
Pdf.replace_obj pdf "/Root/MarkInfo/Marked" (Pdf.Boolean true);
|
||||
Pdf.replace_obj pdf "/Root/StructTreeRoot/Type" (Pdf.Name "/StructTreeRoot");
|
||||
let pdf = {pdf with Pdf.major = 2; Pdf.minor = 0} in
|
||||
mark2 2024 pdf;
|
||||
pdf
|
||||
|
|
Loading…
Reference in New Issue