I am uploading a PDF file and then using Aspos.PDF trial component trying to Save PDF to DOC into memory stream. I have used code below to accomplish that. After save, When try to use mStream it gives me an error that Document is corrupted. Memory stream is closed and I can not do read, write or seek with memory stream.
string saveFilePath = (@"D:\temp\"+FileUpload1.FileName).ToLower();
MemoryStream mStream = new MemoryStream();
if (FileUpload1.FileName.ToUpper().EndsWith("PDF"))
{
saveFilePath = saveFilePath.Replace("pdf", "doc");
using (Aspose.Pdf.Document newDoc = new Aspose.Pdf.Document(FileUpload1.FileContent))
{
newDoc.Save(mStream, Aspose.Pdf.SaveFormat.Doc);
}
}
Hi Kishor,
Thanks for using our products and sharing the sample source code.
I tried to replicate your issue at my end with below source code using Aspose.Pdf for .NET v6.9 and unable to find any issue, using memory stream object after saves. Source and resultant documents are attached for your reference. Kindly try to use the below source code with latest version and check, if it fits your need. If you still face any issue, we would appreciate it if you could kindly create a sample application along with template documents and post it here to show the issue. This will help us to regenerate the issue and get the cause of the issue soon.
MemoryStream mStream = new MemoryStream();
Aspose.Pdf.Document newDoc = new Aspose.Pdf.Document(@"d:\pdffiles\helloworld.pdf");
newDoc.Save(mStream, SaveFormat.Doc);
byte[] data = mStream.ToArray();
FileStream output = new FileStream(@"d:\pdffiles\output.doc", FileMode.Create, FileAccess.Write);
output.Write(data, 0, data.Length);
output.Close();
We apologize for your inconvenience.
Thanks & Regards,
This is working fine. thanks for helping us.