Application Setup
1. We are using Spire.Office v 7.12.4, .Net 6.0, and C# in Visual Studio 2022 environment
2. We are testing an Azure Service Bus with a topic and a subscription
3. C# Function App is deployed in Azure and is triggered whenever a message is published to the topic
4. Function App consumes Spire.Office library to dynamically replace place holders in a Word document with custom text and writes it to Azure File Storage as a PDF file
5. Host.json sets maxConcurrentCalls to the Function App to 16 and maxConcurrentSessions to 8
6. We have a separate Console application that fires messages to the topic, and we observe the behavior of the function by analyzing its logs
Application Behavior
1. We observed that even under a moderate load of 100 messages sent in a batch there are (about) 10% errors in generating a corresponding PDF document when calling the mail merge method
2. In a batch of 704 messages, we saw about 8% errors
3. Here is a typical error message:
4. 2023-02-02T19:24:58.417 [Error] System.OutOfMemoryException: Out of memory.
5. at System.Drawing.Image.ValidateImage(IntPtr image)
6. at System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData)
7. at spr䡸.(Byte[] A_0)
8. at spr䒌.ᜀ(spr䞱 A_0)
9. at spr䒐.ᜀ(spr䞱 A_0)
10. …
11. at spr㆓.ᜀ(sprㅳ A_0, spr⯂ A_1)
12. at spr㆓.ᜂ(sprㅳ A_0)
13. at Spire.Doc.Document.ᜅ(Stream A_0, ToPdfParameterList A_1)
14. at Spire.Doc.Document.SaveToStream(Stream stream, ToPdfParameterList paramList)
Can you please help us identify why we are getting this exception for some of our files and how we can avoid it?
Thanks so much,
Ben