ParagraphFormat

Inheritance: java.lang.Object, com.aspose.slides.PVIObject

All Implemented Interfaces: com.aspose.slides.IParagraphFormat, com.aspose.slides.IChartParagraphFormat

public final class ParagraphFormat extends PVIObject implements IParagraphFormat, IChartParagraphFormat

This class contains the paragraph formatting properties. Unlike IParagraphFormatEffectiveData, all properties of this class are writeable.


This class is used to return and manipulate paragraph formatting properties defined for the particular paragraph. This means that no inheritance is applied when getting values so for the majority of cases you will get values meaning “undefined”.

In order to get the effective formatting parameter values including inherited you need to use getEffective method which returns a IParagraphFormatEffectiveData instance.

Constructors

ConstructorDescription
ParagraphFormat()Initializes a new instance of ParagraphFormat class.

Methods

MethodDescription
getBullet()Returns bullet format of the paragraph.
getDepth()Returns or sets depth of the paragraph.
setDepth(short value)Returns or sets depth of the paragraph.
getAlignment()Returns or sets the text alignment in a paragraph with no inheritance.
setAlignment(int value)Returns or sets the text alignment in a paragraph with no inheritance.
getSpaceWithin()Returns or sets the amount of space between base lines in a paragraph.
setSpaceWithin(float value)Returns or sets the amount of space between base lines in a paragraph.
getSpaceBefore()Returns or sets the amount of space before the first line in a paragraph with no inheritance.
setSpaceBefore(float value)Returns or sets the amount of space before the first line in a paragraph with no inheritance.
getSpaceAfter()Returns or sets the amount of space after the last line in a paragraph with no inheritance.
setSpaceAfter(float value)Returns or sets the amount of space after the last line in a paragraph with no inheritance.
getEastAsianLineBreak()Determines whether the East Asian line break is used in a paragraph.
setEastAsianLineBreak(byte value)Determines whether the East Asian line break is used in a paragraph.
getRightToLeft()Determines whether the Right to Left writing is used in a paragraph.
setRightToLeft(byte value)Determines whether the Right to Left writing is used in a paragraph.
getLatinLineBreak()Determines whether the Latin line break is used in a paragraph.
setLatinLineBreak(byte value)Determines whether the Latin line break is used in a paragraph.
getHangingPunctuation()Determines whether the hanging punctuation is used in a paragraph.
setHangingPunctuation(byte value)Determines whether the hanging punctuation is used in a paragraph.
getMarginLeft()Returns or sets the left margin in a paragraph with no inheritance.
setMarginLeft(float value)Returns or sets the left margin in a paragraph with no inheritance.
getMarginRight()Returns or sets the right margin in a paragraph with no inheritance.
setMarginRight(float value)Returns or sets the right margin in a paragraph with no inheritance.
getIndent()Returns or sets paragraph First Line Indent/Hanging Indent with no inheritance.
setIndent(float value)Returns or sets paragraph First Line Indent/Hanging Indent with no inheritance.
getDefaultTabSize()Returns or sets default tabulation size with no inheritance.
setDefaultTabSize(float value)Returns or sets default tabulation size with no inheritance.
getTabs()Returns tabulations of a paragraph.
getFontAlignment()Returns or sets a font alignment in a paragraph with no inheritance.
setFontAlignment(int value)Returns or sets a font alignment in a paragraph with no inheritance.
getDefaultPortionFormat()Returns default portion format of a paragraph.
getEffective()Gets effective paragraph formatting data with the inheritance applied.
getVersion()

ParagraphFormat()

public ParagraphFormat()

Initializes a new instance of ParagraphFormat class.

getBullet()

public final IBulletFormat getBullet()

Returns bullet format of the paragraph. Read-only IBulletFormat.

Returns: IBulletFormat

getDepth()

public final short getDepth()

Returns or sets depth of the paragraph. Value 0 means undefined value. Read/write short .

Returns: short

setDepth(short value)

public final void setDepth(short value)

Returns or sets depth of the paragraph. Value 0 means undefined value. Read/write short .

Parameters:

ParameterTypeDescription
valueshort

getAlignment()

public final int getAlignment()

Returns or sets the text alignment in a paragraph with no inheritance. Read/write TextAlignment.


