public void ColumnsSameWidth() { //ExStart //ExFor:PageSetup.TextColumns //ExFor:TextColumnCollection //ExFor:TextColumnCollection.Spacing //ExFor:TextColumnCollection.SetCount //ExSummary:Shows how to create multiple evenly spaced columns in a section using DocumentBuilder. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); TextColumnCollection columns = builder.PageSetup.TextColumns; // Make spacing between columns wider columns.Spacing = 100; // This creates two columns of equal width columns.SetCount(2); builder.Writeln("Text in column 1."); builder.InsertBreak(BreakType.ColumnBreak); builder.Writeln("Text in column 2."); doc.Save(ArtifactsDir + "PageSetup.ColumnsSameWidth.docx"); //ExEnd doc = new Document(ArtifactsDir + "PageSetup.ColumnsSameWidth.docx"); Assert.AreEqual(100.0d, doc.FirstSection.PageSetup.TextColumns.Spacing); Assert.AreEqual(2, doc.FirstSection.PageSetup.TextColumns.Count); }
public void VerticalLineBetweenColumns(bool lineBetween) { //ExStart //ExFor:TextColumnCollection.LineBetween //ExSummary:Shows how to separate columns with a vertical line. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Configure the current section's PageSetup object to divide the text into several columns. // Set the "LineBetween" property to "true" to put a dividing line between columns. // Set the "LineBetween" property to "false" to leave the space between columns blank. TextColumnCollection columns = builder.PageSetup.TextColumns; columns.LineBetween = lineBetween; columns.SetCount(3); builder.Writeln("Column 1."); builder.InsertBreak(BreakType.ColumnBreak); builder.Writeln("Column 2."); builder.InsertBreak(BreakType.ColumnBreak); builder.Writeln("Column 3."); doc.Save(ArtifactsDir + "PageSetup.VerticalLineBetweenColumns.docx"); //ExEnd doc = new Document(ArtifactsDir + "PageSetup.VerticalLineBetweenColumns.docx"); Assert.AreEqual(lineBetween, doc.FirstSection.PageSetup.TextColumns.LineBetween); }
public void SetSectionStart() { //ExStart //ExFor:SectionStart //ExFor:PageSetup.SectionStart //ExFor:Document.Sections //ExSummary:Shows how to specify how a new section separates itself from the previous. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); builder.Writeln("This text is in section 1."); // Section break types determine how a new section separates itself from the previous section. // Below are five types of section breaks. // 1 - Starts the next section on a new page: builder.InsertBreak(BreakType.SectionBreakNewPage); builder.Writeln("This text is in section 2."); Assert.AreEqual(SectionStart.NewPage, doc.Sections[1].PageSetup.SectionStart); // 2 - Starts the next section on the current page: builder.InsertBreak(BreakType.SectionBreakContinuous); builder.Writeln("This text is in section 3."); Assert.AreEqual(SectionStart.Continuous, doc.Sections[2].PageSetup.SectionStart); // 3 - Starts the next section on a new even page: builder.InsertBreak(BreakType.SectionBreakEvenPage); builder.Writeln("This text is in section 4."); Assert.AreEqual(SectionStart.EvenPage, doc.Sections[3].PageSetup.SectionStart); // 4 - Starts the next section on a new odd page: builder.InsertBreak(BreakType.SectionBreakOddPage); builder.Writeln("This text is in section 5."); Assert.AreEqual(SectionStart.OddPage, doc.Sections[4].PageSetup.SectionStart); // 5 - Starts the next section on a new column: TextColumnCollection columns = builder.PageSetup.TextColumns; columns.SetCount(2); builder.InsertBreak(BreakType.SectionBreakNewColumn); builder.Writeln("This text is in section 6."); Assert.AreEqual(SectionStart.NewColumn, doc.Sections[5].PageSetup.SectionStart); doc.Save(ArtifactsDir + "PageSetup.SetSectionStart.docx"); //ExEnd doc = new Document(ArtifactsDir + "PageSetup.SetSectionStart.docx"); Assert.AreEqual(SectionStart.NewPage, doc.Sections[0].PageSetup.SectionStart); Assert.AreEqual(SectionStart.NewPage, doc.Sections[1].PageSetup.SectionStart); Assert.AreEqual(SectionStart.Continuous, doc.Sections[2].PageSetup.SectionStart); Assert.AreEqual(SectionStart.EvenPage, doc.Sections[3].PageSetup.SectionStart); Assert.AreEqual(SectionStart.OddPage, doc.Sections[4].PageSetup.SectionStart); Assert.AreEqual(SectionStart.NewColumn, doc.Sections[5].PageSetup.SectionStart); }
public void CustomColumnWidth() { //ExStart //ExFor:TextColumnCollection.LineBetween //ExFor:TextColumnCollection.EvenlySpaced //ExFor:TextColumnCollection.Item //ExFor:TextColumn //ExFor:TextColumn.Width //ExFor:TextColumn.SpaceAfter //ExSummary:Shows how to set widths of columns. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); TextColumnCollection columns = builder.PageSetup.TextColumns; // Show vertical line between columns columns.LineBetween = true; // Indicate we want to create column with different widths columns.EvenlySpaced = false; // Create two columns, note they will be created with zero widths, need to set them columns.SetCount(2); // Set the first column to be narrow TextColumn column = columns[0]; column.Width = 100; column.SpaceAfter = 20; // Set the second column to take the rest of the space available on the page column = columns[1]; PageSetup pageSetup = builder.PageSetup; double contentWidth = pageSetup.PageWidth - pageSetup.LeftMargin - pageSetup.RightMargin; column.Width = contentWidth - column.Width - column.SpaceAfter; builder.Writeln("Narrow column 1."); builder.InsertBreak(BreakType.ColumnBreak); builder.Writeln("Wide column 2."); doc.Save(ArtifactsDir + "PageSetup.CustomColumnWidth.docx"); //ExEnd doc = new Document(ArtifactsDir + "PageSetup.CustomColumnWidth.docx"); pageSetup = doc.FirstSection.PageSetup; Assert.True(pageSetup.TextColumns.LineBetween); Assert.False(pageSetup.TextColumns.EvenlySpaced); Assert.AreEqual(2, pageSetup.TextColumns.Count); Assert.AreEqual(100.0d, pageSetup.TextColumns[0].Width); Assert.AreEqual(20.0d, pageSetup.TextColumns[0].SpaceAfter); Assert.AreEqual(470.3d, pageSetup.TextColumns[1].Width); Assert.AreEqual(0.0d, pageSetup.TextColumns[1].SpaceAfter); }
public void CustomColumnWidth() { //ExStart //ExFor:TextColumnCollection.EvenlySpaced //ExFor:TextColumnCollection.Item //ExFor:TextColumn //ExFor:TextColumn.Width //ExFor:TextColumn.SpaceAfter //ExSummary:Shows how to create unevenly spaced columns. Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); PageSetup pageSetup = builder.PageSetup; TextColumnCollection columns = pageSetup.TextColumns; columns.EvenlySpaced = false; columns.SetCount(2); // Determine the amount of room that we have available for arranging columns. double contentWidth = pageSetup.PageWidth - pageSetup.LeftMargin - pageSetup.RightMargin; Assert.AreEqual(470.30d, contentWidth, 0.01d); // Set the first column to be narrow. TextColumn column = columns[0]; column.Width = 100; column.SpaceAfter = 20; // Set the second column to take the rest of the space available within the margins of the page. column = columns[1]; column.Width = contentWidth - column.Width - column.SpaceAfter; builder.Writeln("Narrow column 1."); builder.InsertBreak(BreakType.ColumnBreak); builder.Writeln("Wide column 2."); doc.Save(ArtifactsDir + "PageSetup.CustomColumnWidth.docx"); //ExEnd doc = new Document(ArtifactsDir + "PageSetup.CustomColumnWidth.docx"); pageSetup = doc.FirstSection.PageSetup; Assert.False(pageSetup.TextColumns.EvenlySpaced); Assert.AreEqual(2, pageSetup.TextColumns.Count); Assert.AreEqual(100.0d, pageSetup.TextColumns[0].Width); Assert.AreEqual(20.0d, pageSetup.TextColumns[0].SpaceAfter); Assert.AreEqual(470.3d, pageSetup.TextColumns[1].Width); Assert.AreEqual(0.0d, pageSetup.TextColumns[1].SpaceAfter); }
public void ColumnsCustomWidth() { //ExStart //ExFor:TextColumnCollection.LineBetween //ExFor:TextColumnCollection.EvenlySpaced //ExFor:TextColumnCollection.Item //ExFor:TextColumn //ExFor:TextColumn.Width //ExFor:TextColumn.SpaceAfter //ExSummary:Creates multiple columns of different widths in a section using DocumentBuilder. DocumentBuilder builder = new DocumentBuilder(); TextColumnCollection columns = builder.PageSetup.TextColumns; // Show vertical line between columns. columns.LineBetween = true; // Indicate we want to create column with different widths. columns.EvenlySpaced = false; // Create two columns, note they will be created with zero widths, need to set them. columns.SetCount(2); // Set the first column to be narrow. TextColumn c1 = columns[0]; c1.Width = 100; c1.SpaceAfter = 20; // Set the second column to take the rest of the space available on the page. TextColumn c2 = columns[1]; Aspose.Words.PageSetup ps = builder.PageSetup; double contentWidth = ps.PageWidth - ps.LeftMargin - ps.RightMargin; c2.Width = contentWidth - c1.Width - c1.SpaceAfter; builder.Writeln("Narrow column 1."); builder.InsertBreak(BreakType.ColumnBreak); builder.Writeln("Wide column 2."); builder.Document.Save(MyDir + "PageSetup.ColumnsCustomWidth Out.doc"); //ExEnd }
public void ColumnsSameWidth() { //ExStart //ExFor:PageSetup.TextColumns //ExFor:TextColumnCollection //ExFor:TextColumnCollection.Spacing //ExFor:TextColumnCollection.SetCount //ExSummary:Creates multiple evenly spaced columns in a section using DocumentBuilder. DocumentBuilder builder = new DocumentBuilder(); TextColumnCollection columns = builder.PageSetup.TextColumns; // Make spacing between columns wider. columns.Spacing = 100; // This creates two columns of equal width. columns.SetCount(2); builder.Writeln("Text in column 1."); builder.InsertBreak(BreakType.ColumnBreak); builder.Writeln("Text in column 2."); builder.Document.Save(MyDir + @"\Artifacts\PageSetup.ColumnsSameWidth.doc"); //ExEnd }