When I am loading a HTML file and doing some modifications, I am not getting a proper output while saving it as PNG.
- Code: Select all
var doc = new Document("sample.html",FileFormat.Html,XHTMLValidationType.None);
doc.Background.Color = Color.Black;
foreach (Section section in doc.Sections)
{
foreach (Table table in section.Tables)
{
table.TableFormat.Borders.Vertical.Color = Color.White;
table.TableFormat.Borders.Horizontal.Color = Color.White;
table.TableFormat.Borders.Color = Color.White;
foreach (TableRow row in table.Rows)
{
foreach (TableCell cell in row.Cells)
{
foreach (Paragraph paragraph in cell.Paragraphs)
{
TextSelection selection = paragraph.Find(new Regex(".*"));
if (!string.IsNullOrEmpty(selection.SelectedText))
{
TextRange range = selection.GetAsOneRange();
if (range.CharacterFormat.TextColor.R == 0 && range.CharacterFormat.TextColor.G == 0 && range.CharacterFormat.TextColor.B == 0)
{
range.CharacterFormat.TextColor = Color.White;
}
}
}
}
}
}
foreach (Paragraph paragraph in section.Paragraphs)
{
TextSelection selection = paragraph.Find(new Regex(".*"));
if (!string.IsNullOrEmpty(selection.SelectedText))
{
TextRange range = selection.GetAsOneRange();
if (range.CharacterFormat.TextColor.R == 0 && range.CharacterFormat.TextColor.G == 0 && range.CharacterFormat.TextColor.B == 0)
{
range.CharacterFormat.TextColor = Color.White;
}
}
}
}
var image = doc.SaveToImages(ImageType.Bitmap);
image[0].Save("sample.png", ImageFormat.Png);
The issue I am facing is:
Bullets are missing.
Indentation is not correct.
Table border cannot be set.
Attaching the HTML and the corresponding PNG file