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.

Sun Nov 30, 2014 6:16 pm

I'm using your free-edition Spire.Doc latest version (5.2).
Here is my piece of code:

Code: Select all
            {
                //save the document as Word
                var ms = new MemoryStream();
                document.SaveToStream(
                    ms,
                    Spire.Doc.FileFormat.Docx
                    );

                // ...
            }
            {
                //save the document as PDF
                var ms = new MemoryStream();
                document.SaveToStream(    //<-- throws here
                    ms,
                    Spire.Doc.FileFormat.PDF
                    );

                // ...
            }

It throws an exception on the SaveToStream method when the target format is PDF:
Unhandled Exception: System.ArgumentException: Parameter is not valid.


However, a similar snippet works fine if I use the SaveToFile method to save files directly on disk rather using streams.

Code: Select all
            //save the document as Word
            document.SaveToFile(
                @"C:\Users\Mario\Documents\SampleReport.docx",
                Spire.Doc.FileFormat.Docx
                );

            //save the document as PDF
            document.SaveToFile(
                @"C:\Users\Mario\Documents\SampleReport.pdf",
                Spire.Doc.FileFormat.PDF
                );


By looking your documentation about the SaveToStream method, you describe that it manages only XML and Word formats. I wonder what's the "XML" format, since AFAIK the Word format is XML based.
http://www.e-iceblue.com/api_documents/53f3fce5d821b6-00532457/res/html/24f027f6-4a59-de9c-4a48-56a66c7ba7ec.htm
Is it a typo on the documentation, or is there any (easy) way to save a document against a stream in the PDF format?
Thanks
Mario

vernarim
 
Posts: 10
Joined: Sat Oct 25, 2014 4:55 pm

Mon Dec 01, 2014 4:25 am

Hello,

Thanks for your feedback.
Please attach your document here for our testing, and we recommend you could try the trial version.
Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Mon Dec 01, 2014 4:49 am

What's the difference between the trial version and the free one? Once expired, the trial behaves exactly as the free edition?

vernarim
 
Posts: 10
Joined: Sat Oct 25, 2014 4:55 pm

Mon Dec 01, 2014 6:00 am

Hello,

The trial version is not free, there will be evaluation warning message, and it has no any feature limitations.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Mon Dec 01, 2014 6:59 am

I'll try the trial edition as well, but I'd like to make the system working with the free one.

So, the problem looks a bit harder than expected.
If I try the SaveToStream in a normal app (I tried a WPF one), everything seems going fine. The problem is that the exception is thrown when I use the *same* snippet in a service running in Azure. I tried several adjustments, but without any luck.

Here is the exception stack trace as shown by Azure:

[12/01/2014 06:50:22 > 0fa28c: ERR ]
[12/01/2014 06:50:22 > 0fa28c: ERR ] Unhandled Exception: System.ArgumentException: Parameter is not valid.
[12/01/2014 06:50:22 > 0fa28c: ERR ] at System.Drawing.Graphics.GetHdc()
[12/01/2014 06:50:22 > 0fa28c: ERR ] at spr?.?(PageSetup A_0, ImageType A_1, MemoryStream A_2, Int32 A_3, GraphicsUnit A_4)
[12/01/2014 06:50:22 > 0fa28c: ERR ] at spr?.?(PageSetup A_0, ImageType A_1, MemoryStream A_2, Int32 A_3)
[12/01/2014 06:50:22 > 0fa28c: ERR ] at spr?.?()
[12/01/2014 06:50:22 > 0fa28c: ERR ] at spr?.?(IDocument A_0)
[12/01/2014 06:50:22 > 0fa28c: ERR ] at spr?.?(Document A_0)
[12/01/2014 06:50:22 > 0fa28c: ERR ] at Spire.Doc.Document.?(Stream A_0)
[12/01/2014 06:50:22 > 0fa28c: ERR ] at Spire.Doc.Document.SaveToFile(Stream stream, FileFormat fileFormat)
[12/01/2014 06:50:22 > 0fa28c: ERR ] at Spire.Doc.Document.SaveToStream(Stream stream, FileFormat fileFormat)
[12/01/2014 06:50:22 > 0fa28c: ERR ] at AzureVeneziano.WebJob.MachineStatus.CreateReport(MailMessage mail, FrameworkElement chart, ReportDataParameters rdp) in c:\Blog\AzureVeneziano\AzureVeneziano.WebJob3\AzureVeneziano.WebJob\MachineStatus.cs:line 317
[12/01/2014 06:50:22 > 0fa28c: ERR ] at AzureVeneziano.WebJob.MachineStatus.SendMail(MailMessage mail) in c:\Blog\AzureVeneziano\AzureVeneziano.WebJob3\AzureVeneziano.WebJob\MachineStatus.cs:line 73
[12/01/2014 06:50:22 > 0fa28c: ERR ] at AzureVeneziano.WebJob.Program.Main() in c:\Blog\AzureVeneziano\AzureVeneziano.WebJob3\AzureVeneziano.WebJob\Program.cs:line 85

