com.lowagie.text.rtf.document

Class RtfPageSetting

public class RtfPageSetting extends RtfElement implements RtfExtendedElement

The RtfPageSetting stores the page size / page margins for a RtfDocument. INTERNAL CLASS - NOT TO BE USED DIRECTLY

Version: $Id: RtfPageSetting.java 2796 2007-05-27 09:42:20Z psoares33 $

Author: Mark Hall (mhall@edu.uni-klu.ac.at) Thomas Bickel (tmb99@inode.at)

Field Summary
booleanlandscape
Whether the page is portrait or landscape
static byte[]LANDSCAPE
Constant for landscape
intmarginBottom
The bottom margin to use
intmarginLeft
The left margin to use
intmarginRight
The right margin to use
intmarginTop
The top margin to use
static byte[]MARGIN_BOTTOM
Constant for the bottom margin
static byte[]MARGIN_LEFT
Constant for the left margin
static byte[]MARGIN_RIGHT
Constant for the right margin
static byte[]MARGIN_TOP
Constant for the top margin
intpageHeight
The page height to use
intpageWidth
The page width to use
static byte[]PAGE_HEIGHT
Constant for the page width
static byte[]PAGE_WIDTH
Constant for the page height
static byte[]SECTION_MARGIN_BOTTOM
Constant for the section bottom margin
static byte[]SECTION_MARGIN_LEFT
Constant for the section left margin
static byte[]SECTION_MARGIN_RIGHT
Constant for the section right margin
static byte[]SECTION_MARGIN_TOP
Constant for the section top margin
static byte[]SECTION_PAGE_HEIGHT
Constant for the section page height
static byte[]SECTION_PAGE_WIDTH
Constant for the section page width
Constructor Summary
RtfPageSetting(RtfDocument doc)
Constructs a new RtfPageSetting object belonging to a RtfDocument.
Method Summary
intgetMarginBottom()
Gets the bottom margin
intgetMarginLeft()
Gets the left margin
intgetMarginRight()
Gets the right margin
intgetMarginTop()
Gets the top margin
intgetPageHeight()
Gets the page height
intgetPageWidth()
Gets the page width
booleanguessFormat(Rectangle pageSize, boolean rotate)
This method tries to fit the Rectangle pageSize to one of the predefined PageSize rectangles.
booleanrectEquals(Rectangle rect1, Rectangle rect2)
This method compares to Rectangles.
voidsetMarginBottom(int marginBottom)
Sets the bottom margin
voidsetMarginLeft(int marginLeft)
Sets the left margin to use
voidsetMarginRight(int marginRight)
Sets the right margin to use
voidsetMarginTop(int marginTop)
Sets the top margin to use
voidsetPageHeight(int pageHeight)
Sets the page height to use
voidsetPageSize(Rectangle pageSize)
Set the page size to use.
voidsetPageWidth(int pageWidth)
Sets the page width to use
byte[]write()
unused
voidwriteContent(OutputStream out)
unused
byte[]writeDefinition()
Writes the page size / page margin definition
voidwriteDefinition(OutputStream result)
Writes the page size / page margin definition
byte[]writeSectionDefinition()
Writes the definition part for a new section
voidwriteSectionDefinition(OutputStream result)
Writes the definition part for a new section

Field Detail

landscape

private boolean landscape
Whether the page is portrait or landscape

LANDSCAPE

private static final byte[] LANDSCAPE
Constant for landscape

marginBottom

private int marginBottom
The bottom margin to use

marginLeft

private int marginLeft
The left margin to use

marginRight

private int marginRight
The right margin to use

marginTop

private int marginTop
The top margin to use

MARGIN_BOTTOM

private static final byte[] MARGIN_BOTTOM
Constant for the bottom margin

MARGIN_LEFT

private static final byte[] MARGIN_LEFT
Constant for the left margin

MARGIN_RIGHT

private static final byte[] MARGIN_RIGHT
Constant for the right margin

MARGIN_TOP

private static final byte[] MARGIN_TOP
Constant for the top margin

pageHeight

private int pageHeight
The page height to use

pageWidth

private int pageWidth
The page width to use

PAGE_HEIGHT

private static final byte[] PAGE_HEIGHT
Constant for the page width

