Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Oct 14, 2015 2:59 pm

Hey,

Im using Spire.Doc to convert docx to pdf.

I have a singleton service to handle a long running tasks like docx to pdf generation.
Solution is a Asp.net MVC 5 website hosted to Azure.

Code: Select all
        private void BuildInvoice( ... )
        {
            var repo = IoC.Resolve<IInvoiceRepository>();

            Task.Factory.StartNew(() =>
            {
                lock (_lock)
                {
                    using (Stream docStream = new MemoryStream())
                    using (Stream pdfStream = new MemoryStream())
                    {
                        using (DocX document = DocX.Load(template))
                        {
                            document.ReplaceText("{{CompanyName}}", company.Name);
                            document.ReplaceText("{{CompanyAddress}}", company.Contact.PostalAddress);
                            document.ReplaceText("{{Number}}", invoice.Reference);
                            document.ReplaceText("{{Date}}", DateTime.UtcNow.Date.ToShortDateString());
                            document.SaveAs(docStream);
                        }

                        Document doc = new Document();
                        doc.LoadFromStream(docStream, FileFormat.Docx);
                        doc.SaveToStream(pdfStream, FileFormat.PDF);

                        byte[] invoiceContent = StreamHelper.ToByteArray(pdfStream);
                        UpdateInvoice(repo, invoice.Id, invoiceContent);

                        SendInvoice(contacts, invoiceContent, invoice.Type, company);
                    }
                }
            });
        }


Locally everything runs great, on azure it fails at line:
doc.SaveToStream(pdfStream, FileFormat.PDF);
with message:
A generic error occurred in GDI+

any ideas ?

Regards
Rasmus K.

rassk
 
Posts: 2
Joined: Wed Oct 14, 2015 2:51 pm

Thu Oct 15, 2015 2:45 am

Hello,

Thanks for your inquiry.
Our product would use the GDI when doc to pdf conversion, but GDI is not well supported on Azure Shared WebSite, so it fails, sorry for the inconvenience.

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

Thu Oct 15, 2015 7:25 am

Could you confirm, if this works ?

https://social.msdn.microsoft.com/forum ... tespreview

Although our site is using Basic mode, and still it's not working...

rassk
 
Posts: 2
Joined: Wed Oct 14, 2015 2:51 pm

Thu Oct 15, 2015 8:10 am

Hi,

Sorry that it still doesn't work even in Basic mode.

Best Regards,
Amy
E-iceblue support team
User avatar

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

Return to Spire.PDF

cron