Welcome Guest Search | Active Topics | Sign In | Register

Memory Exception when converting XML to PDF Options
MIchala Kousted Tonsberg
Posted: Monday, March 4, 2024 6:28:40 AM
Rank: Newbie
Groups: Member

Joined: 10/17/2017
Posts: 5
Hi.

I'm encountering a memory exception when using ConvertUrl to convert an XML file (56mb) to PDF. Files of this size are an outlier, but they need to be handled all the same.
I've just updated to version 24.0.49 in the hopes that it might have improved the situation, but unfortunately I'm still stuck.

I tried splitting the original file into smaller chunks and hoped I might've been able to convert each chunk to a separate PDF and then merge them together, but that conversion fails as well, presumably because each chunk holds invalid XML by not being able to close each tag properly (a tag might open in one chunk, but close in another).
I've also tried disabling RetrieveNodeText. Same result.

I'm assuming that ConvertUrl's input needs to have valid XML in order to attempt to convert it, if that is the case, are there any other approaches I could take, or do you have any other ideas?
eo_support
Posted: Monday, March 4, 2024 10:19:33 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi,

It's unlikely that a file of this size will succeed. However splitting it into small files should work. ConvertUrl should be able to convert unclosed XML by automatically closing unclosed elements, even though it is always better for the XML to be already properly closed. So instead of just "slicing" the huge XML file into small chunks, you can use some kind of XML processing APIs such as XmlDocument or XSLT to generate properly formatted small XML files.

Thanks!
MIchala Kousted Tonsberg
Posted: Tuesday, March 5, 2024 3:36:13 AM
Rank: Newbie
Groups: Member

Joined: 10/17/2017
Posts: 5
I appreciate the feedback, but that solution is unfortunately not an option for us. We must not modify the XML structure, so the tags need to be opening/closing the way they currently are.
eo_support
Posted: Tuesday, March 5, 2024 10:29:40 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
You can share the file with us and we can take a look to see if we can find a solution for you. However there is no guarantee that there is one. If that's the case you must reduce the input file size.
MIchala Kousted Tonsberg
Posted: Tuesday, March 5, 2024 10:42:28 AM
Rank: Newbie
Groups: Member

Joined: 10/17/2017
Posts: 5
I'll ask to have a sanitized version of the file. Where do I send it to?
eo_support
Posted: Tuesday, March 5, 2024 10:52:07 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
You can send it to us through our contact us page:

https://www.essentialobjects.com/contact
MIchala Kousted Tonsberg
Posted: Thursday, March 7, 2024 7:53:11 AM
Rank: Newbie
Groups: Member

Joined: 10/17/2017
Posts: 5
I've tried to drag and drop the XML file as both a ZIP and a TXT, the contact page isn't accepting either. What else can I do to supply you with the offending XML?
eo_support
Posted: Thursday, March 7, 2024 9:49:01 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
It should accept zip file. How big is the zip file?
MIchala Kousted Tonsberg
Posted: Friday, March 8, 2024 2:17:53 AM
Rank: Newbie
Groups: Member

Joined: 10/17/2017
Posts: 5
It's 581KB. When I try and drag it, the Drag n Drop area just remains unresponsive.
eo_support
Posted: Friday, March 8, 2024 10:51:23 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi,

Please try to email it to us:

https://www.essentialobjects.com/forum/test_project.aspx

Thanks!
eo_support
Posted: Thursday, March 14, 2024 9:51:50 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi,

We have looked into the file you sent to us. It indeed cause out of memory exception in the browser engine and crashes the browser engine. Even Google Chrome browser is not able to load and display the file. It resulted in the same crash.

Because even Google Chrome crashes on the same file, it is not possible for us to load the file without running into the same issue. You will have to modify your input file to reduce the size. We see that your input XML is basically a large list of RouteRob element. So you can consider using this strategy:

1. Create a separate HTML file that represents the section of XML before the first RouteRob element;
2. Create multiple HTML files each represents a reasonable amount (for example, 1000) of RouteRob element;
3. Create another HTML file that represents the closing tag after the last RouteRob element;

You can then use a loop to convert all these HTML into a single PdfDocument while using HtmlToPdfOptions.Follow after reach conversion so that they will appear in the output PDF file directly one after another.

Hope this helps.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.