private void WriteHeaderAndFooter(DocxFile docx, DocxXmlWriter writer) { writer.WriteStartElement("sectPr"); int idCounter = 1; if (docx.HasHeader) { string id = "rId" + idCounter; writer.WriteElement("headerReference", "id", id, "type", "default"); this.CreateHeaderOrFooterPart( DocxPackageWriter.HeaderPath, Resources.HeaderContentType, Resources.HeaderRelationshipType, id, "hdr", docx.Header); idCounter++; } if (docx.HasFooter) { string id = "rId" + idCounter; writer.WriteElement("footerReference", "id", id, "type", "default"); this.CreateHeaderOrFooterPart( DocxPackageWriter.FooterPath, Resources.FooterContentType, Resources.FooterRelationshipType, id, "ftr", docx.Footer); } }
public void Write(DocxFile docx) { this.documentPart = this.CreatePart( new Uri(DocxPackageWriter.DocumentPath, UriKind.Relative), Resources.DocumentContentType); using (DocxXmlWriter writer = new DocxXmlWriter(this.documentPart.GetStream())) { writer.WriteStartDocument("document"); writer.WriteStartElement("body"); this.WriteAltChunks(docx.Body, writer, this.documentPart); if (docx.HasHeader || docx.HasHeader) { this.WriteHeaderAndFooter(docx, writer); } writer.WriteEndDocument(); } this.package.CreateRelationship( new Uri(DocxPackageWriter.DocumentPath.Substring(1), UriKind.Relative), TargetMode.Internal, Resources.DocumentRelationshipType, "rId1"); }
public void Write(DocxFile docx) { this.documentPart = this.CreatePart( new Uri(DocxPackageWriter.DocumentPath, UriKind.Relative), Resources.DocumentContentType); using (DocxXmlWriter writer = new DocxXmlWriter(this.documentPart.GetStream())) { writer.WriteStartDocument("document"); writer.WriteStartElement("body"); this.WriteAltChunks(docx.Body, writer, this.documentPart); if (docx.HasHeader || docx.HasHeader) this.WriteHeaderAndFooter(docx, writer); writer.WriteEndDocument(); } this.package.CreateRelationship( new Uri(DocxPackageWriter.DocumentPath.Substring(1), UriKind.Relative), TargetMode.Internal, Resources.DocumentRelationshipType, "rId1"); }