Parallel Processing

If I attempt to run all of the following in parallel (using several Task.Run commands) for a single source document with UseCache not set to false, imageHandler.GetPages occasionally fails.

imageHandler.GetPdfFile
htmlHandler.GetPages
imageHandler.GetPages

The exception is "Parameter is not valid."
at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)
at System.Drawing.Image.FromStream(Stream stream)
at GroupDocs.Viewer.Model.Utilities.SaveAsImage(String path, String imageName, Stream imageContent)

If UseCache is set to false, everything works ok.


Hi Hendrix,


Thanks for sharing your issue with us.

Can you please provide us the sample source code so that we can reproduce the issue at our end? Also, please confirm whether do you get this issue for all the documents or for a particular one. We shall be looking forward to your response.

Warm Regards

This was resolved by not sharing a ViewerConfig object between tasks running in parallel.


If the ViewerConfig is shared between a task running htmlHandler.GetPages and another task running imageHandler.GetPages, then the image handler is occasionally passed a Stream that is actually HTML data rather than image data.

Hi Hendrix,


It is good to know that your issue has been resolved. Thanks for sharing the details with us. In case you would have any other issues or questions, please feel free to let us know.

Have a nice weekend.
Warm Regards