How to get textareas resized in conversion from html to image

Our HTML renders correctly in the browser, as shown in the attached screenshot:
Screenshot 2026-01-07 144840.png (11.3 KB)

However, when we generate the image using Aspose, the output looks different, as shown here:
6_e08c4258-c6b7-4083-9d47-b66c883aadf2_output.png (79.8 KB)

a { text-decoration: none; color: #464feb; } tr th, tr td { border: 1px solid #e6e6e6; } tr th { background-color: #f5f5f5; }

We are new to using Aspose. Previously, we used Selenium WebDriver without any issues resizing textareas. Our page includes a JavaScript script that dynamically resizes all textareas, which seems to work fine in the browser but not in the Aspose-generated image.

Could you please advise how to ensure that JavaScript-based resizing is applied when rendering with Aspose? Are there specific settings or steps we need to enable JavaScript execution or adjust the viewport?

This is the html code :

 <textarea  name='txt_36574_36574' customtype='42'  data-qid='36574' data-qparentid='-1'  readonly class='ta_custom1 ctrl_base' wrap='on' style='width:150px; height: auto; ' data-masked='' >tttt
t
t
t
t

tt


t</textarea>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.7.1.min.js"></script>
<script>
$("textarea").each(function () {
  this.style.height = this.scrollHeight + "px";
  this.style.overflowY = "hidden";
}).on("input", function () {
  this.style.height = "auto";
  this.style.height = this.scrollHeight + "px";
});   

   htmlLicense.SetLicense(HttpContext.Current.Server.MapPath("~") & "\bundles\Aspose.HTML.NET.lic")

   Dim FilGuidname As String = HttpContext.Current.Session("brugerid") & "_" & Guid.NewGuid().ToString
   Dim documentPath As String = Path.Combine(AppDomain.CurrentDomain.BaseDirectory & "App_Data\", FilGuidname & "_answer.html")
   Dim savePath As String = Path.Combine(AppDomain.CurrentDomain.BaseDirectory & "App_Data\", FilGuidname & "_output.png")
   File.WriteAllText(documentPath, html)

   Dim imagebytes() As Byte = Nothing

  Using document As New Aspose.Html.HTMLDocument(html, ".")




       If document.ReadyState = "complete" Then

           Dim pdfOptions As New ImageSaveOptions(ImageFormat.Jpeg)

           pdfOptions.BackgroundColor = System.Drawing.Color.Beige
           pdfOptions.Css.MediaType = MediaType.Print
           pdfOptions.PageSetup.PageLayoutOptions = PageLayoutOptions.UseWidestPage
           pdfOptions.PageSetup.ScaleLimit = 0.8
           pdfOptions.PageSetup.AnyPage.Margin.Left.SetAuto()
           Converter.ConvertHTML(document, pdfOptions, savePath)
               imagebytes = File.ReadAllBytes(savePath)
       End If
   End Using


   Return imagebytes

@riskminder

  • Are you able to confirm whether the jQuery script is being executed during HTML rendering in Aspose.HTML.NET, given that JavaScript execution is not enabled by default?
  • Does the HTML file saved to disk include all required external resources (like jQuery) when opened independently, or does it rely on online availability of CDN-hosted scripts?
  • Have you tried enabling JavaScript execution in Aspose.HTML.NET using WebView with a WebWindow instance, since HTMLDocument alone does not support dynamic script execution?
  • Is the scrollHeight of the textarea being correctly calculated during rendering, or could the issue stem from missing layout reflow due to deferred script execution?

Thanks for the leads we will investigate

@riskminder

The user is experiencing a discrepancy between browser rendering and Aspose.HTML.NET output, specifically regarding JavaScript-driven textarea resizing during HTML-to-image conversion. The issue involves code execution, rendering behavior, and configuration of Aspose.HTML.NET, with provided code and context about dynamic script execution.

Regarding bullet 1:
How do you enable JavaSript in Aspose.HTML.NET?
By the way the same HTML string is used before by Selenium with no problems so we think that external resources are available

@riskminder

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): HTMLNET-6862

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.