Hi,
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();
Margin.setBottom(10);
Margin.setTop(200);
// Set margin information
titel.setMargin(Margin);
// Add HTML Fragment to paragraphs collection of page
page.getParagraphs().add(titel);
// Save PDF file
doc.save("output.pdf");
Hi,
Please try to render
new HtmlFragment(text)
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.
Hi,
Hi,
Are you sure you are using html code in that text?
TEST
”, 520);Hi,
What is the status of that bug?
@Damian_Szuta,
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.
Best Regards,
Imran Rafique
Hey Damian,
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.