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.
I have tested the scenario using Aspose.Pdf for .NET 17.4 and I am unable to notice any issue when using Visual Studio 2010 running over Windows 7 (x64). For your reference, I have also attached the output generated over my end.
Can you please try using the latest release and in case the problem still occurs, please share some further details, which can help us in replicating the issue in our environment. We are sorry for this inconvenience.
I have again tested the scenario and as per my observations, a System.StackOverflowException is being generated. For the sake of correction, I have logged it as PDFNET-42838 in our issue tracking system. We will further look into the details of this problem and will keep you posted on the status of correction. Please be patient and spare us little time. We are sorry for this inconvenience.
[C#]
var doc = new Aspose.Pdf.Document();
var page = doc.Pages.Add();
var textSegment1 = new Aspose.Pdf.Text.TextSegment("text fragment test1")
{
TextState =
{
// Font = Aspose.Pdf.Text.FontRepository.FindFont("Meta Serif Offc Book")
}
};
var text1 = new Aspose.Pdf.Text.TextFragment();
text1.Segments.Add(textSegment1);
page.Paragraphs.Add(text1);
String longHtmlText = StringUtils_repeat("TEST", 9000);
HtmlFragment htmlFragment = new HtmlFragment(longHtmlText);
page.Paragraphs.Add(htmlFragment);
var textSegment2 = new Aspose.Pdf.Text.TextSegment("text fragment test2")
{
TextState =
{
// Font = Aspose.Pdf.Text.FontRepository.FindFont("Proxima Nova Regular")
}
};
var text2 = new Aspose.Pdf.Text.TextFragment();
//text2.TextState.Font = Aspose.Pdf.Text.FontRepository.FindFont("Trade Gothic LT Com Bold");
text2.Segments.Add(textSegment2);
page.Paragraphs.Add(text2);
doc.Save(@"c:\pdftest\fontbreak.pdf");
private string StringUtils_repeat(string v1, int v2)
{
if (v2 == 1) return v1;
else return v1 + StringUtils_repeat(v1, v2 - 1);
}