Docx to Aspose Doc

I save a DOCX document as binary in a database then
I use that binary to create an Aspose document (specify the load format as docx),
I use the new Aspose documents mail merge functionality then
I convert that document to binary,
A new DOCX document is created from that binary.
The problem is that the document xml for the DOCX document is being lost when I create a new aspose document.
How can I create an aspose document from docx binary data without loosing the DOCX document xml?
Note: If the document is created normally without Aspose everything is fine.
Aaron Viljoen

This message was posted using Email2Forum by ShL77.

Hi Aaron,

Thanks for your inquiry. What do you mean when say “document xml is lost”? Could you please clarify? Also please attach your document for testing and code that will allow me to reproduce the problem on my side. I will investigate the issue and provide you more information.
Best regards.

Hi again, thanks for the promt reply!
I’ve attached a docx document with rich text textboxes embedded in it. You are more than welcome to view it.
Please copy it to "c:"
After the you run the code you will see another document has been created “c:\output.docx”.
You will notice that the textbox in the new document has become static context.
If you convert both docx files to zip files you notice there is a difference between the document.xml for both.
Here is the sample code you can use to recreate the problem I’m experiencing. Visual Studio 2005 C# windows application)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using Aspose.Words;
namespace AsposeDocXApp
    public partial class Form1 : Form
        public Form1()
            // Example 
            FileStream fs = new FileStream(@"C:\Tesdtdsdsf.docx", FileMode.OpenOrCreate, FileAccess.Read);
            Byte[] mydata = new Byte[fs.Length]; // This is what is commited to the db.
            fs.Read(mydata, 0, (int)fs.Length);
            // Reading the data from the db into a stream.
            MemoryStream decompressedMemoryStream = new MemoryStream();
            decompressedMemoryStream.Write(mydata, 0, mydata.Length);
            LoadFormat inputFormat = Document.DetectFileFormat(decompressedMemoryStream);
            string extension = string.Empty;
            SaveFormat outputFormat = SaveFormat.Docx;
            // Create the new aspose document
            Document doc = new Document(decompressedMemoryStream);
            // Mail merge ommitted.
            MemoryStream mergedDocumentStream = new MemoryStream();
            doc.Save(mergedDocumentStream, outputFormat);
            byte[] mergedData = mergedDocumentStream.ToArray();
            // Now use this data to create a new docx file
            MemoryStream newDocumentStream = new MemoryStream();
            newDocumentStream.Write(mergedData, 0, mergedData.Length);
            newDocumentStream.Seek(0, SeekOrigin.Begin);
            using (FileStream fileStream = File.Create(@"c:\output.docx"))
                int size = 4096;
                byte[] buffer = new byte[4096];
                while (true)
                    size = newDocumentStream.Read(buffer, 0, buffer.Length);
                    if (size > 0) fileStream.Write(buffer, 0, size);
                    else break;

Aaron Viljoen

This message was posted using Email2Forum by ShL77.


Thank you for additional information. This occurs because TextBoxes in your document are Structured document Tags (Content Controls). Aspose.Words does not support Content Controls at the moment. This is the issue #4295 in our defect database. Hopefully, SDT will be supported somewhere in this year, but I cannot promise you anything at this stage.
Best regards.

The issues you have found earlier (filed as 4295) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.