I’m trying to convert HTML layouts into images using the Converter.convertHtml function. Below is the code snippet i’m using.
def width = 4
def height = 1
final def html = """<html><head><link href="https://cdn.quilljs.com/1.3.6/quill.snow.css" rel="stylesheet"></head><body><div class="ql-editor" style="background-color: #ffffff; height: 230px; font-family: sans-serif; overflow-y: hidden"><p class="ql-align-center"><strong>QWERTYUIOP</strong></p><p class="ql-align-center"><strong>ASDFGHJKL</strong></p><p class="ql-align-center"><strong>ZXCVBNM</strong></p></div></body><html>"""
// Initialize an HTML document
final document = new HTMLDocument(html, ".")
final streamProvider = new MemoryStreamProvider()
try {
ImageSaveOptions options = new ImageSaveOptions(ImageFormat.Png);
PageSetup pageSetup = new PageSetup();
Page anyPage = new Page();
anyPage.setSize(
new Size(
Length.fromPixels(width * 420),
Length.fromPixels(height * 230)
)
);
pageSetup.setAnyPage(anyPage);
options.setPageSetup(pageSetup);
// Convert HTML to Image by using the MemoryStreamProvider
Converter.convertHTML(document, options, streamProvider.lStream)
The MemoryStreamProvider class is taken from the sample provided in link
It’s taking minutes to execute; especially the HtmlDocument construction. Is this behavior expected or is there something else going on? Since this happens every time & we may need to convert 4-5 HTML codes, it’s causing significant performance issue in our system.
Please try to increase the Java Heap Size if it helps. In case issue still persists, please share your sample HTML in .zip format with us along with the information of time taken by the API. We will test the scenario in our environment and address it accordingly.
We were able to notice the issue in our environment while testing the scenario with 21.3 version of the API. Therefore, we have logged a ticket as HTMLJAVA-792 in our issue tracking system. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.
We are porting all features and classes from .NET API to Aspose.HTML for Java at the moment and performance of the API is expected to be improved very much after the porting is done. The task is time taking and we are afraid that we cannot share any reliable ETA at the moment before your ticket is fully investigated. However, we have recorded your concerns and will surely update you once we have additional information in this regard. Please give us some time.
We are afraid that there are no updates at the moment as the work of porting .NET features into Java API is not yet done. We will update you once we have some news in this regard. We appreciate your patience in this matter. Please spare us some time.
We are afraid that no significant progress is made towards completion of the porting. The work is still under process. However, we will surely inform you once we have some updates in this regard.
We regret to inform that no updates are available at the moment as porting is not done yet. We will inform you once we have additional information in this regard. We apologize for the inconvenience and delay.