Skip to content
English
  • There are no suggestions because the search field is empty.

[Public] Preventing HTML to PDF Rendering Crashes in .NET Framework Applications

When rendering HTML to PDF in .NET Framework applications, especially when rendering large HTML stored in memory variables, some developers may encounter unexpected crashes.

var html = File.ReadAllText("large.html"); 
PdfDocument pdf = renderer.RenderHtmlAsPdf(html);

Upon investigation, a common cause for this issue is the "Prefer 32-bit" setting in the project configuration. By default, this option is enabled, which compiles the application to run as a 32-bit process. However, 32-bit processes have memory limitations that can lead to instability or crashes in memory-intensive tasks.

To resolve this, simply uncheck the "Prefer 32-bit" option in your project settings and recompile the application. This will allow it to run as a 64-bit process, which can handle larger memory loads more efficiently.

Based on findings, disabling this setting eliminated the crash, improving both stability and performance during PDF generation.