HTML to image - scaling

I’m using Aspose.HTML for .NET version 19.2 to render an HTML document as an image, using this example as a starting point.

The document I need to convert to an image is an organisational structure diagram, created by the Google Visualization API, which is rendered as a table. This table is the only element in the body of the HTML document, and there are no nested tables.

Due to different organisations having wildly differing structures, the table can vary in size from one or two row/columns up to 20 or so rows and several hundred columns.

What I would like to do is make an image of the entire table, which I can then scale to include in a PDF.

I’ve written a console app to test this, using the following c# code:

private const string Directory = "C:\\Temp\\Aspose";

static void Main(string[] args)
{
    GenerateImage("SimpleTable.html");
    GenerateImage("ComplexTable.html");
}

private static void GenerateImage(string htmlFilename)
{
    using (var imageMemoryStream = new MemoryStream())
    using (var imageDevice = new ImageDevice(new ImageRenderingOptions(), imageMemoryStream))
    using (var htmlRenderer = new HtmlRenderer())
    using (var htmlDocument = new HTMLDocument(Path.Combine(Directory, htmlFilename)))
    {
        htmlRenderer.Render(imageDevice, htmlDocument);
        var image = Image.FromStream(imageMemoryStream);
        image.Save(Path.Combine(Directory, $"Structure{DateTime.Now:yyyyMMddHHmmssfff}.png"), ImageFormat.Png);
    }
}

I have three problems:

  1. The image seems to be rendered from an imaginary viewport. The image of the simple table is much bigger than it needs to be and has small table at the top of the image with the rest of the image empty, while the image of the complex table has exactly the same dimensions but contains a slice of the table with the rest of it cut off. Is it possible to change this so that the image is sized appropriately for the page being rendered?

  2. The text in the cells of the complex table spills out beyond the cells.

  3. The CSS for rounded borders seems to be completely ignored.

I’ve attached a zip file containing the html for a simple and complex table, and the images produced.

Simple.png (49.1 KB)
Complex.png (259.3 KB)

@jsayce

Thank you for contacting support.

We have worked with the data shared by you and have been able to reproduce the problem in our environment. A ticket with ID HTMLNET-1799 has been logged in our issue management system for further investigation and resolution. The ticket ID has been linked with this thread so that you will receive notification as soon as the ticket is resolved.

We are sorry for the inconvenience.

The issues you have found earlier (filed as HTMLNET-1799) have been fixed in this update. This message was posted using Bugs notification tool by pavel.petrushechkin