We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

error when converting doc to pdf

when generating a pdf from a word template, we get the following exception.

Problem is that when we run the application locally the application works, we have published it to an hosting provider and setted full trust and it worked, but when published on azure websites, it throw this exception:

Server Error in '/' Application.

Parameter is not valid.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.ArgumentException: Parameter is not valid.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[ArgumentException: Parameter is not valid.]
   System.Drawing.Graphics.GetHdc() +1144425
   Syncfusion.DocIO.DLS.Rendering.DocumentLayouter.CreateImage(WPageSetup pageSetup, ImageType imageType, MemoryStream stream, Int32 resolution) +339
   Syncfusion.DocIO.DLS.Rendering.DocumentLayouter.LayoutPages() +120
   Syncfusion.DocIO.DLS.Rendering.DocumentLayouter.Layout(IWordDocument doc) +133
   Syncfusion.DocToPDFConverter.DocToPDFConverter.ConvertToPDF(WordDocument wordDocument) +47



30 Replies

AI Andrea Inglese June 26, 2014 02:10 PM UTC

does this rely to the above problem?
http://stackoverflow.com/questions/18726106/azure-websites-full-trust


SK Sathish K Syncfusion Team June 30, 2014 02:41 PM UTC

Hi Andrea,

 

Thank you for your interest in Syncfusion products.

 

Essential DocIO uses GDI+ functionalities for converting a Word document to PDF. Whereas some of the GDI+ functionalities are not supported in Windows Azure websites and this is known limitation in Windows Azure environment. Hence the mentioned error is thrown while deploying the Word to PDF conversion in Azure websites. As a workaround, kindly use Azure cloud services to convert Word documents to PDF and call this service from Azure web site.

 

Please let us know if you have any other questions.

 

Regards,

Sathish



JM José Matos May 28, 2015 10:15 PM UTC

Is there any solution or workaround ?

Thanks


SK Sathish K Syncfusion Team May 29, 2015 07:08 AM UTC

Hi Jose,

Thank you for your update.

As mentioned earlier, currently Azure doesn’t provide full-fledged support for GDI functionalities. Due to this limitation in Azure, when we convert the Word document as PDF document using Essential DocIO, the conversion process become fails because Word document to PDF conversion depends on GDI functionalities. So it is a known limitation in Word document to PDF conversion using DocIO until complete GDI functionalities are supported in Azure.

As a workaround you shall make use of Azure cloud service to convert a Word document as Pdf and use that cloud service as service reference in your azure web site. We have prepared a sample to illustrate the same.

Please find the sample for Azure cloud service from below link:
http://www.syncfusion.com/downloads/support/directtrac/general/GeneratePdf_ColudService2143814054.zip

Please find the sample using cloud service as service reference from below link:
http://www.syncfusion.com/downloads/support/directtrac/general/WordToPdfConversion-329039872.zip

Please let us know if you have any other questions.

Regards,
Sathish



EB Erwann Blancart September 23, 2015 03:36 PM UTC

Hi,

Did this situation get any better since then ?

I created a ticket http://www.syncfusion.com/forums/120526/azure-hosted-syncfusion-doctopdfconverter-converttopdf-a-generic-error-occurred-in-gdi because I am facing the same problem.

Is creating a Cloud Service hosted application is the only workaround ?

Thanking you in advance.


NS Narendran Srinivasan Syncfusion Team September 24, 2015 10:14 AM UTC

Hi Erwann,

Thank you for contacting Syncfusion support,

Currently GDI+ functionalities are not supported in Windows Azure websites and this is known limitation in Windows Azure environment. Till Windows Azure supports
full-fledged on GDI+ functionalities we can use below sample as work around solution.

Please find the sample for Azure cloud service from below link:
http://www.syncfusion.com/downloads/support/directtrac/general/GeneratePdf_ColudService2143814054.zip

Please find the sample using cloud service as service reference from below link:
http://www.syncfusion.com/downloads/support/directtrac/general/WordToPdfConversion-329039872.zip

Regards,
Narendran




IE Ian Elbury April 5, 2016 08:57 PM UTC

Actually GDI+ is available on Basic and Standard Web Apps with restrictions. I used to not be able to run MS ReportViewer because of the GDI+ limitation but it was fixed a couple of years ago.

Your competitors seems to have resolved the problem with many of their components. I believe that the trick is to use bitmap format and NOT metafile format during conversion. Looking at the stack trace, it seems like this fix may possible. Try Google "GDI+ error or OutOfMemoryException on exporting".

