Unplanned
Last Updated: 23 Dec 2021 12:46 by ADMIN
Pankaj
Created on: 23 Dec 2021 12:40
Category: WordsProcessing
Type: Bug Report
0
WordsProcessing: HtmlFormatProvider: The table is cut off when its width is larger than the default page width

The table is cut off when its width is larger than the default page width.

Workaround: 

var htmlProvider = new HtmlFormatProvider();
var document = htmlProvider.Import(File.ReadAllText(@"..\..\HTMLPage1.html"));

var tables = document.EnumerateChildrenOfType<Table>();
double maxWidth = document.Sections.FirstOrDefault().PageSize.Width;

foreach (var item in tables)
{
    if (item.PreferredWidth.Type == Telerik.Windows.Documents.Flow.Model.Styles.TableWidthUnitType.Fixed)
    {
        maxWidth = Math.Max(maxWidth, (item.PreferredWidth.Value + 100));
    }
}

foreach (var item in document.Sections)
{
    item.PageSize = new System.Windows.Size(maxWidth, item.PageSize.Height);
}

var pdfProvider = new PdfFormatProvider();
File.WriteAllBytes(@"..\..\result.pdf", pdfProvider.Export(document));

0 comments