Free Support Forum - aspose.com

HTML to image conversion taking minutes to finish

Hi,

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.

Help much appreciated.

Aspose.HTML version: 21.3
System: Ubuntu LTS 18.04.5
Specifications: ntel® Core™ i7-9700 CPU @ 3.00GHz × 8

@srijal

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.

Hi,

Increasing the heap size doesn’t seem to help. I ran the conversions again and go the same results.

HTML attached.

The timing to convert this HTML code to image for different HTML codes is as follows:
HTMLs.zip (1.3 KB)

  • 3 s`
  • 100 s
  • 100 s

Heap size used: 8 GB

@srijal

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 sorry for the inconvenience.

Could you let us know if there’s any sort of tentative date of when a fix for this might land if possible?

@srijal

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 sorry for the inconvenience.

Any updates on the progress if possible?

We’re waiting on a possible fix to land a feature in our app. Any updates will be appreciated.

@srijal

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.