All,
I am trying to build an example of the moving sections between one document to another. I am defining an allDoc, which will hold the “sum” of 2 documents. When I get a new document, I check if allDoc has been assigned anything yet, If it has NOT, I set it to the current (first) document, if it is already assigned a document, I create new new doc called “doc” and move the sections from doc to allDoc. It runs fine, but when I save the document to disk and try to open it in Word, I get the message “There is not enough memory or diskspace to complete the operation”. Also, trying to send it to the browser just hangs the page for a while and eventually, I get memory error message too. The two individual documents open fine if I don’t do any section moving. I am including my code. Please let me know if anyone sees something wrong.
Thank you!!!
I have cut out some code to make it easier to review here…
private void Page_Load(object sender, System.EventArgs e)
{
string templateFileName = "test.doc";
Aspose.Word.Word wd2 = new Word();
string[] a = new string[2];
a[0] = "628";
a[1] = "630";
//a[2] = "629";
Aspose.Word.Document allDoc = null;
Response.ContentType = "application/vnd.ms-word";
Response.Charset = "";
for (int i = 0; i < a.Length; i++)
{
string docID = a;
// Code removed for easier reading, but I get the word data and put it into the byte array content
byte[] content = (byte[])ds.Tables[0].Rows[0][DocumentAssemblyUtils.COL_CONTENT];
MemoryStream ms2 = new System.IO.MemoryStream();
ms2.Write(content, 0, content.Length);
if (allDoc == null)
{
allDoc = new Document(ms2);
}
else
{
Aspose.Word.Document doc = new Document(ms2);
while (doc.Sections.Count > 0)
{
Section section = doc.Sections[0];
doc.Sections.RemoveAt(0);
allDoc.Sections.Add(section);
}
}
}
allDoc.Save(@"C:\tech\bmstest.doc");
allDoc.Save(templateFileName, SaveFormat.FormatDocument, SaveType.OpenInBrowser, this.Response);
}