PAGE_WIDTH

private static final byte[] PAGE_WIDTH
Constant for the page height

SECTION_MARGIN_BOTTOM

private static final byte[] SECTION_MARGIN_BOTTOM
Constant for the section bottom margin

SECTION_MARGIN_LEFT

private static final byte[] SECTION_MARGIN_LEFT
Constant for the section left margin

SECTION_MARGIN_RIGHT

private static final byte[] SECTION_MARGIN_RIGHT
Constant for the section right margin

SECTION_MARGIN_TOP

private static final byte[] SECTION_MARGIN_TOP
Constant for the section top margin

SECTION_PAGE_HEIGHT

private static final byte[] SECTION_PAGE_HEIGHT
Constant for the section page height

SECTION_PAGE_WIDTH

private static final byte[] SECTION_PAGE_WIDTH
Constant for the section page width

Constructor Detail

RtfPageSetting

public RtfPageSetting(RtfDocument doc)
Constructs a new RtfPageSetting object belonging to a RtfDocument.

Parameters: doc The RtfDocument this RtfPageSetting belongs to

Method Detail

getMarginBottom

public int getMarginBottom()
Gets the bottom margin

Returns: Returns the bottom margin

getMarginLeft

public int getMarginLeft()
Gets the left margin

Returns: Returns the left margin

getMarginRight

public int getMarginRight()
Gets the right margin

Returns: Returns the right margin

getMarginTop

public int getMarginTop()
Gets the top margin

Returns: Returns the top margin

getPageHeight

public int getPageHeight()
Gets the page height

Returns: Returns the page height

getPageWidth

public int getPageWidth()
Gets the page width

Returns: Returns the page width

guessFormat

private boolean guessFormat(Rectangle pageSize, boolean rotate)
This method tries to fit the Rectangle pageSize to one of the predefined PageSize rectangles. If a match is found the pageWidth and pageHeight will be set according to values determined from files generated by MS Word2000 and OpenOffice 641. If no match is found the method will try to match the rotated Rectangle by calling itself with the parameter rotate set to true.

Parameters: pageSize the page size for which to guess the correct format rotate Whether we should try to rotate the size befor guessing the format

Returns: True if the format was guessed, false/ otherwise

rectEquals

private boolean rectEquals(Rectangle rect1, Rectangle rect2)
This method compares to Rectangles. They are considered equal if width and height are the same

Parameters: rect1 The first Rectangle to compare rect2 The second Rectangle to compare

Returns: True if the Rectangles equal, false otherwise

setMarginBottom

public void setMarginBottom(int marginBottom)
Sets the bottom margin

Parameters: marginBottom The bottom margin to use

setMarginLeft

public void setMarginLeft(int marginLeft)
Sets the left margin to use

Parameters: marginLeft The left margin to use

setMarginRight

public void setMarginRight(int marginRight)
Sets the right margin to use

Parameters: marginRight The right margin to use

setMarginTop

public void setMarginTop(int marginTop)
Sets the top margin to use

Parameters: marginTop The top margin to use

setPageHeight

public void setPageHeight(int pageHeight)
Sets the page height to use

Parameters: pageHeight The page height to use

setPageSize

public void setPageSize(Rectangle pageSize)
Set the page size to use. This method will use guessFormat to try to guess the correct page format. If no format could be guessed, the sizes from the pageSize are used and the landscape setting is determined by comparing width and height;

Parameters: pageSize The pageSize to use

setPageWidth

public void setPageWidth(int pageWidth)
Sets the page width to use

Parameters: pageWidth The page width to use

write

public byte[] write()

Deprecated: replaced by writeContent

unused

writeContent

public void writeContent(OutputStream out)
unused

writeDefinition

public byte[] writeDefinition()

Deprecated: replaced by writeDefinition

Writes the page size / page margin definition

Returns: A byte array with the page size / page margin definition

writeDefinition

public void writeDefinition(OutputStream result)
Writes the page size / page margin definition

writeSectionDefinition

public byte[] writeSectionDefinition()

Deprecated: replaced by writeSectionDefinition

Writes the definition part for a new section

Returns: A byte array containing the definition for a new section

writeSectionDefinition

public void writeSectionDefinition(OutputStream result)
Writes the definition part for a new section