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'
Merge DOCX. Keep content and styles.
void
addDOCX
(string $pathDOCX)
-
string
$pathDOCX: Path to DOCX
Add an element to embedd in other elements
Element
addElement
(string $type, [ $params = ''], array $parrams)
-
string
$type: Element type. Values: 'addImage', 'addGraphic', 'addLink', 'addTextBox', 'addText'
-
array
$parrams: Set of parameters. Values: same as elements
-
$params
Add an endnote
void
addEndnote
([string $paramsEndnote = ''])
-
string
$paramsEndnote: Parameters of endnote. Optional, default empty. Values: 'font', 'textDocument', 'textEndNote'
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: 'name', 'pager' (true, false), 'pagerAlignment' (left, right, false)
Add a footnote
void
addFootnote
([array $paramsFootnote = ''])
-
array
$paramsFootnote: Parameters of footnote Values: 'font', 'textDocument', 'textEndNote'
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' (barChart, bar3DChart, colChart, col3DChart, pieChart, pie3DChart)
Add a graphic image
void
addGraphicImg
(array $dats)
-
array
$dats: Parameters of graphic Values: 'color' (1, 2, 3, 4, 5), 'cornerX' (20, 30...), 'data' (array of values), sizeX' (10, 11, 12...), 'sizeY' (10, 11, 12...), 'title', 'type' (barChart, bar3DChart, colChart, col3DChart, pieChart, pie3DChart)
Add a graphic template. Replace placeholder with a graphic
void
addGraphicTemplate
(array $dats)
-
array
$dats: Parameters of graphic Values: same as charts
Add a header.
void
addHeader
([string $text = 'Header'], [array $paramsHeader = ''])
-
string
$text: Text to add
-
array
$paramsHeader: Parameters of header 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 HTML to the document. Transform HTML to DOCX.
void
addHTML
([string $html = ''])
-
string
$html: HTML to add
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)), array 'bullets' (1 (), 2 (o), 3 ())
Add a macro from a DOC
void
addMacroFromDoc
(string $path)
-
string
$path: Path to a file with macro
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)
Convert a math MML eq to DOCX
void
addMathMML
(string $eq)
Add an existing object (XLS or PPTX)
void
addObject
(string $path, string $type)
-
string
$path: Object path
-
string
$type: Object type Values: xlsx, pptx
Add properties to document
void
addProperties
(array $values)
-
array
$values: Parameters to use Values: 'title', 'subject', 'creator', 'keywords', 'description', 'category', 'manager', 'custom' ('title', 'value')
Add a raw WordML
void
addRawWordML
(string $wml)
-
string
$wml: WordML to add
Add a RTF file. Keep content and styles.
void
addRTF
(string $pathRTF)
-
string
$pathRTF: Path to RTF
Add a section
void
addSection
([array $dats = ''])
-
array
$dats: Parameters to use Values: 'bottom' (4000, 4001...), 'columns' (1, 2, 3), 'left' (4000, 4001...), 'orient' (landscape), 'right' (4000, 4001), 'titlePage' (1), 'top' (4000, 4001)
Add a shape
void
addShape
(string $type, [array $style = ''])
-
string
$type: Type of shape to draw Values: line
-
array
$style: Style of text Values: 'width' (300, 400...), 'height' (300, 400...)
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 DOCX file as a template
void
addTemplate
(string $path)
-
string
$path: Path to the file
Replace a variable with a chart.
void
addTemplateChart
(string $var, string $chart)
-
string
$var: Value of the variable
-
string
$chart: Chart to add Values: same as charts.
Replace a variable with a checkbox.
void
addTemplateCheckBox
(string $var, [string $value = false])
-
string
$var: Value of the variable. String
-
string
$value
Replace a variable image template with a new image.
void
addTemplateImage
(string $var, string $pathImage)
-
string
$var: Value of the variable
-
string
$pathImage: Path of the new image
Replace a variable with a text, HTML, DOCX, RTF.
void
addTemplateVariable
(mixed $var, [string $value = ''], [array $settings = ''])
-
mixed
$var: Value of the variable. String or array of values
-
string
$value: Text value, type of value or text array Values type of template: list, table, html, rtf, docx
-
array
$settings: Template settings
Add a text
void
addText
(mixed $value, [array $style = ''])
-
mixed
$value: Text string or array of texts to add Values array: 'b' (single), 'cell_color' (ffffff, ff0000...), 'color' (ffffff, ff0000...), 'font' (Arial, Times New Roman...), 'i' (single), 'jc' (both, center, distribute, left, right), 'pageBreakBefore' (on, off), 'sz' (1, 2, 3...), 'text' 'u' (dash, dotted, double, single, wave, words), 'widowControl' (on, off), 'wordWrap' (on, off)
-
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), 'lineSpacing' 120, 240 (standard), 480...
Add a textbox
void
addTextBox
(mixed $text, [array $style = ''])
-
mixed
$text: Text string to add using params or not
-
array
$style: Style of text Values: 'align' (center, left, right), 'fillcolor' (black, red...), 'font' (Arial, Times New Roman...), 'height' (300, 400...), 'jc' (square, through), 'margin_bottom' (100, 110...), 'margin_left' (100, 110...), 'margin_right' (100, 110...), 'margin_top' (100, 110...)
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)
Clear all blocks
void
clearBlocks
()
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)
Generate and download a new DOCX file
void
createDocxAndDownload
(string $args[0], string $args[1])
-
string
$args[0]: Name of file
-
string
$args[1]: Page style Values: 'bottom' (4000, 4001...), 'left' (4000, 4001...), 'orient' (landscape), 'right' (4000, 4001), 'titlePage' (1), 'top' (4000, 4001)
Delete a block
void
deleteTemplateBlock
(string $blockName)
-
string
$blockName: Block to remove
Disable debug mode
void
disableDebug
()
Enable debug mode
void
enableDebug
()
Return template variables (placeholders)
array
getTemplateVariables
()
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
()
Merge WordML into a DOCX. WordML is added at the end of the document
void
mergeDOCX
(string $path, string $newXML)
-
string
$path: Path to DOCX file
-
string
$newXML: WordML to add
Read DOCX file and extract WordML content
Document.xml
readDOCX
(string $path)
-
string
$path: Path to DOCX file
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...
Mark the document as final
void
setMarkAsFinal
()
Set the symbol surrounding varibles (placeholders)
void
setTemplateSymbol
([string $symbol = '$'])
-
string
$symbol: The new symbol. Optional, $ as default
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
()