Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Jun 03, 2014 7:16 am

Hello,

I'm evaluating the Spire.Doc and having an issue with doc->docx conversion in memory. My code is as below:

Code: Select all
Spire.Doc.Document doc = new Spire.Doc.Document();
doc.LoadFromFile("template_saw.doc");
using (MemoryStream stream = new MemoryStream())
{
    doc.SaveToStream(stream, Spire.Doc.FileFormat.Docx);
    stream.Flush();
    using (StreamReader reader = new StreamReader(stream))
    {
        System.Console.WriteLine(reader.ReadToEnd());
    }
}

And the output I'm getting is empty. The file I'm using to test is attached (zipped)

Why is this not working?

Regards

biuro
 
Posts: 2
Joined: Mon Jun 02, 2014 7:39 am

Tue Jun 03, 2014 7:59 am

Hello,

Thanks for your inquiry.
Please kindly add the line : stream.Position = 0;
Code: Select all
    Spire.Doc.Document doc = new Spire.Doc.Document();
    doc.LoadFromFile("template_saw.doc");
    using (MemoryStream stream = new MemoryStream())
    {
        doc.SaveToStream(stream, Spire.Doc.FileFormat.Docx);
        stream.Flush();
        stream.Position = 0;
        using (StreamReader reader = new StreamReader(stream))
        {
            System.Console.WriteLine(reader.ReadToEnd());
        }
    }


Feel free to contact us if you have any problems.

Best wishes,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Fri Jun 06, 2014 9:45 am

Hello,

Has your issue been resolved?
Thanks for your feedback.

Please don't hesitate to contact us if you have any problems.

Best wishes,
Amy
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Thu Jun 12, 2014 6:58 am

Yes. Thank you.

biuro
 
Posts: 2
Joined: Mon Jun 02, 2014 7:39 am

Thu Jun 12, 2014 7:07 am

Hello,

Thanks for your feedback.
Feel free to contact us for further problems.

Best wishes and have a nice day,
Amy
User avatar

amy.zhao
 
Posts: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.Doc