com.aspose.words

Class ControlChar

  • java.lang.Object
    • com.aspose.words.ControlChar
public abstract class ControlChar 
extends java.lang.Object

Utility class containing constants. Control characters often encountered in documents.
Provides both char and string versions of the same constants. For example: string ControlChar.LineBreak and char ControlChar.LineBreakChar have the same value.

Example:

Shows how to use control characters.
// Replace "\r" control character with "\r\n"
text = text.replace(ControlChar.CR, ControlChar.CR_LF);

Field Summary
static final java.lang.StringCELL
End of a table cell or end of a table row character: "\x0007" or "\a".
static final java.lang.StringTAB
Tab character: "\x0009" or "\t".
static final java.lang.StringLF
Line feed character: "\x000a" or "\n". Same as LINE_FEED.
static final java.lang.StringLINE_FEED
Line feed character: "\x000a" or "\n". Same as LF.
static final java.lang.StringLINE_BREAK
Line break character: "\x000b" or "\v".
static final java.lang.StringPAGE_BREAK
Page break character: "\x000c" or "\f". Note it has the same value as SECTION_BREAK.
static final java.lang.StringSECTION_BREAK
End of section character: "\x000c" or "\f". Note it has the same value as PAGE_BREAK.
static final java.lang.StringCR
Carriage return character: "\x000d" or "\r". Same as PARAGRAPH_BREAK.
static final java.lang.StringPARAGRAPH_BREAK
End of paragraph character: "\x000d" or "\r". Same as CR
static final java.lang.StringCOLUMN_BREAK
End of column character: "\x000e".
static final java.lang.StringCR_LF
Carriage return followed by line feed character: "\x000d\x000a" or "\r\n". Not used as such in Microsoft Word documents, but commonly used in text files for paragraph breaks.
static final java.lang.StringNON_BREAKING_SPACE
Non-breaking space character: "\x00a0".
static final charCELL_CHAR
End of a table cell or end of a table row character: (char)7 or "\a".
static final charTAB_CHAR
Tab character: (char)9 or "\t".
static final charLINE_FEED_CHAR
Line feed character: (char)10 or "\n".
static final charLINE_BREAK_CHAR
Line break character: (char)11 or "\v".
static final charPAGE_BREAK_CHAR
Page break character: (char)12 or "\f".
static final charSECTION_BREAK_CHAR
End of section character: (char)12 or "\f".
static final charPARAGRAPH_BREAK_CHAR
End of paragraph character: (char)13 or "\r".
static final charCOLUMN_BREAK_CHAR
End of column character: (char)14.
static final charFIELD_START_CHAR
Start of MS Word field character: (char)19.
static final charFIELD_SEPARATOR_CHAR
Field separator character separates field code from field value. Optional in some fields. Value: (char)20.
static final charFIELD_END_CHAR
End of MS Word field character: (char)21.
static final charNON_BREAKING_HYPHEN_CHAR
Nonbreaking Hyphen in Microsoft Word is (char)30.
static final charOPTIONAL_HYPHEN_CHAR
Optional Hyphen in Microsoft Word is (char)31.
static final charSPACE_CHAR
Space character: (char)32.
static final charNON_BREAKING_SPACE_CHAR
Non-breaking space character: (char)160.
static final charDEFAULT_TEXT_INPUT_CHAR
This is the "o" character used as a default value in text input form fields.
 

    • Field Detail

      • CELL

        public static final java.lang.String CELL
        End of a table cell or end of a table row character: "\x0007" or "\a".
      • TAB

        public static final java.lang.String TAB
        Tab character: "\x0009" or "\t".

        Example:

        Changes default tab positions for the document and inserts text with some tab characters.
        DocumentBuilder builder = new DocumentBuilder();
        
        // Set default tab stop to 72 points (1 inch).
        builder.getDocument().setDefaultTabStop(72);
        
        builder.writeln("Hello" + ControlChar.TAB + "World!");
        builder.writeln("Hello" + ControlChar.TAB_CHAR + "World!");
      • LF

        public static final java.lang.String LF
        Line feed character: "\x000a" or "\n". Same as LINE_FEED.
      • LINE_FEED

        public static final java.lang.String LINE_FEED
        Line feed character: "\x000a" or "\n". Same as LF.
      • LINE_BREAK

        public static final java.lang.String LINE_BREAK
        Line break character: "\x000b" or "\v".
      • PAGE_BREAK

        public static final java.lang.String PAGE_BREAK
        Page break character: "\x000c" or "\f". Note it has the same value as SECTION_BREAK.

        Example:

        Removes all page breaks from the document.
        private static void removePageBreaks(Document doc) throws Exception
        {
            // Retrieve all paragraphs in the document.
            NodeCollection paragraphs = doc.getChildNodes(NodeType.PARAGRAPH, true);
        
            // Iterate through all paragraphs
            for (Paragraph para : (Iterable<Paragraph>) paragraphs)
            {
                // If the paragraph has a page break before set then clear it.
                if (para.getParagraphFormat().getPageBreakBefore())
                    para.getParagraphFormat().setPageBreakBefore(false);
        
                // Check all runs in the paragraph for page breaks and remove them.
                for (Run run : (Iterable<Run>) para.getRuns())
                {
                    if (run.getText().contains(ControlChar.PAGE_BREAK))
                        run.setText(run.getText().replace(ControlChar.PAGE_BREAK, ""));
                }
        
            }
        
        }
      • SECTION_BREAK

        public static final java.lang.String SECTION_BREAK
        End of section character: "\x000c" or "\f". Note it has the same value as PAGE_BREAK.
      • CR

        public static final java.lang.String CR
        Carriage return character: "\x000d" or "\r". Same as PARAGRAPH_BREAK.

        Example:

        Shows how to use control characters.
        // Replace "\r" control character with "\r\n"
        text = text.replace(ControlChar.CR, ControlChar.CR_LF);
      • PARAGRAPH_BREAK

        public static final java.lang.String PARAGRAPH_BREAK
        End of paragraph character: "\x000d" or "\r". Same as CR
      • COLUMN_BREAK

        public static final java.lang.String COLUMN_BREAK
        End of column character: "\x000e".
      • CR_LF

        public static final java.lang.String CR_LF
        Carriage return followed by line feed character: "\x000d\x000a" or "\r\n". Not used as such in Microsoft Word documents, but commonly used in text files for paragraph breaks.

        Example:

        Shows how to use control characters.
        // Replace "\r" control character with "\r\n"
        text = text.replace(ControlChar.CR, ControlChar.CR_LF);
      • NON_BREAKING_SPACE

        public static final java.lang.String NON_BREAKING_SPACE
        Non-breaking space character: "\x00a0".
      • CELL_CHAR

        public static final char CELL_CHAR
        End of a table cell or end of a table row character: (char)7 or "\a".
      • TAB_CHAR

        public static final char TAB_CHAR
        Tab character: (char)9 or "\t".

        Example:

        Changes default tab positions for the document and inserts text with some tab characters.
        DocumentBuilder builder = new DocumentBuilder();
        
        // Set default tab stop to 72 points (1 inch).
        builder.getDocument().setDefaultTabStop(72);
        
        builder.writeln("Hello" + ControlChar.TAB + "World!");
        builder.writeln("Hello" + ControlChar.TAB_CHAR + "World!");
      • LINE_FEED_CHAR

        public static final char LINE_FEED_CHAR
        Line feed character: (char)10 or "\n".
      • LINE_BREAK_CHAR

        public static final char LINE_BREAK_CHAR
        Line break character: (char)11 or "\v".
      • PAGE_BREAK_CHAR

        public static final char PAGE_BREAK_CHAR
        Page break character: (char)12 or "\f".
      • SECTION_BREAK_CHAR

        public static final char SECTION_BREAK_CHAR
        End of section character: (char)12 or "\f".
      • PARAGRAPH_BREAK_CHAR

        public static final char PARAGRAPH_BREAK_CHAR
        End of paragraph character: (char)13 or "\r".
      • COLUMN_BREAK_CHAR

        public static final char COLUMN_BREAK_CHAR
        End of column character: (char)14.
      • FIELD_START_CHAR

        public static final char FIELD_START_CHAR
        Start of MS Word field character: (char)19.
      • FIELD_SEPARATOR_CHAR

        public static final char FIELD_SEPARATOR_CHAR
        Field separator character separates field code from field value. Optional in some fields. Value: (char)20.
      • FIELD_END_CHAR

        public static final char FIELD_END_CHAR
        End of MS Word field character: (char)21.
      • NON_BREAKING_HYPHEN_CHAR

        public static final char NON_BREAKING_HYPHEN_CHAR
        Nonbreaking Hyphen in Microsoft Word is (char)30.

        Nonbreaking Hyphen in Microsoft Word does not correspond to the Unicode character U+2011 non-breaking hyphen but instead represents internal information that tells Microsoft Word to display a hyphen and not to break a line.

        Useful info: http://www.cs.tut.fi/~jkorpela/dashes.html#linebreaks.

      • OPTIONAL_HYPHEN_CHAR

        public static final char OPTIONAL_HYPHEN_CHAR
        Optional Hyphen in Microsoft Word is (char)31.

        Optional Hyphen in Microsoft Word does not correspond to the Unicode character U+00AD soft hyphen. Instead, it inserts internal information that tells Word about a possible hyphenation point.

      • SPACE_CHAR

        public static final char SPACE_CHAR
        Space character: (char)32.
      • NON_BREAKING_SPACE_CHAR

        public static final char NON_BREAKING_SPACE_CHAR
        Non-breaking space character: (char)160.
      • DEFAULT_TEXT_INPUT_CHAR

        public static final char DEFAULT_TEXT_INPUT_CHAR
        This is the "o" character used as a default value in text input form fields.