Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed Jan 07, 2015 7:08 am

Hi,

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

shrenik.gandhi
 
Posts: 10
Joined: Fri Sep 12, 2014 5:14 am

Wed Jan 07, 2015 7:50 am

Dear Shrenik,

Thanks for your inquiry.

I have reproduced this problem and posted it to our dev team, we will inform you if there is any update.
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Wed Jan 28, 2015 8:11 am

Dear Shrenik,

Sorry to keep you waiting.

We just released a new version of Spire.Doc (Spire.Doc v5.3.38) to fix this problem, please download it via link below and have a try:
http://www.e-iceblue.com/Download/downl ... t-now.html

Please add following code to your project:
Code: Select all
//Set background type to color
doc.Background.Type = BackgroundType.Color;
......
//Set paragraph character format for the break symbol.
paragraph.BreakCharacterFormat.TextColor = Color.White;
Best Regards,
Burning
E-iceblue Support Team
User avatar

burning.liu
 
Posts: 406
Joined: Mon Aug 04, 2014 6:47 am

Return to Spire.Doc