How do I turn off widow/orphan control in the HTML to PDF conversion?

How do I turn off widow/orphan control in the HTML to PDF conversion?

I have attached two versions of the same report, one with a section header, and one where the section header is incorporated in the table header. If you look at pages 13 and 14 on the documents, there is a table that overflows the available page client height by three rows. In either case (with a separated section header, or with it integrated) the table skips that page to start a new page and still overflows. Other larger tables break fine – so I’m presuming that this problem is arising because of a default widow/orphan setting for tables. We would just like to turn off any setting the PDF conversion is using.

AFR Alachua 2024_with_section_header.pdf (480.1 KB)

AFR Alachua 2024_without_section_header.pdf (480.0 KB)

@amos.johnson.dfs

Would you please share your sample HTML in .zip format with us along with the sample code snippet that you are using? We will test the scenario in our environment and address it accordingly.

AFR Alachua 2024 (49).zip (60.0 KB)

Attached is the requested zip file. Below is the relevant code snippet.

using PdfDocument = Aspose.Pdf.Document;
using PdfHtmlLoadOptions = Aspose.Pdf.HtmlLoadOptions;
using Aspose.Html.Dom.Css;

    private void ProcessPDFPageAndMarginInfo(string htmlOutput, PageInfo pageInfo, MarginInfo marginInfo)
    {
                pageInfo.Width = 792.0;
                pageInfo.Height = 612.0;
                pageInfo.IsLandscape = true;
                marginInfo.Top = 36.0;
                marginInfo.Left = 36.0;
                marginInfo.Bottom = 36.0;
                marginInfo.Right = 36.0;

        // Clean up the HTML source before creating an HTML Document. We do this to fetch an CSS page rules in the
        // source which would override the default page and margin settings we currently have for this report. This allows our HTML templates
        // to override the defaults. The HTML Document is discarded after this "style mining".
        string docTest = htmlOutput.Replace("\r\n", " ").Replace("\t", " ");
        using (var document = new HTMLDocument(docTest, "."))
        {
            // Save the document to a disk
            foreach (var ss in document.StyleSheets)
            {
                if (ss is ICSSStyleSheet css)
                {
                    foreach (var r in css.CSSRules)
                    {
                        if( r is ICSSPageRule pageRule)
                        {
                            var pStyle = pageRule.Style;
                            string s = pStyle.GetPropertyValue("Size");
                            if( !string.IsNullOrEmpty(s) )
                            {
                                pageInfo.IsLandscape = (s.ToLower() == "landscape");
                            }
                            pageInfo.Width = ReadMeasurement(pStyle, "width", 612.0);
                            pageInfo.Height = ReadMeasurement(pStyle, "height", 792.0);
                            marginInfo.Top = ReadMeasurement(pStyle, "margin-top", 0);
                            marginInfo.Bottom = ReadMeasurement(pStyle, "margin-bottom", 0);
                            marginInfo.Left = ReadMeasurement(pStyle, "margin-left", 0);
                            marginInfo.Right = ReadMeasurement(pStyle, "margin-right", 0);
                        }
                    }
                }
            }
        }

    }


String htlmOutput = File.ReadAllText(“AFR Alachua 2024 (49).xhtml”);
PdfHtmlLoadOptions options = new PdfHtmlLoadOptions();
PageInfo pageInfo = new PageInfo();

            MarginInfo marginInfo = new MarginInfo();
            ProcessPDFPageAndMarginInfo(htmlOutput, pageInfo, marginInfo);
            pageInfo.Margin = marginInfo;
            options.PageInfo = pageInfo;
            PdfDocument pdfDocument = null;
            using ( var htmlStream = new MemoryStream(Encoding.UTF8.GetBytes(htmlOutput)) )
            {
                pdfDocument = new PdfDocument(htmlStream, options);
            }

@amos.johnson.dfs

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): PDFNET-59520

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.