com.aspose.words

Class TextColumn

  • java.lang.Object
    • com.aspose.words.TextColumn
  • All Implemented Interfaces:
    java.lang.Cloneable
    public class TextColumn 
    extends java.lang.Object

Represents a single text column. TextColumn is a member of the TextColumnCollection collection. The TextColumns collection includes all the columns in a section of a document.

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.TextColumnCollection.EvenlySpaced to true.

When a new TextColumn is created it has its width and spacing set to zero.

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");
See Also:
TextColumnCollection, PageSetup, Section

Property Getters/Setters Summary
doublegetSpaceAfter()
void
setSpaceAfter(doublevalue)
           Gets or sets the space between this column and the next column in points. Not required for the last column.
doublegetWidth()
void
setWidth(doublevalue)
           Gets or sets the width of the text column in points.
 

    • Property Getters/Setters Detail

      • getSpaceAfter/setSpaceAfter

        public double getSpaceAfter() / public void setSpaceAfter(double value)
        
        Gets or sets the space between this column and the next column in points. Not required for the last column.

        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");
      • getWidth/setWidth

        public double getWidth() / public void setWidth(double value)
        
        Gets or sets the width of the text column in points.

        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");