java.lang.Object
com.aspose.words.ParagraphAlignment
public class ParagraphAlignment
- extends java.lang.Object
Utility class containing constants.
Specifies text alignment in a paragraph.
Example:
Creates a simple document from scratch using the Aspose.Words object model.
// Create an "empty" document. Note that like in Microsoft Word,
// the empty document has one section, body and one paragraph in it.
Document doc = new Document();
// This truly makes the document empty. No sections (not possible in Microsoft Word).
doc.removeAllChildren();
// Create a new section node.
// Note that the section has not yet been added to the document,
// but we have to specify the parent document.
Section section = new Section(doc);
// Append the section to the document.
doc.appendChild(section);
// Lets set some properties for the section.
section.getPageSetup().setSectionStart(SectionStart.NEW_PAGE);
section.getPageSetup().setPaperSize(PaperSize.LETTER);
// The section that we created is empty, lets populate it. The section needs at least the Body node.
Body body = new Body(doc);
section.appendChild(body);
// The body needs to have at least one paragraph.
// Note that the paragraph has not yet been added to the document,
// but we have to specify the parent document.
// The parent document is needed so the paragraph can correctly work
// with styles and other document-wide information.
Paragraph para = new Paragraph(doc);
body.appendChild(para);
// We can set some formatting for the paragraph
para.getParagraphFormat().setStyleName("Heading 1");
para.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);
// So far we have one empty paragraph in the document.
// The document is valid and can be saved, but lets add some text before saving.
// Create a new run of text and add it to our paragraph.
Run run = new Run(doc);
run.setText("Hello World!");
run.getFont().setColor(Color.RED);
para.appendChild(run);
// As a matter of interest, you can retrieve text of the whole document and
// see that \x000c is automatically appended. \x000c is the end of section character.
System.out.println(doc.getText());
// Save the document.
doc.save(getMyDir() + "Section.CreateFromScratch Out.doc");
Field Summary |
static final int | LEFT = 0 | |
Text is aligned to the left.
|
static final int | CENTER = 1 | |
Text is centered horizontally.
|
static final int | RIGHT = 2 | |
Text is aligned to the right.
|
static final int | JUSTIFY = 3 | |
Text is aligned to both left and right.
|
static final int | DISTRIBUTED = 4 | |
Text is evenly distributed.
|
static final int | ARABIC_MEDIUM_KASHIDA = 5 | |
Arabic only. Kashida length for text is extended to a medium length determined by the consumer.
|
static final int | ARABIC_HIGH_KASHIDA = 7 | |
Arabic only. Kashida length for text is extended to its widest possible length.
|
static final int | ARABIC_LOW_KASHIDA = 8 | |
Arabic only. Kashida length for text is extended to a slightly longer length.
|
static final int | THAI_DISTRIBUTED = 9 | |
Thai only. Text is justified with an optimization for Thai.
|
LEFT = 0 | |
public static final int LEFT |
-
Text is aligned to the left.
CENTER = 1 | |
public static final int CENTER |
-
Text is centered horizontally.
RIGHT = 2 | |
public static final int RIGHT |
-
Text is aligned to the right.
JUSTIFY = 3 | |
public static final int JUSTIFY |
-
Text is aligned to both left and right.
DISTRIBUTED = 4 | |
public static final int DISTRIBUTED |
-
Text is evenly distributed.
ARABIC_MEDIUM_KASHIDA = 5 | |
public static final int ARABIC_MEDIUM_KASHIDA |
-
Arabic only. Kashida length for text is extended to a medium length determined by the consumer.
ARABIC_HIGH_KASHIDA = 7 | |
public static final int ARABIC_HIGH_KASHIDA |
-
Arabic only. Kashida length for text is extended to its widest possible length.
ARABIC_LOW_KASHIDA = 8 | |
public static final int ARABIC_LOW_KASHIDA |
-
Arabic only. Kashida length for text is extended to a slightly longer length.
THAI_DISTRIBUTED = 9 | |
public static final int THAI_DISTRIBUTED |
-
Thai only. Text is justified with an optimization for Thai.
See Also:
Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
Aspose.Words Support Forum - our preferred method of support.