The key part to be able to change the page margins is to firs t create a "PageMagrin" object and then a "SectionProperties" object. Saving/Disposing of the created word DocumentÄ() add the table to the document - table needs to be wired into the for each loop above getting the values from the list for the right cell get right cell contents, if there is a value for this index Row.Append(new TableCell(new Paragraph(new Run(new Text(Title))))) getting the values from the list for the left table cell get the indexes for left and right cells as pairs (i.e. TblBorders.InsideVerticalBorder = new InsideVerticalBorder()
TblBorders.InsideHorizontalBorder = new InsideHorizontalBorder() TblBorders.LeftBorder = new LeftBorder() TblBorders.RightBorder = new RightBorder() TblBorders.BottomBorder = new BottomBorder() TableBorders tblBorders = new TableBorders() TableProperties tblProps = new TableProperties() creating a properties object to add border to the table (wNo border will be required) getting the internal name for the Title and JobTitle fields of the list SPListItemCollection collListItems = list.Items MainDocumenPart.Document = new Document() MainDocumentPart mainDocumenPart = document.AddMainDocumentPart() WordprocessingDocument document = WordprocessingDocumentType.Document)
CHANGING MARGINS IN WORD FROM CM TO INCHES HOW TO
Can anyone shed some light on how to achieve this? So far the code I have is a as follows: void GenerateBadges_Click(object sender, EventArgs e) I want to be able to change the margins for the document (top, bottom margins), but I am unsure as to how to proceed. I have created a web part with a button that once clicked generates a word document containing the list item values of particular list.