经常会有客户问到如何操作PDF文件的元数据信息,比如标题、主题、作者、关键字等?以下是java语言的代码示例:
String[] kMetadataItems = {"Title", "Author", "Subject", "Keywords",
"Creator", "Producer", "CreationDate", "ModDate"};
String[] kMetadataValues = {"Title set by simple demo", "Simple demo",
"Subject set by simple demo", "Keywords set by simple demo",
"Foxit PDF SDK", "Foxit"};
Metadata metadata = new Metadata(doc);
for (int i = 0; i < kMetadataValues.length; i++) {
WStringArray MetadataValues = new WStringArray();
MetadataValues.add(kMetadataValues[i]);
metadata.setValues(kMetadataItems[i], MetadataValues);
}
metadata.setCreationDateTime(GetLocalDateTime());
metadata.setModifiedDateTime(GetLocalDateTime());
通过以上代码示例,您可将想输入的标题、主题、作者、关键字等的元数据信息填充至PDF文件。