public class TextColumn
TextColumn objects are only used to specify columns with custom width and spacing. If you want
the columns in the document to be of equal width, set TextColumns.
When a new TextColumn is created it has its width and spacing set to zero.
Example:
Shows how to set widths of columns.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); 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 column = columns.get(0); column.setWidth(100.0); column.setSpaceAfter(20.0); // Set the second column to take the rest of the space available on the page column = columns.get(1); PageSetup pageSetup = builder.getPageSetup(); double contentWidth = pageSetup.getPageWidth() - pageSetup.getLeftMargin() - pageSetup.getRightMargin(); column.setWidth(contentWidth - column.getWidth() - column.getSpaceAfter()); builder.writeln("Narrow column 1."); builder.insertBreak(BreakType.COLUMN_BREAK); builder.writeln("Wide column 2."); doc.save(getArtifactsDir() + "PageSetup.CustomColumnWidth.docx");
Property Getters/Setters Summary | ||
---|---|---|
double | getSpaceAfter() | |
void | setSpaceAfter(doublevalue) | |
Gets or sets the space between this column and the next column in points. Not required for the last column. | ||
double | getWidth() | |
void | setWidth(doublevalue) | |
Gets or sets the width of the text column in points. |
public double getSpaceAfter() / public void setSpaceAfter(double value)
Example:
Shows how to set widths of columns.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); 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 column = columns.get(0); column.setWidth(100.0); column.setSpaceAfter(20.0); // Set the second column to take the rest of the space available on the page column = columns.get(1); PageSetup pageSetup = builder.getPageSetup(); double contentWidth = pageSetup.getPageWidth() - pageSetup.getLeftMargin() - pageSetup.getRightMargin(); column.setWidth(contentWidth - column.getWidth() - column.getSpaceAfter()); builder.writeln("Narrow column 1."); builder.insertBreak(BreakType.COLUMN_BREAK); builder.writeln("Wide column 2."); doc.save(getArtifactsDir() + "PageSetup.CustomColumnWidth.docx");
public double getWidth() / public void setWidth(double value)
Example:
Shows how to set widths of columns.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); 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 column = columns.get(0); column.setWidth(100.0); column.setSpaceAfter(20.0); // Set the second column to take the rest of the space available on the page column = columns.get(1); PageSetup pageSetup = builder.getPageSetup(); double contentWidth = pageSetup.getPageWidth() - pageSetup.getLeftMargin() - pageSetup.getRightMargin(); column.setWidth(contentWidth - column.getWidth() - column.getSpaceAfter()); builder.writeln("Narrow column 1."); builder.insertBreak(BreakType.COLUMN_BREAK); builder.writeln("Wide column 2."); doc.save(getArtifactsDir() + "PageSetup.CustomColumnWidth.docx");