Aspose.HTML Page Breaks in HTML are freezing the application

Hello, we are using Aspose.HTML to convert an HTML page to PDF. We have styling to create page breaks when printing but when that style is applied in Aspose.HTML it causes the application to lock up and enter an infinite loop. We are on version 23.12.0 of Aspose.HTML for .NET. Application is not dotnet core, it is dotnet framework.

public static byte[] ConvertHTMLToPDF(string html, bool landscape = false)
{
    using (var config = new Aspose.Html.Configuration())
    {
        config.Security |= Sandbox.Scripts;
        using (var doc = new HTMLDocument(html, ConfigurationManager.AppSettings["APIUrl"] ?? string.Empty, config))
        {
            var saveOptions = new Aspose.Html.Saving.PdfSaveOptions
            {
                JpegQuality = 100
            };

            double width = landscape ? 11 : 8.5;
            double height = landscape ? 8.5 : 11;

            var pageSize = new Aspose.Html.Drawing.Size(Aspose.Html.Drawing.Unit.FromInches(width), Aspose.Html.Drawing.Unit.FromInches(height));
            var pageMargin = new Aspose.Html.Drawing.Margin(20, 10, 20, 10);

            saveOptions.PageSetup.PageLayoutOptions = Aspose.Html.Rendering.PageLayoutOptions.ScaleToPageWidth;
            saveOptions.PageSetup.AnyPage = new Aspose.Html.Drawing.Page(pageSize, pageMargin);

            using (var streamprovider = new AsposeHtmlStreamProvider())
            {
                // A "Nullable object must have a value" exception from Aspose here seems to
                // indicate a failure to break pages cleanly. Try converting a single page
                // worth of content at a time.
                Aspose.Html.Converters.Converter.ConvertHTML(doc, saveOptions, streamprovider);
                return streamprovider.Streams.First().ToArray();
            }
        }
    }
}

HTML is like this:

.page-break {
    page-break-before: always;
    break-before: always;
    break-before: page;
}

..markup
<div class="page-break"></div>
..more markup

@twagner

Would you please share your complete HTML in .zip format with us? We will test the scenario in our environment and address it accordingly.

Crest HTML Aspose Issue.zip (31.0 KB)

I take the external CSS files and download them into one flat HTML file, attached.

Crest HTML Aspose Working HTML.zip (79.6 KB)

Here is a working version of the same file. I removed the css that set the page break. mentioned in the question.

@twagner

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-5247

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.