From 8621b59f2254fa05331ea26c74fa5ade80ae7f39 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Sat, 29 Jun 2019 16:03:29 +0100 Subject: [PATCH] more --- cpdf.ml | 20 ++++++++++++++------ cpdfmanual.tex | 1 + 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/cpdf.ml b/cpdf.ml index 964dfa1..cf0ec27 100644 --- a/cpdf.ml +++ b/cpdf.ml @@ -3399,8 +3399,6 @@ 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} *) @@ -3462,7 +3460,7 @@ let xmp_date date = d.year <- int_of_string (implode [y1; y2; y3; y4]); begin match r with m1::m2::r -> - d.month <- int_of_string (implode [y1; y2]); + d.month <- int_of_string (implode [m1; m2]); begin match r with d1::d2::r -> d.day <- int_of_string (implode [d1; d2]); @@ -3543,16 +3541,26 @@ let set_pdf_info ?(xmp_also=false) ?(xmp_also_when_present=false) ?(xmp_just_set | "/Trapped" -> [(adobe, "Trapped")], value | _ -> failwith "Unknown call to set_pdf_info" in - let pdf = set_metadata_from_bytes true (set_pdf_info_xml_many xmp_also_when_present changes value xmldata pdf) pdf - in - pdf end else pdf + +(* Set metadata date *) +let set_metadata_date pdf date only_when_present = + match get_metadata pdf with + None -> pdf + | Some xmldata -> + let changes= [(xmp, "MetadataDate")] in + let value = match date with "now" -> xmp_date (expand_date "now") | x -> x in + set_metadata_from_bytes + true + (set_pdf_info_xml_many only_when_present changes (Pdf.String value) xmldata pdf) + pdf + (* \section{Blacken text} *) (* diff --git a/cpdfmanual.tex b/cpdfmanual.tex index 3a6cd67..e422417 100644 --- a/cpdfmanual.tex +++ b/cpdfmanual.tex @@ -10,6 +10,7 @@ %FIXME: Activate documentation for -extract-images (when done) %FIXME: Document new -artbox, -trimbox, -bleedbox and -remove-artbox, -remove-trimbox, -remove-bleedbox %FIXME: Document -cropbox and -remove-cropbox as synonyms of -crop and -remove-crop +%FIXME: Document new XMP metadata stuff including setmetadata date and its format \documentclass{book} \usepackage{palatino} \usepackage{microtype}