Ejemplo n.º 1
0
        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");
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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");
        }
Ejemplo n.º 4
0
        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);
        }