/** * save and commit footer */ @Override protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTNumbering.type.getName().getNamespaceURI(), "ftr")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); super._getHdrFtr().save(out, xmlOptions); out.close(); }
InputStream is = null; try { is = getPackagePart().getInputStream(); ftrDocument = FtrDocument.Factory.parse(is, DEFAULT_XML_OPTIONS); headerFooter = ftrDocument.getFtr();
/** * save and commit footer */ @Override protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTNumbering.type.getName().getNamespaceURI(), "ftr")); Map<String,String> map = new HashMap<String, String>(); map.put("http://schemas.openxmlformats.org/markup-compatibility/2006", "ve"); map.put("urn:schemas-microsoft-com:office:office", "o"); map.put("http://schemas.openxmlformats.org/officeDocument/2006/relationships", "r"); map.put("http://schemas.openxmlformats.org/officeDocument/2006/math", "m"); map.put("urn:schemas-microsoft-com:vml", "v"); map.put("http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing", "wp"); map.put("urn:schemas-microsoft-com:office:word", "w10"); map.put("http://schemas.openxmlformats.org/wordprocessingml/2006/main", "w"); map.put("http://schemas.microsoft.com/office/word/2006/wordml", "wne"); xmlOptions.setSaveSuggestedPrefixes(map); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); super._getHdrFtr().save(out, xmlOptions); out.close(); }
/** * save and commit footer */ @Override protected void commit() throws IOException { XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); xmlOptions.setSaveSyntheticDocumentElement(new QName(CTNumbering.type.getName().getNamespaceURI(), "ftr")); PackagePart part = getPackagePart(); OutputStream out = part.getOutputStream(); super._getHdrFtr().save(out, xmlOptions); out.close(); }
InputStream is = null; try { is = getPackagePart().getInputStream(); ftrDocument = FtrDocument.Factory.parse(is, DEFAULT_XML_OPTIONS); headerFooter = ftrDocument.getFtr();
/** * Returns the {@link XWPFFooter} of the given footer reference. * * @param footerRef the footer reference. * @return * @throws XmlException * @throws IOException */ protected XWPFFooter getXWPFFooter( CTHdrFtrRef footerRef ) throws XmlException, IOException { PackagePart hdrPart = document.getPartById( footerRef.getId() ); List<XWPFFooter> footers = document.getFooterList(); for ( XWPFFooter footer : footers ) { if ( footer.getPackagePart().equals( hdrPart ) ) { // footer is aleady loaded, return it. return footer; } } // should never come, but load the footer if needed. FtrDocument hdrDoc = FtrDocument.Factory.parse( hdrPart.getInputStream() ); CTHdrFtr hdrFtr = hdrDoc.getFtr(); XWPFFooter ftr = new XWPFFooter( document, hdrFtr ); return ftr; }
InputStream is; try { is = getPackagePart().getInputStream(); ftrDocument = FtrDocument.Factory.parse(is); headerFooter = ftrDocument.getFtr();
/** * Returns the {@link XWPFFooter} of the given footer reference. * * @param footerRef the footer reference. * @return * @throws XmlException * @throws IOException */ protected XWPFFooter getXWPFFooter( CTHdrFtrRef footerRef ) throws XmlException, IOException { PackagePart hdrPart = document.getPartById( footerRef.getId() ); List<XWPFFooter> footers = document.getFooterList(); for ( XWPFFooter footer : footers ) { if ( footer.getPackagePart().equals( hdrPart ) ) { // footer is aleady loaded, return it. return footer; } } // should never come, but load the footer if needed. FtrDocument hdrDoc = FtrDocument.Factory.parse( hdrPart.getInputStream() ); CTHdrFtr hdrFtr = hdrDoc.getFtr(); XWPFFooter ftr = new XWPFFooter( document, hdrFtr ); return ftr; }
/** * Returns the {@link XWPFFooter} of the given footer reference. * * @param footerRef the footer reference. * @return * @throws XmlException * @throws IOException */ protected XWPFFooter getXWPFFooter( CTHdrFtrRef footerRef ) throws XmlException, IOException { PackagePart hdrPart = document.getPartById( footerRef.getId() ); List<XWPFFooter> footers = document.getFooterList(); for ( XWPFFooter footer : footers ) { if ( footer.getPackagePart().equals( hdrPart ) ) { // footer is aleady loaded, return it. return footer; } } // should never come, but load the footer if needed. FtrDocument hdrDoc = FtrDocument.Factory.parse( hdrPart.getInputStream() ); CTHdrFtr hdrFtr = hdrDoc.getFtr(); XWPFFooter ftr = new XWPFFooter( document, hdrFtr ); return ftr; }
public XWPFFooter createFooter(Enum type, XWPFParagraph[] pars) throws IOException { XWPFRelation relation = XWPFRelation.FOOTER; String pStyle = "Footer"; int i = getRelationIndex(relation); FtrDocument ftrDoc = FtrDocument.Factory.newInstance(); XWPFFooter wrapper = (XWPFFooter)doc.createRelationship(relation, XWPFFactory.getInstance(), i); CTHdrFtr ftr = buildFtr(type, pStyle, wrapper, pars); wrapper.setHeaderFooter(ftr); OutputStream outputStream = wrapper.getPackagePart().getOutputStream(); ftrDoc.setFtr(ftr); XmlOptions xmlOptions = commit(wrapper); assignFooter(wrapper, type); ftrDoc.save(outputStream, xmlOptions); outputStream.close(); return wrapper; }