I confirm that line 317 is where the "SaveToStream" (PDF) is invoked.

I also tried to cut the DOCX creation (the first part of the snippet), thinking to something "colliding" with the PDF. However, whereas the DOCX generation is always running successfully, the PDF does not.

Unfortunately the code is rather complex, because the document results from a pretty long data elaboration. I'll try to cut a smaller piece of code in order to reproduce the behavior, but I can't guarantee that the problem reproduces from outside Azure.

Feel free to give me some hints.
Thanks

vernarim
 
Posts: 10
Joined: Sat Oct 25, 2014 4:55 pm

Mon Dec 01, 2014 8:04 am

Hello,

Thanks for your quick response.
Is it Windows Azure Shared WebSite? If so, please move to Azure Cloud Services or Virtual Machine.
Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Mon Dec 01, 2014 8:16 am

Yes, that's a shared (free) website.
I'd avoid to move to a ordinary service and/or VM, because they're (very) expensive. During this stage I'm walking through an IoT home/hobbist targeted project, and I'm currently writing a series of articles. For this reason I should keep sticky to the all-free context.
http://www.codeproject.com/Articles/843080/Azure-Veneziano-Part

Anyway, is the yours an attempt in order to evaluate the behavior, or do you have any concrete reason to ask me to move in a different environment?

Note, I may cut the ability to create the PDF, but that's a not-so-nice limitation. That is, the resulting report document can be seen by a normal smartphone: whereas an user owns a MS phone the docx format is fine, but I don't think iPhone/Android devices could manage docx in a easier way than a PDF.

Thanks again.

vernarim
 
Posts: 10
Joined: Sat Oct 25, 2014 4:55 pm

Mon Dec 01, 2014 8:33 am

Hello,

The reason is our product would use the GDI when doc to pdf conversion, and the GDI is not well supported on Azure Shared WebSite.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Mon Dec 01, 2014 8:47 am

OH!...that's making sense...but also fires a huge trouble!

First off, I assume that there's no difference if I would use the trial edition: isn't so?
Secondly, you wrote GDI, not GDI+. It means the library still relies on the Windows legacy platform (i.e. unsafe .Net)?
are you aware about something specific for this conversion? I mean that I could cut/change the document layout whereas you *do know* what may cause problems.

Also, I forgot to mention that the WebJob runs as "STA", because I need some WPF rendering as well. However, even cutting it I didn't find any improvement.

vernarim
 
Posts: 10
Joined: Sat Oct 25, 2014 4:55 pm

Mon Dec 01, 2014 9:39 am

Hello,

Both GDI and GDI+ are not supported. Our product uses the GDI when doc to pdf conversion nomatter the document layout. And both trial edition and free will use GDI when converison, will cause the issue.
Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Fri Jul 24, 2015 10:54 pm

Hi,
I've also currently using Spire.Doc (purchased last year) and trialling on Azure, and get the GDI+ error -but when using the para.appendTOC() call (ie adding Table Of Contents).

I've tried scaling the Azure website from the free (shared) tier to both Basic and Standard editions and get the same error in all cases.

Can you please advise whether this will be fixed at a later time?

Thanks,
Bryce

BrycePC
 
Posts: 2
Joined: Mon Apr 21, 2014 4:24 am

Mon Jul 27, 2015 6:58 am

Dear Bryce,

Thanks for your inquiry.
We recommend you try the latest version of Spire.Doc V5.5.30.
If the issue still happens, please offer us your sample document and code you used here, or you can send it to us( support@e-iceblue.com) via email.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Thu Jul 30, 2015 10:14 am

Dear Bryce,

Has your issue been resolved ?
Thanks for your response.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy
 
Posts: 802
Joined: Mon Jan 19, 2015 6:14 am

Wed Jun 22, 2016 7:38 am

Dear,

I am facing the same issue, with the latest dll on azure web app. any idea on how to fix it?

Regards,

mohamadlawand
 
Posts: 1
Joined: Wed Jun 22, 2016 7:36 am

Wed Jun 22, 2016 7:54 am

Hi,

Thanks for your posting.
Word to pdf conversion function is based on GDI because GDI is not well supported on Azure Shared WebSite.
In this case, the only solution for this problem is to move to Azure Cloud Services or Virtual Machine.

Best Regards,
Amy
E-iceblue support team
User avatar

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

Return to Spire.Doc