2.1、获取文档名称
1 2
| WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new File("D:/xxx.docx")); System.out.println(wordMLPackage.name);
|
2.2、获取文档ContentType
1 2
| WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new File("D:/xxx.docx")); System.out.println(wordMLPackage.contentType);
|
2.3、获取文档的docProps/core.xml数据
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| CoreProperties coreProperties = wordMLPackage.getDocPropsCorePart().getJaxbElement();
coreProperties.getCategory();
coreProperties.getContentStatus();
coreProperties.getContentType();
coreProperties.getCreated().getContent().get(0).toString();
coreProperties.getCreator().getContent().get(0).toString();
coreProperties.getDescription().getValue().getContent().get(0).toString();
coreProperties.getIdentifier();
coreProperties.getKeywords();
coreProperties.getLanguage().getContent().get(0).toString();
coreProperties.getLastModifiedBy();
coreProperties.getLastPrinted();
coreProperties.getModified();
coreProperties.getRevision();
coreProperties.getSubject().getContent().get(0).toString();
coreProperties.getTitle().getValue().getContent().get(0).toString();
coreProperties.getVersion();
|
2.3、获取文档的docProps/app.xml数据
注意此处应该是文档编辑工具生成,Docx4j读取出的数据可能存在问题,例如:字数等
注意此处应该是文档编辑工具生成,Docx4j读取出的数据可能存在问题,例如:字数等
注意此处应该是文档编辑工具生成,Docx4j读取出的数据可能存在问题,例如:字数等
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| Properties appProperties = wordMLPackage.getDocPropsExtendedPart().getJaxbElement();
appProperties.getTemplate();
appProperties.getManager();
appProperties.getCompany();
appProperties.getPages();
appProperties.getWords();
appProperties.getCharacters();
appProperties.getCharactersWithSpaces();
appProperties.getLines();
appProperties.getParagraphs();
appProperties.getTotalTime();
appProperties.getApplication();
appProperties.getAppVersion();
|