Would it be possible to see if it can be resolved? The workaround you are proposing precludes the use of your product my solutions.

Thanks


SV Sarathkumar V Syncfusion Team April 6, 2016 12:46 PM UTC

Hi Ian,

Thank you for contacting Syncfusion support.

A support incident to track the status of the
your query has been created under your account. Please log on to our support website to check for further updates,

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Please let me know if you have any questions.

Regards,
Sarath


ST Stefano Tessarin April 28, 2016 01:05 PM UTC

Hi,

I'm facing the same problem on Azure. Is it possible, as suggested by Ian, to convert image based on bitmap instead of metadata? This should fix easily your issue.


SV Sarathkumar V Syncfusion Team April 29, 2016 10:53 AM UTC

Hi Stefano,

Thank you for contacting Syncfusion support.

A support incident to track the status of the your query has been created under your account. Please log on to our support website to check for further updates,

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents 

Please let me know if you have any questions.

Regards, 
Sarath 



TS Tetteh Sackey July 17, 2016 05:09 PM UTC

I'm facing the same problem on Azure. Has the suggestion by Ian been applied?


SY Sethumanikkam Yogendran Syncfusion Team July 18, 2016 09:39 AM UTC

Hi Tetteh Sackey,

Thank you for your update.

We regret to let you know that the support for “Word to PDF conversion in Azure environment” is not yet implemented and we have already logged this as a feature request in our database. We will implement this feature in any of our upcoming releases The feature implementation would also greatly depend on the factors such as product design, code compatibility and complexity. We request you to visit our website periodically for feature related updates.

As a workaround you shall make use of Azure cloud service to convert a Word document as Pdf and use that cloud service as service reference in your azure web site.

Thanks,
Sethumanikkam.Y



DC Daniel Casado November 11, 2016 09:26 AM UTC

Hi,

today I'm facing the same problem with converting a presentation file to PDF.
I'm aware of this problem by using other vendors for reporting in the past.  But they have solved this today, so that I'm not facing this error until today.

Is there any expected timeframe to solve this problem by SyncFusion?

Migrating from App Service (Web Site) to a Cloude Service is not an option for us.


Regards,
Daniel


AP Arun Prasad Matheshwaran Syncfusion Team November 16, 2016 11:49 AM UTC

Hi Daniel,

Thank you for contacting Syncfusion support.

A support incident to track the status of your query has been created under your account. Please log on to our support website to check for further updates,

https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents

Please let us know if you need further clarifications regarding this, 

Thanks, 
Arun 



BV Brad Vossler November 18, 2016 03:57 AM UTC

Any chance I can get updates on this as well? Thanks


SY Sethumanikkam Yogendran Syncfusion Team November 21, 2016 11:03 AM UTC

Hi Brad,

Thank you for contacting Syncfusion support.

We regret to let you know that the support for “Word to PDF and PPTX to PDF conversions in Azure environment” is not yet implemented and we have already logged this as a feature request in our database. We will implement this feature in any of our upcoming releases. The feature implementation would also greatly depend on the factors such as product design, code compatibility and complexity. We request you to visit our website periodically for feature related updates.

A support incident to track the status of your query has been created under your account. Please log on to our support website to check for further updates,

https://www.syncfusion.com/account/login

Please let us know if you need further clarifications regarding this.

Thanks,
Sethumanikkam.Y



TF Torsten Fischer November 24, 2016 06:48 AM UTC

Any chance I can get updates on this as well? Thanks


SY Sethumanikkam Yogendran Syncfusion Team November 25, 2016 04:42 AM UTC

Hi Torsten,

Thank you for contacting Syncfusion support.

We regret to let you know that the support for “Word to PDF and PPTX to PDF conversions in Azure environment” is not yet implemented and we have already logged this as a feature request in our database. We will implement this feature in any of our upcoming releases. The feature implementation would also greatly depend on the factors such as product design, code compatibility and complexity. We request you to visit our website periodically for feature related updates.

Thanks,
Sethumanikkam.Y



RF Ryan Finken December 28, 2016 08:03 PM UTC

I'm facing the same problem and would like to receive updates on it as well.

I just deployed a new feature using this converter and was disappointed to see it fail on the Azure platform. Is there an ETA as to when this change will be implemented? This seems to have been idle since April 2016.


