/** * save and Commit footer */ protected override void Commit() { /*XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS); * xmlOptions.SaveSyntheticDocumentElement=(new QName(CTNumbering.type.Name.NamespaceURI, "ftr")); * Dictionary<String,String> map = new Dictionary<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.SaveSuggestedPrefixes=(map);*/ PackagePart part = GetPackagePart(); Stream out1 = part.GetOutputStream(); FtrDocument doc = new FtrDocument((CT_Ftr)headerFooter); XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces(new XmlQualifiedName[] { new XmlQualifiedName("ve", "http://schemas.openxmlformats.org/markup-compatibility/2006"), new XmlQualifiedName("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"), new XmlQualifiedName("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"), new XmlQualifiedName("v", "urn:schemas-microsoft-com:vml"), new XmlQualifiedName("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"), new XmlQualifiedName("w10", "urn:schemas-microsoft-com:office:word"), new XmlQualifiedName("wne", "http://schemas.microsoft.com/office/word/2006/wordml"), new XmlQualifiedName("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main") }); doc.Save(out1, namespaces); out1.Close(); }
protected override void Commit() { Stream outputStream = this.GetPackagePart().GetOutputStream(); FtrDocument ftrDocument = new FtrDocument((CT_Ftr)this.headerFooter); XmlSerializerNamespaces namespaces = new XmlSerializerNamespaces(new XmlQualifiedName[8] { new XmlQualifiedName("ve", "http://schemas.openxmlformats.org/markup-compatibility/2006"), new XmlQualifiedName("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships"), new XmlQualifiedName("m", "http://schemas.openxmlformats.org/officeDocument/2006/math"), new XmlQualifiedName("v", "urn:schemas-microsoft-com:vml"), new XmlQualifiedName("wp", "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing"), new XmlQualifiedName("w10", "urn:schemas-microsoft-com:office:word"), new XmlQualifiedName("wne", "http://schemas.microsoft.com/office/word/2006/wordml"), new XmlQualifiedName("w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main") }); ftrDocument.Save(outputStream, namespaces); outputStream.Close(); }
public XWPFFooter CreateFooter(ST_HdrFtr type, XWPFParagraph[] pars) { XWPFRelation footer = XWPFRelation.FOOTER; string pStyle = "Footer"; int relationIndex = this.GetRelationIndex(footer); FtrDocument ftrDocument = new FtrDocument(); XWPFFooter relationship = (XWPFFooter)this.doc.CreateRelationship((POIXMLRelation)footer, (POIXMLFactory)XWPFFactory.GetInstance(), relationIndex); CT_HdrFtr headerFooter = this.buildFtr(type, pStyle, (XWPFHeaderFooter)relationship, pars); relationship.SetHeaderFooter(headerFooter); Stream outputStream = relationship.GetPackagePart().GetOutputStream(); ftrDocument.SetFtr((CT_Ftr)headerFooter); this.assignFooter(relationship, type); ftrDocument.Save(outputStream, this.Commit((XWPFHeaderFooter)relationship)); outputStream.Close(); return(relationship); }
public XWPFFooter CreateFooter(ST_HdrFtr type, XWPFParagraph[] pars) { XWPFRelation relation = XWPFRelation.FOOTER; String pStyle = "Footer"; int i = GetRelationIndex(relation); FtrDocument ftrDoc = new FtrDocument(); XWPFFooter wrapper = (XWPFFooter)doc.CreateRelationship(relation, XWPFFactory.GetInstance(), i); CT_HdrFtr ftr = buildFtr(type, pStyle, wrapper, pars); wrapper.SetHeaderFooter(ftr); ftrDoc.SetFtr((CT_Ftr)ftr); assignFooter(wrapper, type); using (Stream outputStream = wrapper.GetPackagePart().GetOutputStream()) { ftrDoc.Save(outputStream); } return(wrapper); }