The following sample code shows how to Align Text Paragraphs in PowerPoint Presentation.
 
 // Instantiate a Presentation object that represents a PPTX file
 Presentation pres = new Presentation("ParagraphsAlignment.pptx");
 try {
     // Accessing first slide
     ISlide slide = pres.getSlides().get_Item(0);
     // Accessing the first and second placeholder in the slide and typecasting it as AutoShape
     ITextFrame tf1 = ((IAutoShape)slide.getShapes().get_Item(0)).getTextFrame();
     ITextFrame tf2 = ((IAutoShape)slide.getShapes().get_Item(1)).getTextFrame();
     // Change the text in both placeholders
     tf1.setText("Center Align by Aspose");
     tf2.setText("Center Align by Aspose");
     // Getting the first paragraph of the placeholders
     IParagraph para1 = tf1.getParagraphs().get_Item(0);
     IParagraph para2 = tf2.getParagraphs().get_Item(0);
     // Aligning the text paragraph to center
     para1.getParagraphFormat().setAlignment(TextAlignment.Center);
     para2.getParagraphFormat().setAlignment(TextAlignment.Center);
     //Writing the presentation as a PPTX file
     pres.save("Centeralign_out.pptx", SaveFormat.Pptx);
 } finally {
     if (pres != null) pres.dispose();
 }

Returns: int

setAlignment(int value)

public final void setAlignment(int value)

Returns or sets the text alignment in a paragraph with no inheritance. Read/write TextAlignment.


The following sample code shows how to Align Text Paragraphs in PowerPoint Presentation.
 
 // Instantiate a Presentation object that represents a PPTX file
 Presentation pres = new Presentation("ParagraphsAlignment.pptx");
 try {
     // Accessing first slide
     ISlide slide = pres.getSlides().get_Item(0);
     // Accessing the first and second placeholder in the slide and typecasting it as AutoShape
     ITextFrame tf1 = ((IAutoShape)slide.getShapes().get_Item(0)).getTextFrame();
     ITextFrame tf2 = ((IAutoShape)slide.getShapes().get_Item(1)).getTextFrame();
     // Change the text in both placeholders
     tf1.setText("Center Align by Aspose");
     tf2.setText("Center Align by Aspose");
     // Getting the first paragraph of the placeholders
     IParagraph para1 = tf1.getParagraphs().get_Item(0);
     IParagraph para2 = tf2.getParagraphs().get_Item(0);
     // Aligning the text paragraph to center
     para1.getParagraphFormat().setAlignment(TextAlignment.Center);
     para2.getParagraphFormat().setAlignment(TextAlignment.Center);
     //Writing the presentation as a PPTX file
     pres.save("Centeralign_out.pptx", SaveFormat.Pptx);
 } finally {
     if (pres != null) pres.dispose();
 }

Parameters:

ParameterTypeDescription
valueint

getSpaceWithin()

public final float getSpaceWithin()

Returns or sets the amount of space between base lines in a paragraph. Positive value means percentage, negative - size in points. No inheritance applied. Read/write float .

Returns: float

setSpaceWithin(float value)

public final void setSpaceWithin(float value)

Returns or sets the amount of space between base lines in a paragraph. Positive value means percentage, negative - size in points. No inheritance applied. Read/write float .

Parameters:

ParameterTypeDescription
valuefloat

getSpaceBefore()

public final float getSpaceBefore()

Returns or sets the amount of space before the first line in a paragraph with no inheritance. A positive value specifies the percentage of the font size that the white space should be. A negative value specifies the size of the white space in point size. Read/write float .

Returns: float

setSpaceBefore(float value)

public final void setSpaceBefore(float value)

Returns or sets the amount of space before the first line in a paragraph with no inheritance. A positive value specifies the percentage of the font size that the white space should be. A negative value specifies the size of the white space in point size. Read/write float .

Parameters:

ParameterTypeDescription
valuefloat

getSpaceAfter()

public final float getSpaceAfter()

Returns or sets the amount of space after the last line in a paragraph with no inheritance. A positive value specifies the percentage of the font size that the white space should be. A negative value specifies the size of the white space in point size. Read/write float .

Returns: float

setSpaceAfter(float value)

public final void setSpaceAfter(float value)

Returns or sets the amount of space after the last line in a paragraph with no inheritance. A positive value specifies the percentage of the font size that the white space should be. A negative value specifies the size of the white space in point size. Read/write float .

Parameters:

ParameterTypeDescription
valuefloat

getEastAsianLineBreak()

public final byte getEastAsianLineBreak()

Determines whether the East Asian line break is used in a paragraph. No inheritance applied. Read/write NullableBool.

Returns: byte

setEastAsianLineBreak(byte value)

public final void setEastAsianLineBreak(byte value)

Determines whether the East Asian line break is used in a paragraph. No inheritance applied. Read/write NullableBool.

