We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

HTML with height=100% on the html tag and width=100% on a nested table, long text isn't wrapped

When loading an HTML file where the root html element has height 100%, and there is a nested table with width 100%, long lines of text in the nested table aren’t wrapped correctly.

If a page width is specified, the contents of the nested table are clipped instead of wrapped.
If no page width is specified, the resulting PDF has a page size wide enough to contain the long lines of text without any line breaks.

We are getting html generated like this from an external system, so we would prefer not to have to manipulate the html.

Sample code:

var htmlString = @"<!DOCTYPE html>
<html style=""height: 100%"">
<head>
</head>
    <body>
        <table>
            <tbody>
                <tr>
                    <td>
                        <table style=""width: 100%"">
                            <tbody>
                                <tr>
                                    <td>
                                        long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text long text
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                        <br>
                    </td>
                </tr>
            </tbody>
        </table>
    </body>
</html>";

using (var ms = new MemoryStream())
{
    using (var sw = new StreamWriter(ms, Encoding.UTF8, 1024, true))
    {
        sw.Write(htmlString);
        sw.Flush();
        ms.Seek(0, SeekOrigin.Begin);
    }
    
    using (var doc = new Document(ms, new HtmlLoadOptions()
    {
        PageInfo = new PageInfo()
        {
            Height = PageSize.A4.Height,
            Width = PageSize.A4.Width,
        }
    }))
    {
        doc.Save("clipped.pdf");
    }
}

@morkl,

Can you please share source code along with generated result and desired result in form of sample to further investigate this issue.

The complete source code is in my original post.

It generates this file, where the table overflows the page:
clipped.pdf (31.0 KB)

The desired result is having the long line of text wrap - which it does if I remove the style attribute from either the html tag or the nested table tag:
expected.pdf (30.9 KB)

@morkl,

Thanks for contacting support.

We were able to notice the issue that you have mentioned and logged it as PDFNET-48165 in our issue tracking system. We will definitely look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.