private void addMetadata() { try { DocPropsCorePart docPropsCorePart = wordMLPackage.getDocPropsCorePart(); CoreProperties coreProps = (CoreProperties) docPropsCorePart.getContents(); org.docx4j.docProps.core.ObjectFactory CorePropsfactory = new org.docx4j.docProps.core.ObjectFactory(); org.docx4j.docProps.core.dc.elements.ObjectFactory dcElfactory = new org.docx4j.docProps.core.dc.elements.ObjectFactory(); SimpleLiteral desc = dcElfactory.createSimpleLiteral(); desc.getContent() .add("Created by NextReports Designer" + ReleaseInfoAdapter.getVersionNumber()); coreProps.setDescription(dcElfactory.createDescription(desc)); SimpleLiteral title = dcElfactory.createSimpleLiteral(); title.getContent().add(getDocumentTitle()); coreProps.setTitle(dcElfactory.createTitle(title)); SimpleLiteral author = dcElfactory.createSimpleLiteral(); author.getContent().add(ReleaseInfoAdapter.getCompany()); coreProps.setCreator(author); SimpleLiteral subject = dcElfactory.createSimpleLiteral(); subject .getContent() .add("Created by NextReports Designer" + ReleaseInfoAdapter.getVersionNumber()); coreProps.setSubject(subject); coreProps.setKeywords(ReleaseInfoAdapter.getHome()); } catch (Docx4JException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
private void createSummaryInformation(String title) { DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss"); POIXMLProperties xmlProps = wb.getProperties(); POIXMLProperties.CoreProperties coreProps = xmlProps.getCoreProperties(); coreProps.setTitle(title); coreProps.setCreator(ReleaseInfoAdapter.getCompany()); coreProps.setDescription("NextReports " + ReleaseInfoAdapter.getVersionNumber()); xmlProps .getExtendedProperties() .getUnderlyingProperties() .setApplication("NextReports " + ReleaseInfoAdapter.getVersionNumber()); coreProps.setSubjectProperty( "Created by NextReports Designer" + ReleaseInfoAdapter.getVersionNumber()); coreProps.setCreated(df.format(new Date())); coreProps.setKeywords(ReleaseInfoAdapter.getHome()); }