Parameters:

ParameterTypeDescription
valuebyte

getRightToLeft()

public final byte getRightToLeft()

Determines whether the Right to Left writing is used in a paragraph. No inheritance applied. Read/write NullableBool.

Returns: byte

setRightToLeft(byte value)

public final void setRightToLeft(byte value)

Determines whether the Right to Left writing is used in a paragraph. No inheritance applied. Read/write NullableBool.

Parameters:

ParameterTypeDescription
valuebyte

getLatinLineBreak()

public final byte getLatinLineBreak()

Determines whether the Latin line break is used in a paragraph. No inheritance applied. Read/write NullableBool.

Returns: byte

setLatinLineBreak(byte value)

public final void setLatinLineBreak(byte value)

Determines whether the Latin line break is used in a paragraph. No inheritance applied. Read/write NullableBool.

Parameters:

ParameterTypeDescription
valuebyte

getHangingPunctuation()

public final byte getHangingPunctuation()

Determines whether the hanging punctuation is used in a paragraph. No inheritance applied. Read/write NullableBool.

Returns: byte

setHangingPunctuation(byte value)

public final void setHangingPunctuation(byte value)

Determines whether the hanging punctuation is used in a paragraph. No inheritance applied. Read/write NullableBool.

Parameters:

ParameterTypeDescription
valuebyte

getMarginLeft()

public final float getMarginLeft()

Returns or sets the left margin in a paragraph with no inheritance. Read/write float .

Returns: float

setMarginLeft(float value)

public final void setMarginLeft(float value)

Returns or sets the left margin in a paragraph with no inheritance. Read/write float .

Parameters:

ParameterTypeDescription
valuefloat

getMarginRight()

public final float getMarginRight()

Returns or sets the right margin in a paragraph with no inheritance. Read/write float .

Returns: float

setMarginRight(float value)

public final void setMarginRight(float value)

Returns or sets the right margin in a paragraph with no inheritance. Read/write float .

Parameters:

ParameterTypeDescription
valuefloat

getIndent()

public final float getIndent()

Returns or sets paragraph First Line Indent/Hanging Indent with no inheritance. Hanging Indent can be defined with negative values. Read/write float .

Returns: float

setIndent(float value)

public final void setIndent(float value)

Returns or sets paragraph First Line Indent/Hanging Indent with no inheritance. Hanging Indent can be defined with negative values. Read/write float .

Parameters:

ParameterTypeDescription
valuefloat

getDefaultTabSize()

public final float getDefaultTabSize()

Returns or sets default tabulation size with no inheritance. Read/write float .

Returns: float

setDefaultTabSize(float value)

public final void setDefaultTabSize(float value)

Returns or sets default tabulation size with no inheritance. Read/write float .

Parameters:

ParameterTypeDescription
valuefloat

getTabs()

public final ITabCollection getTabs()

Returns tabulations of a paragraph. No inheritance applied. Read-only ITabCollection.

Returns: ITabCollection

getFontAlignment()

public final int getFontAlignment()

Returns or sets a font alignment in a paragraph with no inheritance. Read/write FontAlignment.

Returns: int

setFontAlignment(int value)

public final void setFontAlignment(int value)

Returns or sets a font alignment in a paragraph with no inheritance. Read/write FontAlignment.

Parameters:

ParameterTypeDescription
valueint

getDefaultPortionFormat()

public final IPortionFormat getDefaultPortionFormat()

Returns default portion format of a paragraph. No inheritance applied. Read-only IPortionFormat.

Returns: IPortionFormat

getEffective()

public final IParagraphFormatEffectiveData getEffective()

Gets effective paragraph formatting data with the inheritance applied.


This example demonstrates getting some effective paragraph format properties.
 
 Presentation pres = new Presentation("MyPresentation.pptx");
 try
 {
 	IAutoShape shape = (IAutoShape)pres.getSlides().get_Item(0).getShapes().get_Item(0);
 	IParagraphFormatEffectiveData effectiveParagraphFormat = shape.getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().getEffective();
 	System.out.println("Text alignment: " + effectiveParagraphFormat.getAlignment());
 	System.out.println("Indent: " + effectiveParagraphFormat.getIndent());
 	System.out.println("Bullet type: " + effectiveParagraphFormat.getBullet().getType());
 } finally {
  if (pres != null) pres.dispose();
 }

Returns: IParagraphFormatEffectiveData - A IParagraphFormatEffectiveData.

getVersion()

public long getVersion()

Version. Read-only long.

Returns: long