public virtual DocxPackage Load()
 {
     this.docxStream.Seek(0, SeekOrigin.Begin);
     using (var package = Package.Open(this.docxStream, FileMode.Open, FileAccess.Read))
     {
         LoadPackageParts(DocxPartResolver.GetDocumentPart(package));
         LoadPackageParts(DocxPartResolver.GetHeaderParts(package).ToArray());
         LoadPackageParts(DocxPartResolver.GetFooterParts(package).ToArray());
     }
     return(this);
 }
Exemplo n.º 2
0
        public virtual void ReplaceAltChunks()
        {
            var document   = PartXml.Document;
            var htmlChunks = HtmlContentProcessor.GenerateAltChunks(document.Root);

            using (var package = Package.Open(this.docxStream, FileMode.Open, FileAccess.ReadWrite))
            {
                for (var i = 1; i <= htmlChunks.Count; i++)
                {
                    DocxPartResolver.CreateAfChunkPart(package, i, htmlChunks[i - 1]);
                }
            }
        }
Exemplo n.º 3
0
 public virtual DocxPackagePart Save()
 {
     this.docxStream.Seek(0, SeekOrigin.Begin);
     using (var package = Package.Open(this.docxStream, FileMode.Open, FileAccess.ReadWrite))
     {
         var part   = DocxPartResolver.GetPart(package, PartUri);
         var stream = part.GetStream();
         stream.SetLength(0);
         using (var writer = new XmlTextWriter(stream, new UTF8Encoding()))
         {
             this.PartXml.Save(writer);
         }
         package.Flush();
     }
     return(this);
 }