PHP Class PHPRtfLite

Author: Denis Slaveckij ([email protected])
Author: Steffen Zeidler ([email protected])
Afficher le fichier Open project: phprtflite/phprtflite Class Usage Examples

Protected Properties

Свойство 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

Méthodes publiques

Méthode 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

Méthodes protégées

Méthode Description
getInfoPart ( ) : string gets rtf info part
render ( ) prepares rtf contents

Private Methods

Méthode Description
createWriter ( string $file = null ) creates writer

Method Details

__construct() public méthode

public __construct ( )

addFooter() public méthode

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
Résultat PHPRtfLite_Container_Footer

addHeader() public méthode

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
Résultat PHPRtfLite_Container_Header

addSection() public méthode

adds section to rtf document
public addSection ( PHPRtfLite_Container_Section $section = null ) : PHPRtfLite_Container_Section
$section PHPRtfLite_Container_Section
Résultat PHPRtfLite_Container_Section

borderSurroundsFooter() public méthode

checks, if border surrounds footer
public borderSurroundsFooter ( ) : boolean
Résultat boolean

borderSurroundsHeader() public méthode

checks, if border surrounds header
public borderSurroundsHeader ( ) : boolean
Résultat boolean

convertNewlinesToRtfCode() public static méthode

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

free() public méthode

public free ( )

getBorder() public méthode

gets border of document
public getBorder ( ) : PHPRtfLite_Border
Résultat PHPRtfLite_Border

getCharset() public méthode

gets charset for rtf text inputs
public getCharset ( ) : string
Résultat string

getColorTable() public méthode

gets color table
public getColorTable ( ) : PHPRtfLite_DocHead_ColorTable
Résultat PHPRtfLite_DocHead_ColorTable

getContent() public méthode

gets rtf document code
public getContent ( boolean $free = true ) : string
$free boolean
Résultat string

getDefaultFont() public méthode

gets default font
public getDefaultFont ( ) : PHPRtfLite_Font
Résultat PHPRtfLite_Font

getDefaultFontForNotes() public méthode

gets default font for notes
public getDefaultFontForNotes ( ) : PHPRtfLite_Font
Résultat PHPRtfLite_Font

getDefaultTabWidth() public méthode

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

getEndnoteNumberingType() public méthode

gets endnote numbering type
public getEndnoteNumberingType ( ) : integer
Résultat integer

getEndnoteStartNumber() public méthode

gets endnote start number
public getEndnoteStartNumber ( ) : integer
Résultat integer

getFontTable() public méthode

gets font table
public getFontTable ( ) : PHPRtfLite_DocHead_FontTable
Résultat PHPRtfLite_DocHead_FontTable

getFooters() public méthode

gets defined footers for document pages
public getFooters ( ) : array
Résultat array contains PHPRtfLite_Container_FOOTER objects

getFootnoteNumberingType() public méthode

gets footnote numbering type
public getFootnoteNumberingType ( ) : integer
Résultat integer

getFootnoteStartNumber() public méthode

gets footnote start number
public getFootnoteStartNumber ( ) : integer
Résultat integer

getGutter() public méthode

gets the gutter width
public getGutter ( ) : float
Résultat float $gutter gutter width

getHeaders() public méthode

gets defined headers for document pages
public getHeaders ( ) : array
Résultat array contains PHPRtfLite_Container_Header objects

getInfoPart() protected méthode

gets rtf info part
protected getInfoPart ( ) : string
Résultat string

getMarginBottom() public méthode

gets the bottom margin of document pages
public getMarginBottom ( ) : float
Résultat float $margin

getMarginLeft() public méthode

gets the left margin of document pages
public getMarginLeft ( ) : float
Résultat float $margin

getMarginRight() public méthode

gets the right margin of document pages
public getMarginRight ( ) : float
Résultat float $margin

getMarginTop() public méthode

gets the top margin of document pages
public getMarginTop ( ) : float
Résultat float $margin

getNoteDocHead() public méthode

gets document head definition for notes
public getNoteDocHead ( ) : PHPRtfLite_DocHead_Note
Résultat PHPRtfLite_DocHead_Note

getPageNumberStart() public méthode

gets the beginning page number
public getPageNumberStart ( ) : integer
Résultat integer

getPaperHeight() public méthode

gets the paper height of document
public getPaperHeight ( ) : float
Résultat float $paperHeight paper height

getPaperWidth() public méthode

gets the paper width of document
public getPaperWidth ( ) : float
Résultat float $paperWidth paper width

getProperty() public méthode

gets rtf property
public getProperty ( string $name ) : string
$name string
Résultat string

