We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to get left margin of table from the left edge of page using .NET

HI

I have a table in word documnet and i need to know the LeftMargin of the table,that is from from left how much distance is there for that table..

Hi Ajeesh,

Thanks for your query. When you insert a table in word document the table’s left margin from page is depends upon Page Setup properties. You can get the Left Margin of table from page by using PageSetup class (PageSetup.LeftMargin). Hope this answers your query. Let me know, If you have any more queries.

http://docs.aspose.com/display/wordsnet/PageSetup+Class

hi

am pasting my code here

Aspose.Words.Tables.Table tableClone = (Aspose.Words.Tables.Table)table.Clone(true);

Section section = new Section(doc);

doc.AppendChild(section);

section.PageSetup.SectionStart = SectionStart.NewPage;

section.PageSetup.LeftMargin = doc.Sections[0].PageSetup.LeftMargin;

Body body = new Body(doc);

section.AppendChild(body);

body.AppendChild(tableClone);

here what am doing is ,i have a table already in my word document and am creating a clone of that table in the other pages,that is in each page i have clone tables.My problem is the clone tables are not in the same left align with the main table.How to acive that,even i tried above line in red color also

Hi Ajeesh,

Please use the following code snippet for your requirement. Let us know, If you have any more queries.

Document doc = new Document(MyDir + "table.docx");

Node[] tables = doc.GetChildNodes(NodeType.Table, true).ToArray();

Aspose.Words.Tables.Table tableClone = (Aspose.Words.Tables.Table)tables[0].Clone(true);

Section section = new Section(doc);

doc.AppendChild(section);

section.PageSetup.SectionStart = SectionStart.NewPage;

section.PageSetup.PageWidth = doc.Sections[0].PageSetup.PageWidth;

section.PageSetup.LeftMargin = doc.Sections[0].PageSetup.LeftMargin;

Body body = new Body(doc);

section.AppendChild(body);

body.AppendChild(tableClone);

doc.Save(MyDir + "out.docx");