* Subject -> description.abstract
* Keywords -> subject.other
* date is java.util.Calendar
*/
PDDocument pd = new PDDocument(cos);
PDDocumentInformation docinfo = pd.getDocumentInformation();
String title = docinfo.getTitle();
// sanity check: item must have a title.
if (title == null)
throw new MetadataValidationException("This PDF file is unacceptable, it does not have a value for \"Title\" in its Info dictionary.");
log.debug("PDF Info dict title=\""+title+"\"");
item.addDC("title", null, "en", title);
String value;
Calendar date;
if ((value = docinfo.getAuthor()) != null)
{
item.addDC("contributor", "author", null, value);
log.debug("PDF Info dict author=\""+value+"\"");
}
if ((value = docinfo.getCreator()) != null)
item.addDC("description", "provenance", "en",
"Application that created the original document: "+value);
if ((value = docinfo.getProducer()) != null)
item.addDC("description", "provenance", "en",
"Original document converted to PDF by: "+value);
if ((value = docinfo.getSubject()) != null)
item.addDC("description", "abstract", null, value);
if ((value = docinfo.getKeywords()) != null)
item.addDC("subject", "other", null, value);
// Take either CreationDate or ModDate as "date.created",
// Too bad there's no place to put "last modified" in the DC.
Calendar calValue;
if ((calValue = docinfo.getCreationDate()) == null)
calValue = docinfo.getModificationDate();
if (calValue != null)
item.addDC("date", "created", null,
(new DCDate(calValue.getTime())).toString());
item.update();
}