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");
        }
        private void CreateHeaderOrFooterPart(string partPath, string partContentType, string partRelationshipType, string id, string elementName, DocxContentBuilder chunks)
        {
            Uri         partUri = new Uri(partPath, UriKind.Relative);
            PackagePart part    = this.CreatePart(partUri, partContentType);

            using (DocxXmlWriter writer = new DocxXmlWriter(part.GetStream()))
            {
                writer.WriteStartDocument(elementName);
                this.WriteAltChunks(chunks, writer, part);
                writer.WriteEndDocument();
            }

            CreatePartRelationship(partUri, partRelationshipType, id, this.documentPart);
        }
        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");
        }
        private void CreateHeaderOrFooterPart(string partPath, string partContentType, string partRelationshipType, string id, string elementName, DocxContentBuilder chunks)
        {
            Uri partUri = new Uri(partPath, UriKind.Relative);
            PackagePart part = this.CreatePart(partUri, partContentType);

            using (DocxXmlWriter writer = new DocxXmlWriter(part.GetStream()))
            {
                writer.WriteStartDocument(elementName);
                this.WriteAltChunks(chunks, writer, part);
                writer.WriteEndDocument();
            }

            CreatePartRelationship(partUri, partRelationshipType, id, this.documentPart);
        }