getSections() public méthode

gets sections
public getSections ( ) : array
Résultat array

getViewMode() public méthode

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

getWriter() public méthode

gets writer
public getWriter ( ) : PHPRtfLite_Writer_Interface
Résultat PHPRtfLite_Writer_Interface

getZoomLevel() public méthode

gets the zoom level (in percents) of the document
public getZoomLevel ( ) : integer
Résultat integer $zoom zoom level

getZoomMode() public méthode

gets the zoom mode of the document
public getZoomMode ( ) : integer
Résultat integer

hasSpecialLayoutForFirstPage() public méthode

returns true, if first page has special layout

isLandscape() public méthode

returns true, if landscape layout should be used
public isLandscape ( ) : boolean
Résultat boolean

isMirrorMargins() public méthode

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

isOddEvenDifferent() public méthode

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

isRestartEndnoteNumberEachPage() public méthode

checks, if endnote numbering shall be started on each page

isRestartFootnoteNumberEachPage() public méthode

sets restart endnote number on each page

quoteRtfCode() public static méthode

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

registerAutoloader() public static méthode

registers autoloader for PHPRtfLite classes
public static registerAutoloader ( ) : boolean
Résultat boolean

registerFont() public méthode

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

registerParFormat() public méthode

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

render() protected méthode

prepares rtf contents
protected render ( )

save() public méthode

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

sendRtf() public méthode

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

setBorder() public méthode

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

setBorderSurroundsFooter() public méthode

public setBorderSurroundsFooter ( boolean $borderSurroundsFooter = true ) : PHPRtfLite
$borderSurroundsFooter boolean
Résultat PHPRtfLite

setBorderSurroundsHeader() public méthode

sets border surrounds header
public setBorderSurroundsHeader ( boolean $borderSurroundsHeader = true ) : PHPRtfLite
$borderSurroundsHeader boolean
Résultat PHPRtfLite

setBorders() public méthode

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 méthode

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

setDefaultFont() public méthode

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

setDefaultFontForNotes() public méthode

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

setDefaultTabWidth() public méthode

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

setEndnoteNumberingType() public méthode

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

setEndnoteStartNumber() public méthode

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

setFootnoteNumberingType() public méthode

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

setFootnoteStartNumber() public méthode

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

setGutter() public méthode

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

setHyphenation() public méthode

sets using hyphenation
public setHyphenation ( )

setLandscape() public méthode

sets landscape orientation for the document
public setLandscape ( )

setMarginBottom() public méthode

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

setMarginLeft() public méthode

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

setMarginRight() public méthode

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

setMarginTop() public méthode

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

setMargins() public méthode

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 méthode

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

setOddEvenDifferent() public méthode

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

setPageNumberStart() public méthode

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

setPaperFormat() public méthode

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

setPaperHeight() public méthode

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

setPaperWidth() public méthode

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

setProperty() public méthode

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 méthode

checks, if footnote numbering shall be started on each page

setRestartFootnoteNumberEachPage() public méthode

sets restart footnote number on each page

setSpecialLayoutForFirstPage() public méthode

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

setUseTemporaryFile() public méthode

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 méthode

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 méthode

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

setZoomLevel() public méthode

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 méthode

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 méthode

unregisters autoloader for PHPRtfLite classes
public static unregisterAutoloader ( ) : boolean
Résultat boolean

Property Details

$_borderSurroundsFooter protected_oe property

protected bool $_borderSurroundsFooter
Résultat boolean

$_borderSurroundsHeader protected_oe property

protected bool $_borderSurroundsHeader
Résultat boolean

$_colorTable protected_oe property

color table instance
protected PHPRtfLite_DocHead_ColorTable $_colorTable
Résultat PHPRtfLite_DocHead_ColorTable

$_defaultFont protected_oe property

default font
protected PHPRtfLite_Font $_defaultFont
Résultat PHPRtfLite_Font

$_fontTable protected_oe property

font table instance
protected PHPRtfLite_DocHead_FontTable $_fontTable
Résultat PHPRtfLite_DocHead_FontTable

$_footers protected_oe property

rtf footers
protected PHPRtfLite_Container_Footer[] $_footers
Résultat PHPRtfLite_Container_Footer[]

$_headers protected_oe property

rtf headers
protected PHPRtfLite_Container_Header[] $_headers
Résultat PHPRtfLite_Container_Header[]

$_properties protected_oe property

rtf properties
protected array $_properties
Résultat array

$_sections protected_oe property

rtf sections
protected PHPRtfLite_Container_Section[] $_sections
Résultat PHPRtfLite_Container_Section[]