final String PREFIX = "aspose/testfiles/index.html";
URL url = Resources.getResource(PREFIX);
String text = Resources.toString(url, Charsets.UTF_8);
// Instantiate Document object
Document doc = new Document();
// Add a page to pages collection of PDF file
Page page = doc.getPages().add();
// Instantiate HtmlFragment with HTML contents
HtmlFragment titel = new HtmlFragment(text);
// set MarginInfo for margin details
MarginInfo Margin = new MarginInfo();
// Set margin information
// Add HTML Fragment to paragraphs collection of page
// Save PDF file
Please try to render
with any html text with length > 5660,
it will take a long time and at the end it will lead to
exception java.lang.OutOfMemoryError: Java heap space
If text length is less then 5659 chars
it will work just fine.
Are you sure you are using html code in that text?
What is the status of that bug?
The ticket ID PDFJAVA-36752 is pending for analysis and not resolved yet. Our product team will investigate as per the development schedule. We will let you know once a significant progress has been made in this regard.
It looks like you and I are having a very similar issue, except mine is in .NET. Since the Java code is derived from .NET, it’s likely that if either issue is fixed, both of our problems will go away. My ticket is PDFNET-44881 .
The difference with my issue is that it occurs when multiple HTML Fragments of substantial size are put into the same document, although none of my fragments get anywhere close to your 5000 string length. Besides this, the error message we receive and circumstances of the error are practically the same. There is some kind of problem with the way HTML Fragment is having memory allocated and its buffer is being processed.
Thank you for the details. The issue logged under the ticket ID PDFJAVA-36752 is similar to PDFNET-44881, but not the same. We will notify here in this thread once it is fixed.