Dear,
I’ve encounterd a problem with following code.
When a .doc file - generated/updated by Aspose.Words - is downloaded, the complete file is received, and works fine (local and online). However, when a docx file - generated/updated by Aspose.Words - is downloaded, only 20kB (no matter how big it is) is downloaded, and Word2007 says that the document is corrupted when opening.
Extra problem is that testing this offline (Windows Vista, Visual Studio 2005 in debug or local IIS 6.0), this error does not occur. Online (same IIS 6.0, operating system Windows 2003), we have the problem.
I use following code:
string FILE_NAME = (string)fileRef["name"];
string docExtension = FILE_NAME.Substring(fileAndPath.LastIndexOf('.') + 1);
...
// Open template
Document doc = new Document(fileAndPath);
...
if (docExtension.ToLower() == "docx")
doc.Save(FILE_NAME, SaveFormat.Docx, Aspose.Words.SaveType.OpenInWord, Response);
else if (docExtension.ToLower() == "doc")
doc.Save(FILE_NAME, SaveFormat.Doc, Aspose.Words.SaveType.OpenInWord, Response);
Response.End();
We also tried following code, and displayed the wordstream legth after the doc.save, to verify whether it was due to the transfer. The length displayed was also 20kB, which means that Aspose.Words seems to truncate the document.
MemoryStream wordStream = new MemoryStream();
...
if (docExtension.ToLower() == "docx")
doc.Save(wordStream, SaveFormat.Docx);
else if (docExtension.ToLower() == "doc")
doc.Save(wordStream, SaveFormat.Doc); wordStream.Flush();
int wordStreamLength = (int)wordStream.Length;
wordStream.Close();
if (wordStream != null)
{
Response.Cache.SetCacheability(System.Web.HttpCacheability.Public);
byte[] bytes = wordStream.GetBuffer();
Response.OutputStream.Write(bytes, 0, wordStreamLength);
Response.OutputStream.Flush();
Response.OutputStream.Close();
Response.End();
}
Are there settings which might be different on my local system in comparison to the server?
Thanks for your help.
This message was posted using Aspose.Live 2 Forum