We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ASPOSE.PDF HtmlFragment Size Limit Bug


We are getting SystemOutOfMemory exception when we are trying to create PDF from Html content, and the content size exceeds more than(250-300 kb). We are using Aspose PDF HtmlFragment for rendering html content in PDF.

Also here we are attaching the sample code to understand our scenario better.

Please suggest/provide any alternative or work around for this issue.

SampleCode_SystemOutOfMemoryException.zip (692 Bytes)



Thanks for contacting support.

I have tested the scenario using your code snippet and noticed that the method (StringUtils_repeat(string v1, int v2)) caused the System.OutOfMemoryException Exception. The reason is that, you were using quite basic way to concatenate two string using plus (+) sign, which consumes a lot of memory and in case if string length exceeds than 1000, it causes exception.

In order to concatenate long length string, the recommended way is using StringBuilder. Please check following modified method which I have used to generate long HTML string and generated document in our environment. For your reference, I have also attached an output, generated over our end.

private static string StringUtils_repeat(string v1, int v2)
 StringBuilder sb = new StringBuilder();
 int i = 1;
 while (i < v2)
 return sb.ToString();

Output : fontbreak.pdf (582.1 KB)

Please use above method to generate long length HTML string and in case if you still face any issue, please let us know. We will again test the scenario in our environment and address it accordingly.

Best Regards,
Asad Ali