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();
|
![image-20231206102818793](/2023/12/06/Docx4j%E5%BC%80%E5%8F%91%E6%89%8B%E5%86%8C-2-Docx4j%E7%9A%84%E6%AE%B5%E8%90%BD%E7%BA%A7%E5%88%AB%E4%BF%A1%E6%81%AF/image-20231206102818793.png)
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();
|
![image-20231206102824413](/2023/12/06/Docx4j%E5%BC%80%E5%8F%91%E6%89%8B%E5%86%8C-2-Docx4j%E7%9A%84%E6%AE%B5%E8%90%BD%E7%BA%A7%E5%88%AB%E4%BF%A1%E6%81%AF/image-20231206102824413.png)