Beginning work on -set-metadata-date
This commit is contained in:
parent
872491f60e
commit
44fdb93574
8
cpdf.ml
8
cpdf.ml
|
@ -3399,6 +3399,9 @@ let set_pdf_info_xml_many only_when_present changes value xmldata pdf =
|
|||
changes;
|
||||
!xmldata
|
||||
|
||||
(* Set metadata date *)
|
||||
let set_metadata_date pdf only_when_present date = pdf
|
||||
|
||||
(* \section{Set an entry in the /Info dictionary} *)
|
||||
|
||||
(* We must parse the date to get its components, then use strftime to build the
|
||||
|
@ -3429,10 +3432,11 @@ let default_date () =
|
|||
(* XMP date format is YYYY-MM-DDThh:mm:ssTZD *)
|
||||
let make_xmp_date_from_components d =
|
||||
let tzd =
|
||||
if d.ut_relationship = 0 && d.offset_hours = 0 && d.offset_minutes = 0 then "Z" else
|
||||
(if d.ut_relationship >=0 then "+" else "-") ^
|
||||
Printf.sprintf "%2i" d.offset_hours ^
|
||||
Printf.sprintf "%02i" d.offset_hours ^
|
||||
":" ^
|
||||
Printf.sprintf "%2i" d.offset_minutes
|
||||
Printf.sprintf "%02i" d.offset_minutes
|
||||
in
|
||||
Cpdfstrftime.strftime
|
||||
~time:{Unix.tm_sec = d.second;
|
||||
|
|
2
cpdf.mli
2
cpdf.mli
|
@ -195,6 +195,8 @@ val get_metadata : Pdf.t -> Pdfio.bytes option
|
|||
(** Print metadate to stdout *)
|
||||
val print_metadata : Pdf.t -> unit
|
||||
|
||||
val set_metadata_date : Pdf.t -> string -> bool -> Pdf.t
|
||||
|
||||
(** {2 Stamping} *)
|
||||
|
||||
(** [combine_pages fast under over scaletofit swap equalize] combines the page
|
||||
|
|
|
@ -1589,6 +1589,9 @@ let setalsosetxmlwhenpresent () =
|
|||
let setjustsetxml () =
|
||||
args.justsetxml <- true
|
||||
|
||||
let setsetmetadatadate d =
|
||||
args.op <- Some (SetMetadataDate d)
|
||||
|
||||
(* Parse a control file, make an argv, and then make Arg parse it. *)
|
||||
let rec make_control_argv_and_parse filename =
|
||||
control_args := !control_args @ parse_control_file filename
|
||||
|
@ -2039,6 +2042,9 @@ and specs =
|
|||
("-remove-metadata",
|
||||
Arg.Unit (setop RemoveMetadata),
|
||||
" Remove document metadata");
|
||||
("-set-metadata-date",
|
||||
Arg.String setsetmetadatadate,
|
||||
" Set the XMP metadata date property");
|
||||
("-hide-toolbar",
|
||||
Arg.String hidetoolbar,
|
||||
" Hide the viewer's toolbar");
|
||||
|
@ -3698,7 +3704,7 @@ let go () =
|
|||
~xmp_just_set:args.justsetxml
|
||||
(key, value, version) pdf)
|
||||
| Some (SetMetadataDate date) ->
|
||||
failwith "SetMetadataDate unimplemented"
|
||||
write_pdf false (Cpdf.set_metadata_date (get_single_pdf args.op false) date args.alsosetxmlwhenpresent)
|
||||
| Some ((HideToolbar _ | HideMenubar _ | HideWindowUI _
|
||||
| FitWindow _ | CenterWindow _ | DisplayDocTitle _) as op) ->
|
||||
begin match args.out with
|
||||
|
|
Loading…
Reference in New Issue