Transform a word document to a text file
static
void
docx2txt
( $from, array $to, [ $options = array()], string $path.)
-
string
$path.: Path to the text file output
-
array
$to: styles. keys: table => true/false,list => true/false, paragraph => true/false, footnote => true/false, endnote => true/false, chart => (0=false,1=array,2=table)
-
$from
-
$options
To add support of sys_get_temp_dir for PHP versions under 5.2.1
static
string
getTempDir
()
Construct
CreateDocx
__construct
([ $baseTemplatePath = PHPDOCX_BASE_TEMPLATE], string $baseTemplatePath.)
-
string
$baseTemplatePath.: Optional, basicTemplate.docx as default
-
$baseTemplatePath
Destruct
void
__destruct
()
Add a break
void
addBreak
([string $options = array('type' => 'line')])
-
string
$options: Values: 'type' (line, page, column)
Add a chart
void
addChart
([array $options = array()])
-
array
$options: Values: 'color' (1, 2, 3...) color scheme, 'perspective' (20, 30...), 'rotX' (20, 30...), 'rotY' (20, 30...), 'data' (array of values), 'float' (left, right, center) floating image. It only applies if textWrap is not inline (default value). 'font' (Arial, Times New Roman...), 'groupBar' (clustered, stacked, percentStacked), 'horizontalOffset' (int) given in emus (1cm = 360000 emus) 'jc' (center, left, right), 'showPercent' (0, 1), 'sizeX' (10, 11, 12...), 'sizeY' (10, 11, 12...), 'textWrap' (0 (inline), 1 (square), 2 (front), 3 (back), 4 (up and bottom)), 'verticalOffset' (int) given in emus (1cm = 360000 emus) 'title', 'type' (barChart, pieChart) 'legendPos' (r, l, t, b, none), 'legendOverlay' (0, 1), 'border' (0, 1), 'haxLabel' horizontal axis label, 'vaxLabel' vertical axis label, 'showtable' (0, 1) shows the table of values, 'vaxLabelDisplay' (rotated, vertical, horizontal), 'haxLabelDisplay' (rotated, vertical, horizontal), 'hgrid' (0, 1, 2, 3), 'vgrid' (0, 1, 2, 3), 'style' this work only in radar charts. 'gapWidth' distance between the pie and the second chart(ofpiechart) 'secondPieSize' : size of the second chart(ofpiechart) 'splitType' how decide to split the values :auto(Default Split), cust(Custom Split), percent(Split by Percentage), pos(Split by Position), val(Split by Value) 'splitPos' split position , integer or float 'custSplit' array of index to split 'subtype' type of the second chart pie or bar 'explosion' distance between the diferents values 'holeSize' size of the hole in doughnut type 'symbol' array of symbols(scatter chart) 'symbolSize' the size of the simbols 'smooth' smooth the line (scatter chart) 'wireframe' boolean(surface chart)to remove content color and only leave the border colors 'showValue' (0,1) shows the values inside the chart 'showCategory' (0,1) shows the category inside the chart
Add an image
void
addImage
([array $data = ''])
-
array
$data: Values: 'border'(int) 1, 2, 3... 'borderDiscontinuous' (0, 1) 'float' (left, right, center) floating image. It only applies if textWrap is not inline (default value). 'font' (string) Arial, Times New Roman... 'horizontalOffset' (int) given in emus (1cm = 360000 emus). Only applies if there is the image is not floating 'jc' (center, left, right, inside, outside) 'name' (string) path to a local image 'scaling' (int) 50, 100, .. 'sizeX' (int) 10, 11, 12... 'sizeY' (int) 10, 11, 12... 'dpi' (int) dots per inch 'spacingTop' (int) 10, 11... 'spacingBottom' (int) 10, 11... 'spacingLeft' (int) 10, 11... 'spacingRight' (int) 10, 11... 'textWrap' 0 (inline), 1 (square), 2 (front), 3 (back), 4 (up and bottom)) 'target' (string): document (default value), defaultHeader, firstHeader, evenHeader, defaultFooter, firstFooter, evenFooter 'verticalOffset' (int) given in emus (1cm = 360000 emus)
Add a link
void
addLink
( $text, [array $options = array('url' => '',
'font' => '',
'sz' => '',
'color' => '0000ff',
'u' => 'single',
)])
Add a list
void
addList
(array $data, [array $options = array()])
-
array
$data: Values of the list
-
array
$options: Values: 'font' (string), Arial, Times New Roman, ... 'val' (int), 0 (clear), 1 (inordinate), 2(numerical) 'bullets' (array) 1 (), 2 (o), 3 ()
Add a raw WordML
void
addRawWordML
(string $wml)
-
string
$wml: WordML to add
Add a table.
void
addTable
(array $tableData, [array $tableProperties = array()], [array $rowProperties = array()])
-
array
$tableData: an array of arrays with the table data organized by rows Each cell content may be a string or array. If the cell contents are in the form of an array its keys and posible values are: 'value' (string) 'rowspan' (int) 'colspan' (int) 'width' (int) in twentieths of a point 'border' (none, single, double, dashed, threeDEngrave, threeDEmboss, outset, inset) 'border_color' (ffffff, ff0000) 'border_spacing' (0, 1, 2...) 'border_sz' (10, 11...) in eights of a point 'border_<side>' (none, single, double, dashed, threeDEngrave, threeDEmboss, outset, inset) where the side may be: top, left, right or bottom 'border_<side>_color' (ffffff, ff0000) 'border_<side>_spacing' (0, 1, 2...) 'border_<side>_sz' (10, 11...) 'background_color' (ffffff, ff0000) 'noWrap' (boolean) 'cellMargin' (mixed) an integer value or an array: 'top' (int) in twentieths of a point 'right' (int) in twentieths of a point 'bottom' (int) in twentieths of a point 'left' (int) in twentieths of a point 'textDirection' (string) available values are: tbRl and btLr 'fitText' (boolean) if true fits the text to the size of the cell 'vAlign' (string) vertical align of text: top, center, both or bottom
-
array
$tableProperties: Parameters to use Values: 'border' (none, single, double, dashed, threeDEngrave, threeDEmboss, outset, inset) 'border_color' (ffffff, ff0000) 'border_spacing' (0, 1, 2...) 'border_sz' (10, 11...) in eights of a point 'border_settings' (all, outside, inside) if all (default value) the border styles apply to all table borders. If the value is set to outside or inside the border styles will only apply to the outside or inside boreders respectively. 'cantSplitRows' (boolean) set global row split properties (can be overriden by rowProperties) 'cellMargin' (array) the keys are top, right, bottom and left and the values is given in twips (twentieths of a point) 'cellSpacing' (int) given in twips (twentieths of a point) 'float' (array) with the following keys and values: 'textMargin_top' (int) in twentieths of a point 'textMargin_right' (int) in twentieths of a point 'textMargin_bottom' (int) in twentieths of a point 'textMargin_left' (int) in twentieths of a point 'align' (string) posible values are: left, center, right, outside, inside 'font' (Arial, Times New Roman...) 'indent' (int) given in twips (twentieths of a point) 'jc' (center, left, right) 'decimalTab' 'size_col': column width fix (int) column width variable (array) 'tableWidth' (array) its posible keys and values are: 'type' (pct, dxa) pct if the value refers to percentage and dxa if the value is given in twentieths of a point (twips) 'value' (int) 'TBLSTYLEval' (string) Word table style
-
array
$rowProperties: (array) a cero based array. Each entry is an array with keys and values: 'cantSplit' (boolean) 'minHeight' (int) in twentieths of a point 'height' (int) in twentieths of a point 'tblHeader' (boolean) if true this row repeats at the beguinning of each new page
Add a text
void
addText
(mixed $textParams, [array $paragraphParams = array()])
-
mixed
$textParams: if a string just the text to be included, if an array is or an array of arrays with each element containing the text to be inserted and their formatting properties Array values: 'text' (string) the run of text to be inserted 'b' (on, off) 'caps' (on, off) display text in capital letters 'color' (ffffff, ff0000...) 'columnBreak' (before, after, both) inserts a column break before, after or both, a run of text 'font' (Arial, Times New Roman...) 'i' (on, off) 'lineBreak' (before, after, both) inserts a line break before, after or both, a run of text 'sz' (1, 2, 3...) 'tab' (boolean) inserts a tab. Default value is false 'spaces': number of spaces at the beguinning of the run of text 'u' (none, dash, dotted, double, single, wave, words)
-
array
$paragraphParams: Style options to apply to the whole paragraph Values: 'pStyle' (string) Word style to be used. Run parseStyles() to check all available paragraph styles 'b' (on, off) 'caps' (on, off) display text in capital letters 'color' (ffffff, ff0000...) 'contextualSpacing' (on, off) ignore spacing above and below when using identical styles 'font' (Arial, Times New Roman...) 'i' (on, off) 'indent_left' 100..., 'indent_right' 100... 'jc' (both, center, distribute, left, right) 'keepLines' (on, off) keep all paragraph lines on the same page 'keepNext' (on, off) keep in the same page the current paragraph with next paragraph 'lineSpacing' 120, 240 (standard), 360, 480, ... 'pageBreakBefore' (on, off) 'spacingBottom' (int) bottom margin in twentieths of a point 'spacingTop' (int) top margin in twentieths of a point 'sz' (8, 9, 10, ...) size in points 'tabPositions' (array) each entry is an associative array with the following keys and values 'type' (string) can be clear, left (default), center, right, decimal, bar and num 'leader' (string) can be none (default), dot, hyphen, underscore, heavy and middleDot 'position' (int) given in twentieths of a point if there is a tab and the tabPositions array is not defined the standard tab position (default of 708) will be used 'textDirection' (lrTb, tbRl, btLr, lrTbV, tbRlV, tbLrV) text flow direction 'u' (none, dash, dotted, double, single, wave, words) 'widowControl' (on, off)
Generate a new DOCX file
void
createDocx
(string $args[0], string $args[1])
-
string
$args[0]: File name
-
string
$args[1]: Page style Values: 'bottom' (4000, 4001...), 'columns' (1, 2, 3), 'left' (4000, 4001...), 'orient' (landscape), 'right' (4000, 4001), 'titlePage' (1), 'top' (4000, 4001)
Getter
void
getExtension
()
Getter
void
getTemporaryDirectory
()
Getter
void
getXmlContentTypes
()
Getter
void
getXmlDocPropsApp
()
Getter
void
getXmlDocPropsCore
()
Getter
void
getXmlDocPropsCustom
()
Getter
void
getXmlRelsRels
()
Getter
void
getXmlWordDocumentContent
()
Getter
void
getXmlWordDocumentStyles
()
Getter
void
getXmlWordEndnotes
()
Getter
void
getXmlWordFontTable
()
Getter
void
getXmlWordFooter1
()
Getter
void
getXmlWordHeader1
()
Getter
void
getXmlWordRelsDocumentRels
()
Getter
void
getXmlWordSettings
()
Getter
void
getXmlWordStyles
()
Getter
void
getXmlWordThemeTheme1
()
Setter
void
getXml_Word_WebSettings
()
Transform to UTF-8 charset
void
setEncodeUTF8
()
Setter
void
setExtension
( $extension)
Change default language.
void
setLanguage
([$lang $lang = null])
-
$lang
$lang: Locale: en-US, es-ES...
Setter
void
setTemporaryDirectory
( $tempDir)
Setter
void
setXmlContentTypes
( $xmlContentTypes)
Setter
void
setXmlDocPropsApp
( $xmlDocPropsApp)
Setter
void
setXmlDocPropsCore
( $xmlDocPropsCore)
Setter
void
setXmlDocPropsCustom
( $xmlDocPropsCustom)
Setter
void
setXmlRelsRels
( $xmlRelsRels)
Setter
void
setXmlWordDocument
( $xmlWordDocument)
Setter
void
setXmlWordDocumentStyles
( $xmlWordDocumentStyles)
Setter
void
setXmlWordEndnotes
( $xmlWordEndnotes)
Setter
void
setXmlWordFontTable
( $xmlWordFontTable)
Setter
void
setXmlWordFooter1
( $xmlWordFooter)
Setter
void
setXmlWordHeader1
( $xmlWordHeader)
Setter
void
setXmlWordRelsDocumentRels
( $xmlWordRelsDocumentRels)
Setter
void
setXmlWordSettings
( $xmlWordSettings)
Setter
void
setXmlWordStyles
( $xmlWordStyles)
Setter
void
setXmlWordThemeTheme1
( $xmlWordThemeTheme)
Setter
void
setXmlWordWebSettings
( $xmlWordWebSettings)
Magic method, returns current word XML
string
__toString
()