SY Sethumanikkam Yogendran Syncfusion Team January 2, 2017 12:42 PM UTC

Hi Ryan Finken,

We regret for the inconvenience caused.

Still we have not resolved GDI limitations specific to Azure environment. We have plans to resolve these limitations in near future and we are working towards finding the alternate solution for these limitations. At this moment we cannot provide any concrete timeline for this feature. We will let you know once this feature has been implemented.

Please let us know if you have any other questions.

Thanks,
Sethumanikkam.Y



MC Mark cho January 20, 2017 08:38 PM UTC

Does it work with AzureWebJob?


SV Sivasubramani V Syncfusion Team January 27, 2017 01:39 PM UTC

Hi Mark,

We regret for the inconvenience caused.

Due to the GDI+ limitation, DocIO doesn’t provide the support for Word to PDF conversion in Azure platform using Azure WebJob.

As mentioned in the previous update, we have plans to resolve these limitations (GDI+ limitation in Azure platform) in Azure environment. At this moment, we cannot provide any concrete timeline for this feature. Let you know once this feature has been implemented.

Please let us know if you have any other questions.

Thanks,
Sivasubramani.  



DC Daniel Casado December 12, 2017 03:01 PM UTC

Hi, Are there any updates for this issue?

Regards,
Daniel


SY Sethumanikkam Yogendran Syncfusion Team December 13, 2017 04:49 AM UTC

Hi Daniel,

Thank you for your update.

We are glad to inform you that the support for Word to PDF conversion using Essential DocIO in Azure has been already provided in our latest Essential Studio version (since v15.3.0.26).


You can download our Essential Studio 2017 Volume 3 - v15.3.0.26 from the following link.
https://www.syncfusion.com/forums/131983/essential-studio-2017-volume-3-release-v15-3-0-26-is-available-for-download

Please find the below KB link to know more about Word to PDF conversion in Azure Environment:
https://www.syncfusion.com/kb/7751/is-it-possible-to-perform-word-to-pdf-conversion-in-azure-environment

Please let us know if you have any other questions.

Regards,
Sethumanikkam.Y



BD Bart de keersmaeker January 30, 2019 12:38 PM UTC

Dear,

Even with the latest version available, we are still facing this issue.

We are facing an issue with rendering our template (on Azure)
This is a known issue (for a long time) and we were hoping to have a fix delivered by Syncfusion in order to be able to use this functionality in our application.

- Does not happen on our local machine
- Even adding "WordDocument.EnablePartialTrustCode = true;" does not fix the problem
- Is the drawToImage on a worddocument supported, if this document contains emf-images ? Can we detect if these images are embedded in the word document ?

