FrameFormat
Inheritance: java.lang.Object
public class FrameFormat
Represents frame related formatting for a paragraph.
Remarks:
This object is always created. If a paragraph is a frame, then all properties will contain respective values, otherwise all properties are set to their defaults.
Use isFrame() to check whether paragraph is a frame.
Examples:
Shows how to get information about formatting properties of paragraphs that are frames.
Document doc = new Document(getMyDir() + "Paragraph frame.docx");
Paragraph paragraphFrame = IterableUtils.find(doc.getFirstSection().getBody().getParagraphs(), p -> p.getFrameFormat().isFrame());
Assert.assertEquals(233.3d, paragraphFrame.getFrameFormat().getWidth());
Assert.assertEquals(138.8d, paragraphFrame.getFrameFormat().getHeight());
Assert.assertEquals(HeightRule.AT_LEAST, paragraphFrame.getFrameFormat().getHeightRule());
Assert.assertEquals(HorizontalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getHorizontalAlignment());
Assert.assertEquals(VerticalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getVerticalAlignment());
Assert.assertEquals(34.05d, paragraphFrame.getFrameFormat().getHorizontalPosition());
Assert.assertEquals(RelativeHorizontalPosition.PAGE, paragraphFrame.getFrameFormat().getRelativeHorizontalPosition());
Assert.assertEquals(9.0d, paragraphFrame.getFrameFormat().getHorizontalDistanceFromText());
Assert.assertEquals(20.5d, paragraphFrame.getFrameFormat().getVerticalPosition());
Assert.assertEquals(RelativeVerticalPosition.PARAGRAPH, paragraphFrame.getFrameFormat().getRelativeVerticalPosition());
Assert.assertEquals(0.0d, paragraphFrame.getFrameFormat().getVerticalDistanceFromText());
Methods
Method | Description |
---|---|
getHeight() | Gets the height of the specified frame. |
getHeightRule() | Gets the rule for determining the height of the specified frame. |
getHorizontalAlignment() | Gets horizontal alignment of the specified frame. |
getHorizontalDistanceFromText() | Gets horizontal distance between a frame and the surrounding text, in points. |
getHorizontalPosition() | Gets horizontal distance between the edge of the frame and the item specified by the getRelativeHorizontalPosition() property. |
getRelativeHorizontalPosition() | Gets the relative horizontal position of a frame. |
getRelativeVerticalPosition() | Gets the relative vertical position of a frame. |
getVerticalAlignment() | Gets vertical alignment of the specified frame. |
getVerticalDistanceFromText() | Specifies vertical distance (in points) between a frame and the surrounding text. |
getVerticalPosition() | Gets vertical distance between the edge of the frame and the item specified by the getRelativeVerticalPosition() property. |
getWidth() | Gets the width of the specified frame, in points. |
isFrame() | Returns true if the paragraph is a frame. |
getHeight()
public double getHeight()
Gets the height of the specified frame.
Examples:
Shows how to get information about formatting properties of paragraphs that are frames.
Document doc = new Document(getMyDir() + "Paragraph frame.docx");
Paragraph paragraphFrame = IterableUtils.find(doc.getFirstSection().getBody().getParagraphs(), p -> p.getFrameFormat().isFrame());
Assert.assertEquals(233.3d, paragraphFrame.getFrameFormat().getWidth());
Assert.assertEquals(138.8d, paragraphFrame.getFrameFormat().getHeight());
Assert.assertEquals(HeightRule.AT_LEAST, paragraphFrame.getFrameFormat().getHeightRule());
Assert.assertEquals(HorizontalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getHorizontalAlignment());
Assert.assertEquals(VerticalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getVerticalAlignment());
Assert.assertEquals(34.05d, paragraphFrame.getFrameFormat().getHorizontalPosition());
Assert.assertEquals(RelativeHorizontalPosition.PAGE, paragraphFrame.getFrameFormat().getRelativeHorizontalPosition());
Assert.assertEquals(9.0d, paragraphFrame.getFrameFormat().getHorizontalDistanceFromText());
Assert.assertEquals(20.5d, paragraphFrame.getFrameFormat().getVerticalPosition());
Assert.assertEquals(RelativeVerticalPosition.PARAGRAPH, paragraphFrame.getFrameFormat().getRelativeVerticalPosition());
Assert.assertEquals(0.0d, paragraphFrame.getFrameFormat().getVerticalDistanceFromText());
Returns: double - The height of the specified frame.
getHeightRule()
public int getHeightRule()
Gets the rule for determining the height of the specified frame.
Examples:
Shows how to get information about formatting properties of paragraphs that are frames.
Document doc = new Document(getMyDir() + "Paragraph frame.docx");
Paragraph paragraphFrame = IterableUtils.find(doc.getFirstSection().getBody().getParagraphs(), p -> p.getFrameFormat().isFrame());
Assert.assertEquals(233.3d, paragraphFrame.getFrameFormat().getWidth());
Assert.assertEquals(138.8d, paragraphFrame.getFrameFormat().getHeight());
Assert.assertEquals(HeightRule.AT_LEAST, paragraphFrame.getFrameFormat().getHeightRule());
Assert.assertEquals(HorizontalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getHorizontalAlignment());
Assert.assertEquals(VerticalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getVerticalAlignment());
Assert.assertEquals(34.05d, paragraphFrame.getFrameFormat().getHorizontalPosition());
Assert.assertEquals(RelativeHorizontalPosition.PAGE, paragraphFrame.getFrameFormat().getRelativeHorizontalPosition());
Assert.assertEquals(9.0d, paragraphFrame.getFrameFormat().getHorizontalDistanceFromText());
Assert.assertEquals(20.5d, paragraphFrame.getFrameFormat().getVerticalPosition());
Assert.assertEquals(RelativeVerticalPosition.PARAGRAPH, paragraphFrame.getFrameFormat().getRelativeVerticalPosition());
Assert.assertEquals(0.0d, paragraphFrame.getFrameFormat().getVerticalDistanceFromText());
Returns: int - The rule for determining the height of the specified frame. The returned value is one of HeightRule constants.
getHorizontalAlignment()
public int getHorizontalAlignment()
Gets horizontal alignment of the specified frame.
Examples:
Shows how to get information about formatting properties of paragraphs that are frames.
Document doc = new Document(getMyDir() + "Paragraph frame.docx");
Paragraph paragraphFrame = IterableUtils.find(doc.getFirstSection().getBody().getParagraphs(), p -> p.getFrameFormat().isFrame());
Assert.assertEquals(233.3d, paragraphFrame.getFrameFormat().getWidth());
Assert.assertEquals(138.8d, paragraphFrame.getFrameFormat().getHeight());
Assert.assertEquals(HeightRule.AT_LEAST, paragraphFrame.getFrameFormat().getHeightRule());
Assert.assertEquals(HorizontalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getHorizontalAlignment());
Assert.assertEquals(VerticalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getVerticalAlignment());
Assert.assertEquals(34.05d, paragraphFrame.getFrameFormat().getHorizontalPosition());
Assert.assertEquals(RelativeHorizontalPosition.PAGE, paragraphFrame.getFrameFormat().getRelativeHorizontalPosition());
Assert.assertEquals(9.0d, paragraphFrame.getFrameFormat().getHorizontalDistanceFromText());
Assert.assertEquals(20.5d, paragraphFrame.getFrameFormat().getVerticalPosition());
Assert.assertEquals(RelativeVerticalPosition.PARAGRAPH, paragraphFrame.getFrameFormat().getRelativeVerticalPosition());
Assert.assertEquals(0.0d, paragraphFrame.getFrameFormat().getVerticalDistanceFromText());
Returns: int - Horizontal alignment of the specified frame. The returned value is one of HorizontalAlignment constants.
getHorizontalDistanceFromText()
public double getHorizontalDistanceFromText()
Gets horizontal distance between a frame and the surrounding text, in points.
Examples:
Shows how to get information about formatting properties of paragraphs that are frames.
Document doc = new Document(getMyDir() + "Paragraph frame.docx");
Paragraph paragraphFrame = IterableUtils.find(doc.getFirstSection().getBody().getParagraphs(), p -> p.getFrameFormat().isFrame());
Assert.assertEquals(233.3d, paragraphFrame.getFrameFormat().getWidth());
Assert.assertEquals(138.8d, paragraphFrame.getFrameFormat().getHeight());
Assert.assertEquals(HeightRule.AT_LEAST, paragraphFrame.getFrameFormat().getHeightRule());
Assert.assertEquals(HorizontalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getHorizontalAlignment());
Assert.assertEquals(VerticalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getVerticalAlignment());
Assert.assertEquals(34.05d, paragraphFrame.getFrameFormat().getHorizontalPosition());
Assert.assertEquals(RelativeHorizontalPosition.PAGE, paragraphFrame.getFrameFormat().getRelativeHorizontalPosition());
Assert.assertEquals(9.0d, paragraphFrame.getFrameFormat().getHorizontalDistanceFromText());
Assert.assertEquals(20.5d, paragraphFrame.getFrameFormat().getVerticalPosition());
Assert.assertEquals(RelativeVerticalPosition.PARAGRAPH, paragraphFrame.getFrameFormat().getRelativeVerticalPosition());
Assert.assertEquals(0.0d, paragraphFrame.getFrameFormat().getVerticalDistanceFromText());
Returns: double - Horizontal distance between a frame and the surrounding text, in points.
getHorizontalPosition()
public double getHorizontalPosition()
Gets horizontal distance between the edge of the frame and the item specified by the getRelativeHorizontalPosition() property.
Examples:
Shows how to get information about formatting properties of paragraphs that are frames.
Document doc = new Document(getMyDir() + "Paragraph frame.docx");
Paragraph paragraphFrame = IterableUtils.find(doc.getFirstSection().getBody().getParagraphs(), p -> p.getFrameFormat().isFrame());
Assert.assertEquals(233.3d, paragraphFrame.getFrameFormat().getWidth());
Assert.assertEquals(138.8d, paragraphFrame.getFrameFormat().getHeight());
Assert.assertEquals(HeightRule.AT_LEAST, paragraphFrame.getFrameFormat().getHeightRule());
Assert.assertEquals(HorizontalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getHorizontalAlignment());
Assert.assertEquals(VerticalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getVerticalAlignment());
Assert.assertEquals(34.05d, paragraphFrame.getFrameFormat().getHorizontalPosition());
Assert.assertEquals(RelativeHorizontalPosition.PAGE, paragraphFrame.getFrameFormat().getRelativeHorizontalPosition());
Assert.assertEquals(9.0d, paragraphFrame.getFrameFormat().getHorizontalDistanceFromText());
Assert.assertEquals(20.5d, paragraphFrame.getFrameFormat().getVerticalPosition());
Assert.assertEquals(RelativeVerticalPosition.PARAGRAPH, paragraphFrame.getFrameFormat().getRelativeVerticalPosition());
Assert.assertEquals(0.0d, paragraphFrame.getFrameFormat().getVerticalDistanceFromText());
Returns: double - Horizontal distance between the edge of the frame and the item specified by the getRelativeHorizontalPosition() property.
getRelativeHorizontalPosition()
public int getRelativeHorizontalPosition()
Gets the relative horizontal position of a frame.
Examples:
Shows how to get information about formatting properties of paragraphs that are frames.
Document doc = new Document(getMyDir() + "Paragraph frame.docx");
Paragraph paragraphFrame = IterableUtils.find(doc.getFirstSection().getBody().getParagraphs(), p -> p.getFrameFormat().isFrame());
Assert.assertEquals(233.3d, paragraphFrame.getFrameFormat().getWidth());
Assert.assertEquals(138.8d, paragraphFrame.getFrameFormat().getHeight());
Assert.assertEquals(HeightRule.AT_LEAST, paragraphFrame.getFrameFormat().getHeightRule());
Assert.assertEquals(HorizontalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getHorizontalAlignment());
Assert.assertEquals(VerticalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getVerticalAlignment());
Assert.assertEquals(34.05d, paragraphFrame.getFrameFormat().getHorizontalPosition());
Assert.assertEquals(RelativeHorizontalPosition.PAGE, paragraphFrame.getFrameFormat().getRelativeHorizontalPosition());
Assert.assertEquals(9.0d, paragraphFrame.getFrameFormat().getHorizontalDistanceFromText());
Assert.assertEquals(20.5d, paragraphFrame.getFrameFormat().getVerticalPosition());
Assert.assertEquals(RelativeVerticalPosition.PARAGRAPH, paragraphFrame.getFrameFormat().getRelativeVerticalPosition());
Assert.assertEquals(0.0d, paragraphFrame.getFrameFormat().getVerticalDistanceFromText());
Returns: int - The relative horizontal position of a frame. The returned value is one of RelativeHorizontalPosition constants.
getRelativeVerticalPosition()
public int getRelativeVerticalPosition()
Gets the relative vertical position of a frame.
Examples:
Shows how to get information about formatting properties of paragraphs that are frames.
Document doc = new Document(getMyDir() + "Paragraph frame.docx");
Paragraph paragraphFrame = IterableUtils.find(doc.getFirstSection().getBody().getParagraphs(), p -> p.getFrameFormat().isFrame());
Assert.assertEquals(233.3d, paragraphFrame.getFrameFormat().getWidth());
Assert.assertEquals(138.8d, paragraphFrame.getFrameFormat().getHeight());
Assert.assertEquals(HeightRule.AT_LEAST, paragraphFrame.getFrameFormat().getHeightRule());
Assert.assertEquals(HorizontalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getHorizontalAlignment());
Assert.assertEquals(VerticalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getVerticalAlignment());
Assert.assertEquals(34.05d, paragraphFrame.getFrameFormat().getHorizontalPosition());
Assert.assertEquals(RelativeHorizontalPosition.PAGE, paragraphFrame.getFrameFormat().getRelativeHorizontalPosition());
Assert.assertEquals(9.0d, paragraphFrame.getFrameFormat().getHorizontalDistanceFromText());
Assert.assertEquals(20.5d, paragraphFrame.getFrameFormat().getVerticalPosition());
Assert.assertEquals(RelativeVerticalPosition.PARAGRAPH, paragraphFrame.getFrameFormat().getRelativeVerticalPosition());
Assert.assertEquals(0.0d, paragraphFrame.getFrameFormat().getVerticalDistanceFromText());
Returns: int - The relative vertical position of a frame. The returned value is one of RelativeVerticalPosition constants.
getVerticalAlignment()
public int getVerticalAlignment()
Gets vertical alignment of the specified frame.
Examples:
Shows how to get information about formatting properties of paragraphs that are frames.
Document doc = new Document(getMyDir() + "Paragraph frame.docx");
Paragraph paragraphFrame = IterableUtils.find(doc.getFirstSection().getBody().getParagraphs(), p -> p.getFrameFormat().isFrame());
Assert.assertEquals(233.3d, paragraphFrame.getFrameFormat().getWidth());
Assert.assertEquals(138.8d, paragraphFrame.getFrameFormat().getHeight());
Assert.assertEquals(HeightRule.AT_LEAST, paragraphFrame.getFrameFormat().getHeightRule());
Assert.assertEquals(HorizontalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getHorizontalAlignment());
Assert.assertEquals(VerticalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getVerticalAlignment());
Assert.assertEquals(34.05d, paragraphFrame.getFrameFormat().getHorizontalPosition());
Assert.assertEquals(RelativeHorizontalPosition.PAGE, paragraphFrame.getFrameFormat().getRelativeHorizontalPosition());
Assert.assertEquals(9.0d, paragraphFrame.getFrameFormat().getHorizontalDistanceFromText());
Assert.assertEquals(20.5d, paragraphFrame.getFrameFormat().getVerticalPosition());
Assert.assertEquals(RelativeVerticalPosition.PARAGRAPH, paragraphFrame.getFrameFormat().getRelativeVerticalPosition());
Assert.assertEquals(0.0d, paragraphFrame.getFrameFormat().getVerticalDistanceFromText());
Returns: int - Vertical alignment of the specified frame. The returned value is one of VerticalAlignment constants.
getVerticalDistanceFromText()
public double getVerticalDistanceFromText()
Specifies vertical distance (in points) between a frame and the surrounding text.
Examples:
Shows how to get information about formatting properties of paragraphs that are frames.
Document doc = new Document(getMyDir() + "Paragraph frame.docx");
Paragraph paragraphFrame = IterableUtils.find(doc.getFirstSection().getBody().getParagraphs(), p -> p.getFrameFormat().isFrame());
Assert.assertEquals(233.3d, paragraphFrame.getFrameFormat().getWidth());
Assert.assertEquals(138.8d, paragraphFrame.getFrameFormat().getHeight());
Assert.assertEquals(HeightRule.AT_LEAST, paragraphFrame.getFrameFormat().getHeightRule());
Assert.assertEquals(HorizontalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getHorizontalAlignment());
Assert.assertEquals(VerticalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getVerticalAlignment());
Assert.assertEquals(34.05d, paragraphFrame.getFrameFormat().getHorizontalPosition());
Assert.assertEquals(RelativeHorizontalPosition.PAGE, paragraphFrame.getFrameFormat().getRelativeHorizontalPosition());
Assert.assertEquals(9.0d, paragraphFrame.getFrameFormat().getHorizontalDistanceFromText());
Assert.assertEquals(20.5d, paragraphFrame.getFrameFormat().getVerticalPosition());
Assert.assertEquals(RelativeVerticalPosition.PARAGRAPH, paragraphFrame.getFrameFormat().getRelativeVerticalPosition());
Assert.assertEquals(0.0d, paragraphFrame.getFrameFormat().getVerticalDistanceFromText());
Returns: double - The corresponding double value.
getVerticalPosition()
public double getVerticalPosition()
Gets vertical distance between the edge of the frame and the item specified by the getRelativeVerticalPosition() property.
Examples:
Shows how to get information about formatting properties of paragraphs that are frames.
Document doc = new Document(getMyDir() + "Paragraph frame.docx");
Paragraph paragraphFrame = IterableUtils.find(doc.getFirstSection().getBody().getParagraphs(), p -> p.getFrameFormat().isFrame());
Assert.assertEquals(233.3d, paragraphFrame.getFrameFormat().getWidth());
Assert.assertEquals(138.8d, paragraphFrame.getFrameFormat().getHeight());
Assert.assertEquals(HeightRule.AT_LEAST, paragraphFrame.getFrameFormat().getHeightRule());
Assert.assertEquals(HorizontalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getHorizontalAlignment());
Assert.assertEquals(VerticalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getVerticalAlignment());
Assert.assertEquals(34.05d, paragraphFrame.getFrameFormat().getHorizontalPosition());
Assert.assertEquals(RelativeHorizontalPosition.PAGE, paragraphFrame.getFrameFormat().getRelativeHorizontalPosition());
Assert.assertEquals(9.0d, paragraphFrame.getFrameFormat().getHorizontalDistanceFromText());
Assert.assertEquals(20.5d, paragraphFrame.getFrameFormat().getVerticalPosition());
Assert.assertEquals(RelativeVerticalPosition.PARAGRAPH, paragraphFrame.getFrameFormat().getRelativeVerticalPosition());
Assert.assertEquals(0.0d, paragraphFrame.getFrameFormat().getVerticalDistanceFromText());
Returns: double - Vertical distance between the edge of the frame and the item specified by the getRelativeVerticalPosition() property.
getWidth()
public double getWidth()
Gets the width of the specified frame, in points.
Examples:
Shows how to get information about formatting properties of paragraphs that are frames.
Document doc = new Document(getMyDir() + "Paragraph frame.docx");
Paragraph paragraphFrame = IterableUtils.find(doc.getFirstSection().getBody().getParagraphs(), p -> p.getFrameFormat().isFrame());
Assert.assertEquals(233.3d, paragraphFrame.getFrameFormat().getWidth());
Assert.assertEquals(138.8d, paragraphFrame.getFrameFormat().getHeight());
Assert.assertEquals(HeightRule.AT_LEAST, paragraphFrame.getFrameFormat().getHeightRule());
Assert.assertEquals(HorizontalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getHorizontalAlignment());
Assert.assertEquals(VerticalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getVerticalAlignment());
Assert.assertEquals(34.05d, paragraphFrame.getFrameFormat().getHorizontalPosition());
Assert.assertEquals(RelativeHorizontalPosition.PAGE, paragraphFrame.getFrameFormat().getRelativeHorizontalPosition());
Assert.assertEquals(9.0d, paragraphFrame.getFrameFormat().getHorizontalDistanceFromText());
Assert.assertEquals(20.5d, paragraphFrame.getFrameFormat().getVerticalPosition());
Assert.assertEquals(RelativeVerticalPosition.PARAGRAPH, paragraphFrame.getFrameFormat().getRelativeVerticalPosition());
Assert.assertEquals(0.0d, paragraphFrame.getFrameFormat().getVerticalDistanceFromText());
Returns: double - The width of the specified frame, in points.
isFrame()
public boolean isFrame()
Returns true if the paragraph is a frame.
Examples:
Shows how to get information about formatting properties of paragraphs that are frames.
Document doc = new Document(getMyDir() + "Paragraph frame.docx");
Paragraph paragraphFrame = IterableUtils.find(doc.getFirstSection().getBody().getParagraphs(), p -> p.getFrameFormat().isFrame());
Assert.assertEquals(233.3d, paragraphFrame.getFrameFormat().getWidth());
Assert.assertEquals(138.8d, paragraphFrame.getFrameFormat().getHeight());
Assert.assertEquals(HeightRule.AT_LEAST, paragraphFrame.getFrameFormat().getHeightRule());
Assert.assertEquals(HorizontalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getHorizontalAlignment());
Assert.assertEquals(VerticalAlignment.DEFAULT, paragraphFrame.getFrameFormat().getVerticalAlignment());
Assert.assertEquals(34.05d, paragraphFrame.getFrameFormat().getHorizontalPosition());
Assert.assertEquals(RelativeHorizontalPosition.PAGE, paragraphFrame.getFrameFormat().getRelativeHorizontalPosition());
Assert.assertEquals(9.0d, paragraphFrame.getFrameFormat().getHorizontalDistanceFromText());
Assert.assertEquals(20.5d, paragraphFrame.getFrameFormat().getVerticalPosition());
Assert.assertEquals(RelativeVerticalPosition.PARAGRAPH, paragraphFrame.getFrameFormat().getRelativeVerticalPosition());
Assert.assertEquals(0.0d, paragraphFrame.getFrameFormat().getVerticalDistanceFromText());
Returns: boolean - true if the paragraph is a frame.