Background colour does not fill the table cell when the table padding is 4 and the border width is changed

Last post 02-06-2012, 12:20 AM by imran.rafique. 1 replies.
Sort Posts: Previous Next
  •  02-03-2012, 10:44 AM 359228

    Background colour does not fill the table cell when the table padding is 4 and the border width is changed .NET

    Attachment: Present (inaccessible)
    Dear Aspose,

    This issue is a more detailed expansion of an issue reported by my colleague here.

    I have found when the table padding is set to "4" and the border width is changed. The table cell background does not fill the whole cell, it leaves one line of pixels at the bottom white.

    This only occurs when the user uses the document model to build a table.
    (Aspose.Words.Tables.Cell.CellFormat.Borders.LineWidth= 1;)

    If I were to just "inserthtml()" this will produce the document correctly.
    It seems to be a difference in implementation between the two methods that causes this issue.

    I have tried your suggestion of an Aspose Upgrade, but 11.0 still shows the issue.

    This issue occurs in word (2003 and 2007) but only at even zoom levels (100%, 120%), and does not appear on physical printed output. Pdf is fine.
    The best workaround I could suggest to my users is to not specify a cell border width or to change the padding size.

    Attached code, and output.

    Thanks in advance

    Regards
    Dominic

    Code:
    [TestMethod]
            public void Test()
            {
                /// First table is built using the insert HTML method. ///

                Aspose.Words.DocumentBuilder documentBuild = new Aspose.Words.DocumentBuilder();
                documentBuild.InsertHtml(GetBackPageTable());


                /// Second table is built using the document model ///
                var AsposeSection = documentBuild.Document.Sections[0];
               
                var AsposeTable = new Aspose.Words.Tables.Table(documentBuild.Document);
                Aspose.Words.Tables.Row row = new Aspose.Words.Tables.Row(documentBuild.Document);
                Aspose.Words.Tables.Cell cell = new Aspose.Words.Tables.Cell(documentBuild.Document);
            
                row.Cells.Add(cell);
                AsposeTable.Rows.Add(row);
                AsposeSection.Body.Tables.Add(AsposeTable);

                AsposeTable.RightPadding = AsposeTable.BottomPadding = AsposeTable.TopPadding = AsposeTable.LeftPadding = 4;

                /// If I change any of these properties there is a bug in the background color height ///
               
                // AsposeTable.SetBorders(Aspose.Words.LineStyle.Single, 1, Color.Black);
                cell.CellFormat.Borders.LineWidth = 1;

                // Not affected by changed values
                cell.CellFormat.Borders.LineStyle = Aspose.Words.LineStyle.Single;
                cell.CellFormat.Borders.Color = Color.Black;

                // This is needed to figure out if the there is a space between the border and the background
                cell.CellFormat.Shading.BackgroundPatternColor = Color.Firebrick;

                string methodName = new StackTrace().GetFrame(0).GetMethod().Name;

                documentBuild.Document.Save(methodName + " - Pre Aspose Refactor.doc", Aspose.Words.SaveFormat.Doc);
                documentBuild.Document.Save(methodName + " - Pre Aspose Refactor.docx", Aspose.Words.SaveFormat.Docx);
                documentBuild.Document.Save(methodName + " - Pre Aspose Refactor.pdf", Aspose.Words.SaveFormat.Pdf);
            }

            private static string GetBackPageTable()
            {
                return @"<Table border=1 width=""100%"" cellspacing=""0"" align=Left cellpadding=4>
                <tr bgcolor=Silver height= ""200"">
                <td width=""50%"" bgcolor=Silver><B>Questionnaire / Ability Test</B></td>
                <td><B>Comparison Group</B></td>
                </tr>
                <tr>
                <td width=""50%""><InstrumentName[/2,36,900]></td>
                <td><NormGroupName[/2,36,900]></td>
                </tr>
                </Table>
                <BR>
                <Table border=1 width=""100%"" align=Left cellspacing=""0"" cellpadding=4>
                <tr>
                <td  width=""20%"" bgcolor=Silver><b>Name</b></td>
                <td><span style=""font-size: 9pt;""><Forename>&nbsp;<Surname></span></td>
                </tr>
                <tr>
                <td  width=""20%"" bgcolor=Silver><b>Candidate Data</b></td>
                <td><span style=""font-size: 9pt;"">RP1=<ScaleValue/OPQ32_RP1.sten>,
                RP2=<ScaleValue/OPQ32_RP2.sten>, RP3=<ScaleValue/OPQ32_RP3.sten>,
                RP4=<ScaleValue/OPQ32_RP4.sten>, RP5=<ScaleValue/OPQ32_RP5.sten>,
                RP6=<ScaleValue/OPQ32_RP6.sten>, RP7=<ScaleValue/OPQ32_RP7.sten>,
                RP8=<ScaleValue/OPQ32_RP8.sten>, RP9=<ScaleValue/OPQ32_RP9.sten>,
                RP10=<ScaleValue/OPQ32_RP10.sten>, TS1=<ScaleValue/OPQ32_TS1.sten>,
                TS2=<ScaleValue/OPQ32_TS2.sten>, TS3=<ScaleValue/OPQ32_TS3.sten>,
                TS4=<ScaleValue/OPQ32_TS4.sten>, TS5=<ScaleValue/OPQ32_TS5.sten>,
                TS6=<ScaleValue/OPQ32_TS6.sten>, TS7=<ScaleValue/OPQ32_TS7.sten>,
                TS8=<ScaleValue/OPQ32_TS8.sten>, TS9=<ScaleValue/OPQ32_TS9.sten>,
                TS10=<ScaleValue/OPQ32_TS10.sten>, TS11=<ScaleValue/OPQ32_TS11.sten>, TS12=<ScaleValue/OPQ32_TS12.sten>, FE1=<ScaleValue/OPQ32_FE1.sten>,
                FE2=<ScaleValue/OPQ32_FE2.sten>, FE3=<ScaleValue/OPQ32_FE3.sten>,
                FE4=<ScaleValue/OPQ32_FE4.sten>, FE5=<ScaleValue/OPQ32_FE5.sten>,
                FE6=<ScaleValue/OPQ32_FE6.sten>, FE7=<ScaleValue/OPQ32_FE7.sten>,
                FE8=<ScaleValue/OPQ32_FE8.sten>, FE9=<ScaleValue/OPQ32_FE9.sten>,
                FE10=<ScaleValue/OPQ32_FE10.sten>, CNS=<ScaleValue/OPQ32_CNS.sten>.
                </td>
                </tr>
                <tr>
                <td  width=""20%"" bgcolor=Silver><b>Report</b></td>
                <td><span style=""font-size: 9pt;"">OPQ32 Profile v2.0</span></td>
                </tr>
                </Table>
                </BR></BR>";
            }
     
  •  02-06-2012, 12:20 AM 359358 in reply to 359228

    Re: Background colour does not fill the table cell when the table padding is 4 and the border width is changed

    Hi Dominic,

    Thanks you for inquiry.

    >> I have found when the table padding is set to "4" and the border width is changed. The table cell background does not fill the whole cell, it leaves one line of pixels at the bottom white.


    Using latest Aspose.Words 11.0.0, i managed to reproduce the problem on my side. I have logged this issue in our bug tracking system. Your request has been linked to the appropriate issue. You will be notified as soon as it is fixed.

    In case of any further query, please let me know.


    Best Regards,
    Imran Rafique
    Support Developer
    Aspose Sialkot Team
    http://www.aspose.com/
    Aspose - Your File Format Experts
    Keep in touch! We're on Twitter and Facebook
     
View as RSS news feed in XML