java.lang.Objectcom.aspose.words.TextColumnCollection
public class TextColumnCollection
Use To make all columns equal width and spaced evenly, set If you have EvenlySpaced set to false, you need to specify width and spacing for each
column individually. Use the indexer to access individual When using custom column widths, make sure the sum of all column widths and spacings between them
equals page width minus left and right page margins. Example:
DocumentBuilder builder = new DocumentBuilder();
TextColumnCollection columns = builder.getPageSetup().getTextColumns();
// Make spacing between columns wider.
columns.setSpacing(100);
// This creates two columns of equal width.
columns.setCount(2);
builder.writeln("Text in column 1.");
builder.insertBreak(BreakType.COLUMN_BREAK);
builder.writeln("Text in column 2.");
builder.getDocument().save(getMyDir() + "\\Artifacts\\PageSetup.ColumnsSameWidth.doc");
Property Getters/Setters Summary | ||
---|---|---|
int | getCount() | |
Gets the number of columns in the section of a document. | ||
boolean | getEvenlySpaced() | |
void | setEvenlySpaced(boolean value) | |
True if text columns are of equal width and evenly spaced. | ||
boolean | getLineBetween() | |
void | setLineBetween(boolean value) | |
When true, adds a vertical line between columns. | ||
double | getSpacing() | |
void | setSpacing(double value) | |
When columns are evenly spaced, gets or sets the amount of space between each column in points. | ||
double | getWidth() | |
When columns are evenly spaced, gets the width of the columns. | ||
TextColumn | get(int index) | |
Returns a text column at the specified index. |
Method Summary | ||
---|---|---|
void | setCount(int newCount) | |
Arranges text into the specified number of text columns. |
Property Getters/Setters Detail |
---|
getCount | |
public int getCount() |
getEvenlySpaced/setEvenlySpaced | |
public boolean getEvenlySpaced() / public void setEvenlySpaced(boolean value) |
Example:
Creates multiple columns of different widths in a section using DocumentBuilder.DocumentBuilder builder = new DocumentBuilder(); TextColumnCollection columns = builder.getPageSetup().getTextColumns(); // Show vertical line between columns. columns.setLineBetween(true); // Indicate we want to create column with different widths. columns.setEvenlySpaced(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.get(0); c1.setWidth(100); c1.setSpaceAfter(20); // Set the second column to take the rest of the space available on the page. TextColumn c2 = columns.get(1); PageSetup ps = builder.getPageSetup(); double contentWidth = ps.getPageWidth() - ps.getLeftMargin() - ps.getRightMargin(); c2.setWidth(contentWidth - c1.getWidth() - c1.getSpaceAfter()); builder.writeln("Narrow column 1."); builder.insertBreak(BreakType.COLUMN_BREAK); builder.writeln("Wide column 2."); builder.getDocument().save(getMyDir() + "\\Artifacts\\PageSetup.ColumnsCustomWidth.doc");
getLineBetween/setLineBetween | |
public boolean getLineBetween() / public void setLineBetween(boolean value) |
Example:
Creates multiple columns of different widths in a section using DocumentBuilder.DocumentBuilder builder = new DocumentBuilder(); TextColumnCollection columns = builder.getPageSetup().getTextColumns(); // Show vertical line between columns. columns.setLineBetween(true); // Indicate we want to create column with different widths. columns.setEvenlySpaced(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.get(0); c1.setWidth(100); c1.setSpaceAfter(20); // Set the second column to take the rest of the space available on the page. TextColumn c2 = columns.get(1); PageSetup ps = builder.getPageSetup(); double contentWidth = ps.getPageWidth() - ps.getLeftMargin() - ps.getRightMargin(); c2.setWidth(contentWidth - c1.getWidth() - c1.getSpaceAfter()); builder.writeln("Narrow column 1."); builder.insertBreak(BreakType.COLUMN_BREAK); builder.writeln("Wide column 2."); builder.getDocument().save(getMyDir() + "\\Artifacts\\PageSetup.ColumnsCustomWidth.doc");
getSpacing/setSpacing | |
public double getSpacing() / public void setSpacing(double value) |
Example:
Creates multiple evenly spaced columns in a section using DocumentBuilder.DocumentBuilder builder = new DocumentBuilder(); TextColumnCollection columns = builder.getPageSetup().getTextColumns(); // Make spacing between columns wider. columns.setSpacing(100); // This creates two columns of equal width. columns.setCount(2); builder.writeln("Text in column 1."); builder.insertBreak(BreakType.COLUMN_BREAK); builder.writeln("Text in column 2."); builder.getDocument().save(getMyDir() + "\\Artifacts\\PageSetup.ColumnsSameWidth.doc");
getWidth | |
public double getWidth() |
Has effect only when
get | |
public TextColumn get(int index) |
Example:
Creates multiple columns of different widths in a section using DocumentBuilder.DocumentBuilder builder = new DocumentBuilder(); TextColumnCollection columns = builder.getPageSetup().getTextColumns(); // Show vertical line between columns. columns.setLineBetween(true); // Indicate we want to create column with different widths. columns.setEvenlySpaced(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.get(0); c1.setWidth(100); c1.setSpaceAfter(20); // Set the second column to take the rest of the space available on the page. TextColumn c2 = columns.get(1); PageSetup ps = builder.getPageSetup(); double contentWidth = ps.getPageWidth() - ps.getLeftMargin() - ps.getRightMargin(); c2.setWidth(contentWidth - c1.getWidth() - c1.getSpaceAfter()); builder.writeln("Narrow column 1."); builder.insertBreak(BreakType.COLUMN_BREAK); builder.writeln("Wide column 2."); builder.getDocument().save(getMyDir() + "\\Artifacts\\PageSetup.ColumnsCustomWidth.doc");
Method Detail |
---|
setCount | |
public void setCount(int newCount) |
When
newCount
- The number of columns the text is to be arranged into.Example:
Creates multiple evenly spaced columns in a section using DocumentBuilder.DocumentBuilder builder = new DocumentBuilder(); TextColumnCollection columns = builder.getPageSetup().getTextColumns(); // Make spacing between columns wider. columns.setSpacing(100); // This creates two columns of equal width. columns.setCount(2); builder.writeln("Text in column 1."); builder.insertBreak(BreakType.COLUMN_BREAK); builder.writeln("Text in column 2."); builder.getDocument().save(getMyDir() + "\\Artifacts\\PageSetup.ColumnsSameWidth.doc");