将描述标记添加到docx文件中的core.xml

时间:2013-08-02 04:34:28

标签: java docx4j

我正在使用docx4j修改停靠文件的description标记,如下所示:

DocPropsCorePart docPropsCorePart = wordMLPackage.getDocPropsCorePart();
CoreProperties coreProps = (CoreProperties)docPropsCorePart.getJaxbElement();
JAXBElement<SimpleLiteral> desc = coreProps.getDescription();
SimpleLiteral literal = (SimpleLiteral) XmlUtils.unwrap(desc);
if (literal!=null) {
   List<String> contents = literal.getContent();
   contents.add(0, "Scanned by AFTA. Request Code: ${scanCode}");
}
else {
   //comes here when document has no description tag
}
//save the document

但是,某些文档没有description标记。我想将描述标签添加到这些文档中。我怎样才能做到这一点?

0 个答案:

没有答案