System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+.
   at System.Drawing.Graphics.CheckErrorStatus(Int32 status)
   at System.Drawing.Graphics.DrawImage(Image image, Single x, Single y, Single width, Single height)
   at System.Drawing.Graphics.DrawImage(Image image, RectangleF rect)
   at Syncfusion.DocIO.Rendering.DrawingContext.DrawPicture(WPicture picture, LayoutedWidget ltwidget)
   at Syncfusion.DocIO.Rendering.DrawingContext.Draw(IWidget widget, LayoutedWidget layoutedWidget)
   at Syncfusion.DocIO.Rendering.DrawingContext.Draw(LayoutedWidget layoutedWidget, Boolean isHaveToInitLayoutInfo)
   at Syncfusion.DocIO.Rendering.DrawingContext.DrawBehindWidgets(LayoutedWidgetList behindWidgets, IWidget ownerWidget, Int32 length, Boolean isHaveToInitLayoutInfo)
   at Syncfusion.DocIO.Rendering.DrawingContext.Draw(Page page)
   at Syncfusion.DocIO.DLS.Rendering.DocumentLayouter.DrawToImage(Int32 startPageIndex, Int32 noOfPages, ImageType imageType, MemoryStream stream)
   at Syncfusion.DocIO.DLS.Convertors.WordToImageConverter.ConvertToImage(WordDocument document, ImageType imageType, MemoryStr


DB Dilli Babu Nandha Gopal Syncfusion Team January 31, 2019 06:28 PM UTC

Hi Bart, 

Greetings from Syncfusion. 

From the given details, we suspect that the input Word document contains metafile images. Currently, the metafile images (*.wmf, *.emf) in Word document are not supported while converting to PDF in Azure environment which is already a known limitation. We have already considered this exception problem at our end and will provide fix to skip the exception to convert the given Word document as PDF. The fix will be included in our 2018 Volume 4 SP1 release which is expected to be rolled out in February 2019.

Also, could you please provide us the input Word document which used at your end. Thereby, we will check and provide you the confirmation whether the reported problem will be fixed in 2018 Volume 4 SP1 release.
Note: If you have any confidential data in your Word document, please replace with some dummy data and provide us the same. We just need your document to recreate the problem you face. 

Regards, 
Dilli babu. 



DL Daryl Liscano replied to Dilli Babu Nandha Gopal September 2, 2019 12:34 AM UTC

Hi Bart, 

Greetings from Syncfusion. 

From the given details, we suspect that the input Word document contains metafile images. Currently, the metafile images (*.wmf, *.emf) in Word document are not supported while converting to PDF in Azure environment which is already a known limitation. We have already considered this exception problem at our end and will provide fix to skip the exception to convert the given Word document as PDF. The fix will be included in our 2018 Volume 4 SP1 release which is expected to be rolled out in February 2019.

Also, could you please provide us the input Word document which used at your end. Thereby, we will check and provide you the confirmation whether the reported problem will be fixed in 2018 Volume 4 SP1 release.
Note: If you have any confidential data in your Word document, please replace with some dummy data and provide us the same. We just need your document to recreate the problem you face. 

Regards, 
Dilli babu. 


Good day,

Do you have alternative solution on this? We're having trouble on deploying our project to Azure.


Thanks,
Daryl


VA Vijayasurya Anandhan Syncfusion Team September 3, 2019 08:51 AM UTC

Hi Bart,

Thank you for your update.
 
 
As mentioned earlier, metafile images such as (*.wmf, *.emf) in Word document are not supported while converting the Word document to PDF in Azure environment which is already a known limitation.    

We are glad to announce that starting with version 17.1 (2019 Vol 1) in our 
Essential DocIO library, to avoid this exception, if the word document holds “wmf” and “emf” image, we have replaced the original image with the default “RedX” image.


Please find the release notes details from the below link:
https://help.syncfusion.com/aspnetmvc/release-notes/v17.1.0.38?type=all#docio  

Please let us know if you need further assistance in this.

Regards,
Vijayasurya A
 



ER Ernst March 10, 2023 02:44 PM UTC

Hi, 

I'm using Syncfusion.DocToPdfConverter.ClientProfile (version 20.4.0.52) to convert a Word document in PDF.

Code runs in a Dynamics 365 CE plugin (cloud hosted).


I'm getting this error:

System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: A generic error occurred in GDI+. (Fault Detail is equal to Exception details:
ErrorCode: 0x80040224
Message: A generic error occurred in GDI+.
TimeStamp: 2023-03-10T14:41:45.4838781Z
OriginalException: PluginExecution

There are no images in the Word document, just plain text and some tables.

The GDI+ eception should be fixed, as described in previous posts. So what's causing this exception?


Best regards,

Ernst Wolthaus



SB Suriya Balamurugan Syncfusion Team March 13, 2023 02:12 PM UTC

Hi Ernst,

The previous updates and solutions in the forums are related to Support for Word to PDF conversion in Azure environment.

But you are facing the problem in a Dynamics 365 CE plugin (cloud hosted). We have already analyzed about the Word to PDF conversion feasibility in this environment and found that Microsoft Dynamics has limited support for GDI+. So Word to PDF conversion is not supported in Microsoft Dynamics using DocToPDFConverter (internally used GDI+) which is already a known limitation.

To resolve this problem, we suggest you to use the Syncfusion.DocIORenderer.Net.Core NuGet package in which internally we used the SkiaSharp library to convert a Word document to PDF and provide us confirmation whether the reported problem gets resolved or not using this solution.

Refer the below code snippet to convert Word to PDF using DocIORenderer.

//Open the existing Word document.

using (WordDocument wordDocument = new WordDocument(inputDocumentStream, FormatType.Automatic))

{

    //Create an instance of DocIORenderer.

    using (DocIORenderer renderer = new DocIORenderer())

    {

        //Convert Word document into PDF document.

        using (PdfDocument pdfDocument = renderer.ConvertToPDF(wordDocument))

        {

            //Save the PDF.

            MemoryStream pdfStream = new MemoryStream();

            pdfDocument.Save(pdfStream);

        }

    }

}


Regards,
Suriya Balamurugan.


Loader.
Live Chat Icon For mobile
Up arrow icon