I have a scenario where I need to return a byte array. This is the code that was used with the earlier version(5.2.2.). As I said earlier, I have to use both the version as I have some users who are not ready for this upgrade. For the user who are ready with this upgrade, I’m using Aspose.Words ver 8.2.1.
The below strategy is used in my middle tier and changing the UI peice is very very risky. Appreciate your help.
The new version errors out when I use the new version. Here the code and error:
public byte[] PdfStream
{
get
{
System.Security.Principal.WindowsImpersonationContext ctx = RemoveASPNETAuthenticationToken();
try
{
MemoryStream memStream = new MemoryStream();
Document.Save(memStream, SaveFormat.AsposePdf);
memStream.Seek(0, SeekOrigin.Begin);
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
xmlDoc.Load(memStream);
Aspose.Pdf.Pdf pdf = new Pdf();
pdf.BindXML(xmlDoc, null);
byte[] byteStream;
using(MemoryStream pdfStream = new MemoryStream())
{
pdf.Save(pdfStream);
byteStream = pdfStream.ToArray();
}
return byteStream;
}
finally
{
// Resume impersonation
if (ctx != null) ctx.Undo();
}
}
}
I’m getting the Error “Image File cannot be written to the Disk…” when I use this method. How can I solve this with the new version of Word.