PHP Class PHPRtfLite

Author: Denis Slaveckij ([email protected])
Author: Steffen Zeidler ([email protected])
Mostrar archivo Open project: phprtflite/phprtflite Class Usage Examples

Protected Properties

Property Type Description
$_borderSurroundsFooter boolean
$_borderSurroundsHeader boolean
$_colorTable PHPRtfLite_DocHead_ColorTable color table instance
$_defaultFont PHPRtfLite_Font default font
$_fontTable PHPRtfLite_DocHead_FontTable font table instance
$_footers PHPRtfLite_Container_Footer[] rtf footers
$_headers PHPRtfLite_Container_Header[] rtf headers
$_properties array rtf properties
$_sections PHPRtfLite_Container_Section[] rtf sections

Public Methods

Method Description
__construct ( )
addFooter ( string $type = PHPRtfLite_Container_Footer::TYPE_ALL, PHPRtfLite_Container_Footer $footer = null ) : PHPRtfLite_Container_Footer creates footer for the document
addHeader ( string $type = PHPRtfLite_Container_Header::TYPE_ALL, PHPRtfLite_Container_Header $header = null ) : PHPRtfLite_Container_Header creates header for the document
addSection ( PHPRtfLite_Container_Section $section = null ) : PHPRtfLite_Container_Section adds section to rtf document
borderSurroundsFooter ( ) : boolean checks, if border surrounds footer
borderSurroundsHeader ( ) : boolean checks, if border surrounds header
convertNewlinesToRtfCode ( string $text ) : string convert new lines to rtf line breaks
free ( )
getBorder ( ) : PHPRtfLite_Border gets border of document
getCharset ( ) : string gets charset for rtf text inputs
getColorTable ( ) : PHPRtfLite_DocHead_ColorTable gets color table
getContent ( boolean $free = true ) : string gets rtf document code
getDefaultFont ( ) : PHPRtfLite_Font gets default font
getDefaultFontForNotes ( ) : PHPRtfLite_Font gets default font for notes
getDefaultTabWidth ( ) : float sets default tab width of the document
getEndnoteNumberingType ( ) : integer gets endnote numbering type
getEndnoteStartNumber ( ) : integer gets endnote start number
getFontTable ( ) : PHPRtfLite_DocHead_FontTable gets font table
getFooters ( ) : array gets defined footers for document pages
getFootnoteNumberingType ( ) : integer gets footnote numbering type
getFootnoteStartNumber ( ) : integer gets footnote start number
getGutter ( ) : float gets the gutter width
getHeaders ( ) : array gets defined headers for document pages
getMarginBottom ( ) : float gets the bottom margin of document pages
getMarginLeft ( ) : float gets the left margin of document pages
getMarginRight ( ) : float gets the right margin of document pages
getMarginTop ( ) : float gets the top margin of document pages
getNoteDocHead ( ) : PHPRtfLite_DocHead_Note gets document head definition for notes
getPageNumberStart ( ) : integer gets the beginning page number
getPaperHeight ( ) : float gets the paper height of document
getPaperWidth ( ) : float gets the paper width of document
getProperty ( string $name ) : string gets rtf property
getSections ( ) : array gets sections
getViewMode ( ) : integer gets the view mode of the document
getWriter ( ) : PHPRtfLite_Writer_Interface gets writer
getZoomLevel ( ) : integer gets the zoom level (in percents) of the document
getZoomMode ( ) : integer gets the zoom mode of the document
hasSpecialLayoutForFirstPage ( ) : boolean returns true, if first page has special layout
isLandscape ( ) : boolean returns true, if landscape layout should be used
isMirrorMargins ( ) : boolean returns true, if use mirror margins should be used
isOddEvenDifferent ( ) : boolean gets if odd and even headers/footers are different
isRestartEndnoteNumberEachPage ( ) : boolean checks, if endnote numbering shall be started on each page
isRestartFootnoteNumberEachPage ( ) : boolean sets restart endnote number on each page
quoteRtfCode ( string $text, boolean $convertNewlines = true ) : string quotes rtf code
registerAutoloader ( ) : boolean registers autoloader for PHPRtfLite classes
registerFont ( PHPRtfLite_Font $font ) registers the font in color table and font table
registerParFormat ( PHPRtfLite_ParFormat $parFormat ) registers the par format in color table
save ( string $file, boolean $free = true ) saves rtf document to file
sendRtf ( string $filename = 'simple', $free = true ) sends rtf content as file attachment
setBorder ( PHPRtfLite_Border $border ) Sets border to rtf document. Sections may override this border.
setBorderSurroundsFooter ( boolean $borderSurroundsFooter = true ) : PHPRtfLite
setBorderSurroundsHeader ( boolean $borderSurroundsHeader = true ) : PHPRtfLite sets border surrounds header
setBorders ( PHPRtfLite_Border_Format $borderFormat, boolean $left = true, boolean $top = true, boolean $right = true, boolean $bottom = true ) Sets borders to rtf document. Sections may override this border.
setCharset ( string $charset ) sets charset for rtf text inputs
setDefaultFont ( PHPRtfLite_Font $font ) sets default font
setDefaultFontForNotes ( PHPRtfLite_Font $font ) sets default font for notes
setDefaultTabWidth ( float $defaultTabWidth ) sets default tab width of the document
setEndnoteNumberingType ( integer $numberingType ) sets endnote numbering type
setEndnoteStartNumber ( integer $startNumber ) sets endnote start number
setFootnoteNumberingType ( integer $numberingType ) sets footnote numbering type
setFootnoteStartNumber ( integer $startNumber ) sets footnote start number
setGutter ( float $gutter ) sets the gutter width.
NOTICE: Does not work with OpenOffice.
setHyphenation ( ) sets using hyphenation
setLandscape ( ) sets landscape orientation for the document
setMarginBottom ( float $margin ) sets the bottom margin of document pages
setMarginLeft ( float $margin ) sets the left margin of document pages
setMarginRight ( float $margin ) sets the right margin of document pages
setMarginTop ( float $margin ) sets the top margin of document pages
setMargins ( float $marginLeft, float $marginTop, float $marginRight, float $marginBottom ) sets the margins of document pages
setMirrorMargins ( ) sets the margin definitions on left and right pages.
NOTICE: Does not work with OpenOffice.
setOddEvenDifferent ( boolean $different = true ) sets if odd and even headers/footers are different
setPageNumberStart ( integer $pageNumber ) sets the beginning page number
setPaperFormat ( string $paperFormat ) Sets the paper format.
setPaperHeight ( float $height ) sets the paper height of document
setPaperWidth ( float $width ) sets the paper width of document
setProperty ( string $name, mixed $value ) sets document information properties
setRestartEndnoteNumberEachPage ( ) : boolean checks, if footnote numbering shall be started on each page
setRestartFootnoteNumberEachPage ( ) sets restart footnote number on each page
setSpecialLayoutForFirstPage ( boolean $specialLayout = true ) sets that first page has a special layout
setUseTemporaryFile ( boolean $flag = true ) set that a temporary file should be used for creating the output NOTE: is slowing down the rendering because of the io operations, but uses less memory
setViewMode ( integer $viewMode ) sets the view mode of the document
setWriter ( PHPRtfLite_Writer_Interface $writer ) sets writer
setZoomLevel ( integer $zoom ) sets the zoom level (in percents) of the document. By default word uses 100%.
NOTICE: if zoom mode is defined, zoom level is not used.
setZoomMode ( integer $zoomMode ) sets the zoom mode of the document
unregisterAutoloader ( ) : boolean unregisters autoloader for PHPRtfLite classes

