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.

Wed Jun 01, 2016 4:24 pm

I trying to convert a .docx file already in memory to pdf with the method LoadFromStream() but receive this error:

Code: Select all
[NullReferenceException: Object reference not set to an instance of an object.]
   spr᳝.ᜀ(ListLevel A_0, String A_1) +221
   spr᳝.ᜁ(XmlReader A_0, ListLevel A_1) +1665
   spr᳝.ᜀ(XmlReader A_0, ListStyle A_1) +345
   spr᳝.ᜒ(XmlReader A_0) +238
   spr᳝.᜕(XmlReader A_0) +541
   spr᳝.ᜁ(sprᢇ A_0) +542
   spr᳝.ᜁ(Document A_0) +74
   spr᳝.ᜁ(Stream A_0, Document A_1) +157
   Spire.Doc.Document.ᜍ(Stream A_0) +69
   Spire.Doc.Document.LoadFromStream(Stream stream, FileFormat fileFormat, String password) +499
   Spire.Doc.Document.LoadFromStream(Stream stream, FileFormat fileFormat) +11


And this is a snippet from my code:

Code: Select all
 using (var stream = new MemoryStream(myDoc.GetBytes())) // Another  component will replace tags inside the doc..
                        {
                            Document documentPdf = new Document();

                            documentPdf.LoadFromStream(stream,FileFormat.Auto); //Throw exception.
                            documentPdf.SaveToFile(filePath, FileFormat.PDF);
                        }


What I'm doing wrong? If I load from file it's work 100%.

lucasluandemelo@gmail.com
 
Posts: 4
Joined: Wed Jun 01, 2016 4:07 pm

Thu Jun 02, 2016 3:32 am

Hi,

Thank you for your feedback and your file.
I tested your file with the latest version Spire.Doc Pack Version:5.7 and the below code, and it works fine. Please have a try.
Code: Select all
Stream stream = File.OpenRead(@"C:\Users\Administrator\Desktop\MaiconModelo.docx");
Document documentPdf = new Document();
documentPdf.LoadFromStream(stream, FileFormat.Auto);
documentPdf.SaveToFile("result.pdf", FileFormat.PDF);


Sincerely,
Caroline
E-iceblue support team
User avatar

caroline.zhang
 
Posts: 291
Joined: Mon Mar 07, 2016 9:22 am

Thu Jun 02, 2016 8:04 pm

caroline.zhang wrote:Hi,

Thank you for your feedback and your file.
I tested your file with the latest version and the below code, and it works fine. Please have a try.
Code: Select all
Stream stream = File.OpenRead(@"C:\Users\Administrator\Desktop\MaiconModelo.docx");
Document documentPdf = new Document();
documentPdf.LoadFromStream(stream, FileFormat.Auto);
documentPdf.SaveToFile("result.pdf", FileFormat.PDF);


Sincerely,
Caroline
E-iceblue support team


Hi Caroline,

First of all thanks for your help =).

I'm using the FreeSpireDoc (version 5.5), maybe this is the reason why I get this error? If is because this there's any idea when FreeSpireDoc will be updated?

lucasluandemelo@gmail.com
 
Posts: 4
Joined: Wed Jun 01, 2016 4:07 pm

Fri Jun 03, 2016 2:19 am

Hello,

Thank you for your kind feedback.
I also tested your file with the free version Free Spire.Doc for .NET Version:5.5, sorry that it didn't replicate the issue. Could you please test the latest pro version Spire.Doc Pack Version:5.7 on your side? If there still is the error after testing, could you please save the object myDoc.GetBytes() as file and share the file with us for investigation? Thank you for the assistance.

Sincerely,
Caroline
E-iceblue support team
User avatar

caroline.zhang
 
Posts: 291
Joined: Mon Mar 07, 2016 9:22 am

Mon Jun 06, 2016 7:28 am

Hi,

How is the issue now? Could you please give us some feedback?

Thank you in advance.
Caroline
E-iceblue support team
User avatar

caroline.zhang
 
Posts: 291
Joined: Mon Mar 07, 2016 9:22 am

Mon Jun 06, 2016 7:50 pm

Hello Caroline, sorry for the delay :( .

I tested with version SpireDoc 5.7.27 and works like a charm.

But there's another issue with 5.5. When I load the file attached on this repply I get nothing, my upload get stuck on loading... When I debugged, the last step is on SaveToFile. Can be a problem of more paragraphs than the expected for the free version?

Code: Select all
                using (var stream = new MemoryStream(arquivo.GetBytes()))
                {
                    Document documentPdf = new Document();
                    documentPdf.LoadFromStream(stream, FileFormat.Auto);
                    documentPdf.SaveToFile(filepath, FileFormat.PDF);
                }

lucasluandemelo@gmail.com
 
Posts: 4
Joined: Wed Jun 01, 2016 4:07 pm

Tue Jun 07, 2016 1:52 am

Hi,

Thank you for your feedback.
I tested the file with the free version Spire.Doc 5.5 and didn't reproduce your issue. But there is other issue that the table in the file is missing (see the attachment). Sorry that we don't plan to maintain the free version at present. I also tested it with the latest pro version Spire.Doc Pack Version:5.7 and there is no issue. So I recommend you to test the pro version.

Sincerely,
Caroline
E-iceblue support team
User avatar

caroline.zhang
 
Posts: 291
Joined: Mon Mar 07, 2016 9:22 am

Tue Jun 07, 2016 11:27 am

Thank you Caroline for all the help, I will test with the pro version.

lucasluandemelo@gmail.com
 
Posts: 4
Joined: Wed Jun 01, 2016 4:07 pm

Thu Jun 09, 2016 8:39 am

Hi,

Thank you for your reply.
Did you test the pro version? Could you please give us some feedback after testing at your convenience?

Tnanks in advance,
Caroline
E-iceblue support team
User avatar

caroline.zhang
 
Posts: 291
Joined: Mon Mar 07, 2016 9:22 am

Return to Spire.Doc