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. Declares if we want to change the default styles of phpdocx 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
Construct
CreateDocx
__construct
([string $extension = 'docx'])
-
string
$extension: File extension. Optional, docx as default
Destruct
void
__destruct
()
Add a break
void
addBreak
([string $type = ''])
-
string
$type: Break type Values: 'line', 'page'
Add a new font
void
addFont
(array $fonts)
-
array
$fonts: Fonts to add
Add a footer
void
addFooter
([string $dat = ''], [array $paramsFooter = ''])
-
string
$dat: Text to add
-
array
$paramsFooter: Parameters of footer Values: 'pager' (true, false), 'pagerAlignment' (left, right, false)
Add a graphic
void
addGraphic
(array $dats)
-
array
$dats: Parameters of graphic Values: 'color' (1, 2, 3...), 'cornerP' (20, 30...), 'cornerX' (20, 30...), 'cornerY' (20, 30...), 'data' (array of values), 'font' (Arial, Times New Roman...), 'groupBar' (clustered, stacked), '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), 5 (clear)), 'title', 'type' (pieChart, barChart, colChart)
Add a header.
void
addHeader
([string $text = 'Header'], [array $paramsHeader = ''])
-
string
$text: Text to add
-
array
$paramsHeader: Parameters of header
Add an image
void
addImage
([array $dats = ''])
-
array
$dats: Image to add and paramaters to use Values: 'border'(1, 2, 3...), 'borderDiscontinuous' (0, 1), 'font' (Arial, Times New Roman...), 'jc' (center, left, right), 'name', 'scaling' (50, 100), 'sizeX' (10, 11, 12...), 'sizeY' (10, 11, 12...), spacingTop (10, 11...), spacingBottom (10, 11...), spacingLeft (10, 11...), spacingRight (10, 11...), 'textWrap' (0 (inline), 1 (square), 2 (front), 3 (back), 4 (up and bottom), 5 (clear))
Add a link
void
addLink
([string $text = ''], [ $textLink = ''], [string $font = ''], string $link)
-
string
$text: Text to use as link
-
string
$link: URL link
-
string
$font: Type of font Values: 'Arial', 'Times New Roman'...
-
$textLink
Add a list
void
addList
(array $dats, [array $paramsList = ''])
-
array
$dats: Values of the list
-
array
$paramsList: Parameters to use Values: 'font' (Arial, Times New Roman...), 'val' (0 (clear, 1 (inordinate), 2(numerical))
Convert a math eq to DOCX
void
addMathDocx
(string $path)
-
string
$path: Path to a file with math eq
Add an existing math eq to DOCX
void
addMathEq
(string $eq)
Add a paragraph
void
addParagraph
(string $text, [string $style = ''], [string $align = ''])
-
string
$text: Text to add
-
string
$style: Style of the paragraph
-
string
$align: Align of the paragraph
Add a table.
void
addTable
(array $dats, [array $parameters = ''])
-
array
$dats: Values to add
-
array
$parameters: Parameters to use Values: 'border' (none, single, double), 'border_color' (ffffff, ff0000), 'border_spacing' (0, 1, 2...), 'border_sz' (10, 11...), 'font' (Arial, Times New Roman...), 'jc' (center, left, right), 'size_col' (1200, 1300...), 'TBLSTYLEval' (Cuadrculamedia3-nfasis1, Sombreadomedio1, Tablaconcuadrcula, TableGrid)
Add a table of contents (TOC)
void
addTableContents
([string $font = ''])
-
string
$font: Set font type Values: 'Arial', 'Times New Roman'...
Add a text
void
addText
(mixed $value, [array $style = ''])
-
mixed
$value: Text or array of texts to add
-
array
$style: Style of text Values: 'b' (single), 'color' (ffffff, ff0000...), 'font' (Arial, Times New Roman...), 'i' (single), 'jc' (both, center, distribute, left, right), 'pageBreakBefore' (on, off), 'sz' (1, 2, 3...), 'u' (dash, dotted, double, single, wave, words), 'widowControl' (on, off), 'wordWrap' (on, off)
Add a title
void
addTitle
(string $text, [array $style = ''])
-
string
$text: Text to add
-
array
$style: Style of title Values: 'b' (single), 'color' (ffffff, ff0000...), 'font' (Arial, Times New Roman...), 'i' (single), 'jc' (both, center, distribute, left, right), 'pageBreakBefore' (on, off), 'sz' (1, 2, 3...), 'u' (dash, dotted, double, single, wave, words), 'widowControl' (on, off), 'wordWrap' (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...), 'left' (4000, 4001...), 'orient' (landscape), 'right' (4000, 4001), 'titlePage' (1), 'top' (4000, 4001)
Add a break
void
fAddBreak
([string $type = ''])
Add a new font
void
fAddFont
(array $fonts)
-
array
$fonts: Fonts to add
Add a footer
void
fAddFooter
([string $dat = ''], [array $paramsFooter = ''])
-
string
$dat: Text to add
-
array
$paramsFooter: Parameters of footer
Add a graphic
void
fAddGraphic
(array $dats)
-
array
$dats: Parameters of graphic
Add a header.
void
fAddHeader
([string $text = 'Header'], [array $paramsHeader = ''])
-
string
$text: Text to add
-
array
$paramsHeader: Parameters of header
Add an image
void
fAddImage
([array $dats = ''])
-
array
$dats: Image to add and paramaters to use
Add a link
void
fAddLink
([string $text = ''], [ $textLink = ''], [string $font = ''], string $link)
-
string
$text: Text to use as link
-
string
$link: URL link
-
string
$font: Type of font
-
$textLink
Add a list
void
fAddList
(array $dats, [array $paramsList = ''])
-
array
$dats: Values of the list
-
array
$paramsList: Parameters to use
Convert a math eq to DOCX
void
fAddMathDocx
(string $path)
-
string
$path: Path to a file with math eq
Add an existing math eq to DOCX
void
fAddMathEq
(string $eq)
Add a paragraph
void
fAddParagraph
(string $text, [string $style = ''], [string $align = ''])
-
string
$text: Text to add
-
string
$style: Style of the paragraph
-
string
$align: Align of the paragraph
Add a table.
void
fAddTable
(array $dats, [array $parameters = ''])
-
array
$dats: Values to add
-
array
$parameters: Parameters to use
Add a table of contents (TOC)
void
fAddTableContents
([string $font = ''])
-
string
$font: Set font type
Add a text
void
fAddText
(mixed $value, [array $style = ''])
-
mixed
$value: Text or array of texts to add
-
array
$style: Style of text
Add a title
void
fAddTitle
(string $text, [array $style = ''])
-
string
$text: Text to add
-
array
$style: Style of title
Generate a new DOCX file
void
fCreateDocx
(string $args[0])
-
string
$args[0]: File name
Change the default font
void
fSetDefaultFont
(string $font)
-
string
$font: The new font
Getter
void
getXmlContentTypes
()
Getter
void
getXmlDocPropsApp
()
Getter
void
getXmlDocPropsCore
()
Getter
void
getXmlRels_Rels
()
Getter
void
getXmlWordDocumentContent
()
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
getXmlWordWebSettings
()
Change the default font
void
setDefaultFont
(string $font)
-
string
$font: The new font Values: 'Arial', 'Times New Roman'...
Transform to UTF-8 charset
void
setEncodeUTF8
()
Change default language.
void
setLanguage
([$lang $lang = 'en-US'])
-
$lang
$lang: Locale: en-US, es-ES...
Setter
void
setXmlContentTypes
( $xmlContentTypes)
Setter
void
setXmlDocPropsApp
( $xmlDocPropsApp)
Setter
void
setXmlDocPropsCore
( $xmlDocPropsCore)
Setter
void
setXmlRelsRels
( $xmlRelsRels)
Setter
void
setXmlWordDocument
( $xmlWordDocument)
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
()