Protected Methods

Method Description
getInfoPart ( ) : string gets rtf info part
render ( ) prepares rtf contents

Private Methods

Method Description
createWriter ( string $file = null ) creates writer

Method Details

__construct() public method

public __construct ( )

addFooter() public method

creates footer for the document
public addFooter ( string $type = PHPRtfLite_Container_Footer::TYPE_ALL, PHPRtfLite_Container_Footer $footer = null ) : PHPRtfLite_Container_Footer
$type string Represented by class constants PHPRtfLite_Container_Footer::TYPE_*
Possible values:
PHPRtfLite_Container_Footer::TYPE_ALL all pages (different odd and even headers/footers must be not set)
PHPRtfLite_Container_Footer::TYPE_LEFT left pages (different odd and even headers/footers must be set)
PHPRtfLite_Container_Footer::TYPE_RIGHT right pages (different odd and even headers/footers must be set)
PHPRtfLite_Container_Footer::TYPE_FIRST first page
$footer PHPRtfLite_Container_Footer
return PHPRtfLite_Container_Footer

addHeader() public method

creates header for the document
public addHeader ( string $type = PHPRtfLite_Container_Header::TYPE_ALL, PHPRtfLite_Container_Header $header = null ) : PHPRtfLite_Container_Header
$type string Represented by class constants PHPRtfLite_Container_Header::TYPE_*
Possible values:
PHPRtfLite_Container_Header::TYPE_ALL all pages (different odd and even headers/footers must be not set)
PHPRtfLite_Container_Header::TYPE_LEFT left pages (different odd and even headers/footers must be set)
PHPRtfLite_Container_Header::TYPE_RIGHT right pages (different odd and even headers/footers must be set
PHPRtfLite_Container_Header::TYPE_FIRST first page
$header PHPRtfLite_Container_Header
return PHPRtfLite_Container_Header

addSection() public method

adds section to rtf document
public addSection ( PHPRtfLite_Container_Section $section = null ) : PHPRtfLite_Container_Section
$section PHPRtfLite_Container_Section
return PHPRtfLite_Container_Section

borderSurroundsFooter() public method

checks, if border surrounds footer
public borderSurroundsFooter ( ) : boolean
return boolean

borderSurroundsHeader() public method

checks, if border surrounds header
public borderSurroundsHeader ( ) : boolean
return boolean

convertNewlinesToRtfCode() public static method

convert new lines to rtf line breaks
public static convertNewlinesToRtfCode ( string $text ) : string
$text string
return string

free() public method

public free ( )

getBorder() public method

gets border of document
public getBorder ( ) : PHPRtfLite_Border
return PHPRtfLite_Border

getCharset() public method

gets charset for rtf text inputs
public getCharset ( ) : string
return string

getColorTable() public method

gets color table
public getColorTable ( ) : PHPRtfLite_DocHead_ColorTable
return PHPRtfLite_DocHead_ColorTable

getContent() public method

gets rtf document code
public getContent ( boolean $free = true ) : string
$free boolean
return string

getDefaultFont() public method

gets default font
public getDefaultFont ( ) : PHPRtfLite_Font
return PHPRtfLite_Font

getDefaultFontForNotes() public method

gets default font for notes
public getDefaultFontForNotes ( ) : PHPRtfLite_Font
return PHPRtfLite_Font

getDefaultTabWidth() public method

sets default tab width of the document
public getDefaultTabWidth ( ) : float
return float $defaultTabWidth Default tab width

getEndnoteNumberingType() public method

gets endnote numbering type

getEndnoteStartNumber() public method

gets endnote start number
public getEndnoteStartNumber ( ) : integer
return integer

getFontTable() public method

gets font table
public getFontTable ( ) : PHPRtfLite_DocHead_FontTable
return PHPRtfLite_DocHead_FontTable

getFooters() public method

gets defined footers for document pages
public getFooters ( ) : array
return array contains PHPRtfLite_Container_FOOTER objects

getFootnoteNumberingType() public method

gets footnote numbering type

getFootnoteStartNumber() public method

gets footnote start number
public getFootnoteStartNumber ( ) : integer
return integer

getGutter() public method

gets the gutter width
public getGutter ( ) : float
return float $gutter gutter width

getHeaders() public method

gets defined headers for document pages
public getHeaders ( ) : array
return array contains PHPRtfLite_Container_Header objects

getInfoPart() protected method

gets rtf info part
protected getInfoPart ( ) : string
return string

getMarginBottom() public method

gets the bottom margin of document pages
public getMarginBottom ( ) : float
return float $margin

getMarginLeft() public method

gets the left margin of document pages
public getMarginLeft ( ) : float
return float $margin

getMarginRight() public method

gets the right margin of document pages
public getMarginRight ( ) : float
return float $margin

getMarginTop() public method

gets the top margin of document pages
public getMarginTop ( ) : float
return float $margin

getNoteDocHead() public method

gets document head definition for notes
public getNoteDocHead ( ) : PHPRtfLite_DocHead_Note
return PHPRtfLite_DocHead_Note

getPageNumberStart() public method

gets the beginning page number
public getPageNumberStart ( ) : integer
return integer

getPaperHeight() public method

gets the paper height of document
public getPaperHeight ( ) : float
return float $paperHeight paper height

getPaperWidth() public method

gets the paper width of document
public getPaperWidth ( ) : float
return float $paperWidth paper width

getProperty() public method

gets rtf property
public getProperty ( string $name ) : string
$name string
return string

getSections() public method

gets sections
public getSections ( ) : array
return array

getViewMode() public method

gets the view mode of the document
public getViewMode ( ) : integer
return integer view mode represented as class constants VIEW_MODE_*

getWriter() public method

gets writer
public getWriter ( ) : PHPRtfLite_Writer_Interface
return PHPRtfLite_Writer_Interface

getZoomLevel() public method

gets the zoom level (in percents) of the document
public getZoomLevel ( ) : integer
return integer $zoom zoom level

getZoomMode() public method

gets the zoom mode of the document
public getZoomMode ( ) : integer
return integer

hasSpecialLayoutForFirstPage() public method

returns true, if first page has special layout

isLandscape() public method

returns true, if landscape layout should be used
public isLandscape ( ) : boolean
return boolean

isMirrorMargins() public method

returns true, if use mirror margins should be used
public isMirrorMargins ( ) : boolean
return boolean

isOddEvenDifferent() public method

gets if odd and even headers/footers are different
public isOddEvenDifferent ( ) : boolean
return boolean

isRestartEndnoteNumberEachPage() public method

checks, if endnote numbering shall be started on each page

isRestartFootnoteNumberEachPage() public method

sets restart endnote number on each page

quoteRtfCode() public static method

quotes rtf code
public static quoteRtfCode ( string $text, boolean $convertNewlines = true ) : string
$text string
$convertNewlines boolean
return string

registerAutoloader() public static method

registers autoloader for PHPRtfLite classes
public static registerAutoloader ( ) : boolean
return boolean

registerFont() public method

registers the font in color table and font table
public registerFont ( PHPRtfLite_Font $font )
$font PHPRtfLite_Font

registerParFormat() public method

registers the par format in color table
public registerParFormat ( PHPRtfLite_ParFormat $parFormat )
$parFormat PHPRtfLite_ParFormat

render() protected method

prepares rtf contents
protected render ( )

save() public method

saves rtf document to file
public save ( string $file, boolean $free = true )
$file string Name of file
$free boolean

sendRtf() public method

sends rtf content as file attachment
public sendRtf ( string $filename = 'simple', $free = true )
$filename string

setBorder() public method

Sets border to rtf document. Sections may override this border.
public setBorder ( PHPRtfLite_Border $border )
$border PHPRtfLite_Border

setBorderSurroundsFooter() public method

public setBorderSurroundsFooter ( boolean $borderSurroundsFooter = true ) : PHPRtfLite
$borderSurroundsFooter boolean
return PHPRtfLite

setBorderSurroundsHeader() public method

sets border surrounds header
public setBorderSurroundsHeader ( boolean $borderSurroundsHeader = true ) : PHPRtfLite
$borderSurroundsHeader boolean
return PHPRtfLite

setBorders() public method

Sets borders to rtf document. Sections may override this border.
public setBorders ( PHPRtfLite_Border_Format $borderFormat, boolean $left = true, boolean $top = true, boolean $right = true, boolean $bottom = true )
$borderFormat PHPRtfLite_Border_Format
$left boolean
$top boolean
$right boolean
$bottom boolean

setCharset() public method

sets charset for rtf text inputs
public setCharset ( string $charset )
$charset string

setDefaultFont() public method

sets default font
public setDefaultFont ( PHPRtfLite_Font $font )
$font PHPRtfLite_Font

setDefaultFontForNotes() public method

sets default font for notes
public setDefaultFontForNotes ( PHPRtfLite_Font $font )
$font PHPRtfLite_Font

setDefaultTabWidth() public method

sets default tab width of the document
public setDefaultTabWidth ( float $defaultTabWidth )
$defaultTabWidth float Default tab width

setEndnoteNumberingType() public method

sets endnote numbering type
public setEndnoteNumberingType ( integer $numberingType )
$numberingType integer

setEndnoteStartNumber() public method

sets endnote start number
public setEndnoteStartNumber ( integer $startNumber )
$startNumber integer

setFootnoteNumberingType() public method

sets footnote numbering type
public setFootnoteNumberingType ( integer $numberingType )
$numberingType integer

setFootnoteStartNumber() public method

sets footnote start number
public setFootnoteStartNumber ( integer $startNumber )
$startNumber integer

setGutter() public method

sets the gutter width.
NOTICE: Does not work with OpenOffice.
public setGutter ( float $gutter )
$gutter float gutter width

setHyphenation() public method

sets using hyphenation
public setHyphenation ( )

setLandscape() public method

sets landscape orientation for the document
public setLandscape ( )

setMarginBottom() public method

sets the bottom margin of document pages
public setMarginBottom ( float $margin )
$margin float

setMarginLeft() public method

sets the left margin of document pages
public setMarginLeft ( float $margin )
$margin float

setMarginRight() public method

sets the right margin of document pages
public setMarginRight ( float $margin )
$margin float

setMarginTop() public method

sets the top margin of document pages
public setMarginTop ( float $margin )
$margin float

setMargins() public method

sets the margins of document pages
public setMargins ( float $marginLeft, float $marginTop, float $marginRight, float $marginBottom )
$marginLeft float Margin left (default 3 cm)
$marginTop float Margin top (default 1 cm)
$marginRight float Margin right (default 3 cm)
$marginBottom float Margin bottom (default 2 cm)

setMirrorMargins() public method

sets the margin definitions on left and right pages.
NOTICE: Does not work with OpenOffice.
public setMirrorMargins ( )

setOddEvenDifferent() public method

sets if odd and even headers/footers are different
public setOddEvenDifferent ( boolean $different = true )
$different boolean

setPageNumberStart() public method

sets the beginning page number
public setPageNumberStart ( integer $pageNumber )
$pageNumber integer Beginning page number (if not defined, Word uses 1)

setPaperFormat() public method

Sets the paper format.
public setPaperFormat ( string $paperFormat )
$paperFormat string

setPaperHeight() public method

sets the paper height of document
public setPaperHeight ( float $height )
$height float paper height

setPaperWidth() public method

sets the paper width of document
public setPaperWidth ( float $width )
$width float pager width

setProperty() public method

sets document information properties
public setProperty ( string $name, mixed $value )
$name string Property of document. Possible properties:
'title' => title of the document (value string)
'subject' => subject of the document (value string)
'author' => author of the document (value string)
'manager' => manager of the document (value string)
'company' => company of author (value string)
'operator' => operator of document. Operator is a person who last made changes to the document. (value string)
'category' => category of document (value string)
'keywords' => keywords of document (value string)
'doccomm' => comments of document (value string)
'creatim' => creation time (value int)
'revtim' => last revision time (value int)
'buptim' => last backup time (value int)
'printim' => last print time (value int)
$value mixed Value

setRestartEndnoteNumberEachPage() public method

checks, if footnote numbering shall be started on each page

setRestartFootnoteNumberEachPage() public method

sets restart footnote number on each page

setSpecialLayoutForFirstPage() public method

sets that first page has a special layout
public setSpecialLayoutForFirstPage ( boolean $specialLayout = true )
$specialLayout boolean

setUseTemporaryFile() public method

set that a temporary file should be used for creating the output NOTE: is slowing down the rendering because of the io operations, but uses less memory
public setUseTemporaryFile ( boolean $flag = true )
$flag boolean default is true

setViewMode() public method

sets the view mode of the document
public setViewMode ( integer $viewMode )
$viewMode integer View Mode. Represented as class constants VIEW_MODE_*
Possible values:
VIEW_MODE_NONE => 0 - None
VIEW_MODE_PAGE_LAYOUT => 1 - Page Layout view
VIEW_MODE_OUTLINE => 2 - Outline view
VIEW_MODE_MASTER => 3 - Master Document view
VIEW_MODE_NORMAL => 4 - Normal view
VIEW_MODE_ONLINE_LAYOUT => 5 - Online Layout view

setWriter() public method

sets writer
public setWriter ( PHPRtfLite_Writer_Interface $writer )
$writer PHPRtfLite_Writer_Interface

setZoomLevel() public method

sets the zoom level (in percents) of the document. By default word uses 100%.
NOTICE: if zoom mode is defined, zoom level is not used.
public setZoomLevel ( integer $zoom )
$zoom integer zoom level

setZoomMode() public method

sets the zoom mode of the document
public setZoomMode ( integer $zoomMode )
$zoomMode integer zoom mode. Represented as class constants. Possible values:
ZOOM_MODE_NONE => 0 - None
ZOOM_MODE_FULL_PAGE => 1 - Full Page
ZOOM_MODE_BEST_FIT => 2 - Best Fit

unregisterAutoloader() public static method

unregisters autoloader for PHPRtfLite classes
public static unregisterAutoloader ( ) : boolean
return boolean

Property Details

$_borderSurroundsFooter protected_oe property

protected bool $_borderSurroundsFooter
return boolean

$_borderSurroundsHeader protected_oe property

protected bool $_borderSurroundsHeader
return boolean

$_colorTable protected_oe property

color table instance
protected PHPRtfLite_DocHead_ColorTable $_colorTable
return PHPRtfLite_DocHead_ColorTable

$_defaultFont protected_oe property

default font
protected PHPRtfLite_Font $_defaultFont
return PHPRtfLite_Font

$_fontTable protected_oe property

font table instance
protected PHPRtfLite_DocHead_FontTable $_fontTable
return PHPRtfLite_DocHead_FontTable

$_footers protected_oe property

rtf footers
protected PHPRtfLite_Container_Footer[] $_footers
return PHPRtfLite_Container_Footer[]

$_headers protected_oe property

rtf headers
protected PHPRtfLite_Container_Header[] $_headers
return PHPRtfLite_Container_Header[]

$_properties protected_oe property

rtf properties
protected array $_properties
return array

$_sections protected_oe property

rtf sections
protected PHPRtfLite_Container_Section[] $_sections
return PHPRtfLite_Container_Section[]