Hi,
We tried to create a document with different margins between header/footer and document body. We tried to insert a table in the body with left margin = 0 but we need to maintain left margin = 4 in the body.
Many thanks,
Hi,
We tried to create a document with different margins between header/footer and document body. We tried to insert a table in the body with left margin = 0 but we need to maintain left margin = 4 in the body.
Many thanks,
Hi Tahir,
It works fine, but now we have the same problem with right margin. We can“t find something like RightIndent property.
Hi Tahir,
I share expected output document, the input document is the same without header and footer sections.
Thanks!
Document doc = new Document(MyDir + "in.docx");
//Set the width of table
double tablewidth = doc.FirstSection.PageSetup.PageWidth - doc.FirstSection.PageSetup.LeftMargin
- doc.FirstSection.PageSetup.RightMargin;
Table table = (Table)doc.GetChild(NodeType.Table, 0, true);
table.PreferredWidth = PreferredWidth.FromPoints(tablewidth - 100);
table.Alignment = TableAlignment.Center;
//Change the bottom border of last row of table
foreach (Cell cell in table.LastRow.Cells)
{
cell.CellFormat.Borders[BorderType.Bottom].LineStyle = LineStyle.Single;
cell.CellFormat.Borders[BorderType.Bottom].Color = Color.Green;
}
doc.Save(MyDir + "Out.docx");
Good job! It works fine.
Thanks a lot!