Hi,
I tried adding custom color as background color for table. It is not working for me. Please let me know how to add custom color as background color to the table. The customer color which i am trying is #F3EBDE
I tried both in C# as well as from the XML.
My Code is
Aspose.Pdf.Table SRSGrowthBlurbTable = new Table();
byte Red = 243;
byte Green = 235;
byte Blue = 222;
SRSGrowthBlurbTable .BackgroundColor = new Color(243, 235, 222);
OR
<Table BackgroundColor="" ID="RefAddressTable" ColumnWidths="100 150 100 150" MarginBottom="10" DefaultCellPaddingTop="2" IsDisabled="true">
<Row>
<Cell ColumnsSpan="2" ID="BillingAddress">
<Text Alignment="Left" >
<Segment FontName="Arial" FontSize="8" IsTrueTypeFontBold="true"></Segment>
</Text>
</Cell>
<Cell ColumnsSpan="2" ID="InstallationAddress">
<Text Alignment="Left">
<Segment FontName="Arial" FontSize="8" IsTrueTypeFontBold="true"></Segment>
</Text>
</Cell>
</Row>
</Table>
thanks,
moorthi.
If you set IsDisabled="true" the table will not be displayed.
I set BackgroundColor="RGB 243 235 222" in XML and it works.
The API code also works.
If it still won't work for you, please provide you complete code and let us check it.
Hi Tommy,
Thanks for the quick reply. As advised by you, i set the background in XML and it is working fine. But it is not working from the API code. Here with i have attached the XML as well as the code for the same.
<Table ID="SystemTypeTable" ColumnWidths="500" MarginTop="10" MarginBottom="10" IsDisabled="true">
<Row>
<Cell>
<Text FontSize="8" FontName="Arial" IsTrueTypeFontBold="true">
<Segment></Segment>
</Text>
</Cell>
</Row>
</Table>
Aspose.Pdf.Table SystemTypeTable = (Aspose.Pdf.Table)((Aspose.Pdf.Table)SystemDetailsSection.Paragraphs["SystemTypeTable"]).CompleteClone(); // I am doing a complete clone
SystemTypeTable.IsDisabled = false; //Making it visible
byte Red = 243;
byte Green = 235;
byte Blue = 222;
SystemTypeTable.BackgroundColor = new Color(Red, Green, Blue); //Adding background color
SystemDetailsSection.Paragraphs.Add(SystemTypeTable); //Adding to the Main Section
Cell SystemTypeCell = SystemTypeTable.Rows[0].Cells[0];
((Text)SystemTypeCell.Paragraphs[0]).Segments[0].Content = "System Type" //Text for the Table Cell
thanks,
moorthi.
Hi,
I have checked the issue you raised, but I found no problems. I have used this code. Its similar to yours. Please find attached PDf file generated. Here is the code:
Pdf pdf1 = new Pdf();
Aspose.Pdf.Section SystemDetailsSection = pdf1.Sections.Add();
Aspose.Pdf.Table SystemTypeTable = new Aspose.Pdf.Table();
SystemDetailsSection.Paragraphs.Add(SystemTypeTable);
SystemDetailsSection.Paragraphs[0].ID = "SystemTypeTable";
SystemTypeTable.IsDisabled = false; //Making it visible
byte Red = 243;
byte Green = 235;
byte Blue = 222;
SystemTypeTable.BackgroundColor = new Color(Red, Green, Blue);
SystemDetailsSection.Paragraphs.Add(SystemTypeTable);
Aspose.Pdf.Row row1 = SystemTypeTable.Rows.Add();
Aspose.Pdf.Cell cell1Row2 = row1.Cells.Add("cell1");
cell1Row2.Border = new BorderInfo((int)BorderSide.All,0.5F);
Aspose.Pdf.Cell SystemTypeCell = SystemTypeTable.Rows[0].Cells[0];
((Text)SystemTypeCell.Paragraphs[0]).Segments[0].Content = "System Type";//Text for the Table Cell
//Cloned Table
Aspose.Pdf.Table SystemTypeTable2 = (Aspose.Pdf.Table)((Aspose.Pdf.Table)SystemDetailsSection.Paragraphs["SystemTypeTable"]).CompleteClone();
SystemTypeTable2.IsDisabled = false;
SystemTypeTable2.BackgroundColor = new Color(243, 212, 112); //Adding background color
SystemDetailsSection.Paragraphs.Add(SystemTypeTable2); //Adding to the Main Section
Aspose.Pdf.Cell SystemTypeCell2 = SystemTypeTable2.Rows[0].Cells[0];
((Text)SystemTypeCell2.Paragraphs[0]).Segments[0].Content = "CLONED TABLE";//Text for the Table Cell
pdf1.Save("D:/AsposeTest/Table.pdf");
Thanks.
Adeel Ahmad
Support Developer
Aspose Changsha Team
http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html