Class CreateDocx

Description

Main class. Methods and vars to generate a DOCX file

Located in /CreateDocx.inc (line 33)

CreateDocument
   |
   --CreateDocx
Class Constant Summary
 SCHEMA_IMAGEDOCUMENT = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image'
 SCHEMA_OFFICEDOCUMENT = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument'
Variable Summary
static int $intIdWord
static Logger $log
Method Summary
CreateDocx __construct ([string $extension = 'docx'])
void __destruct ()
void addBreak ([string $type = ''])
void addDOCX (string $pathDOCX)
Element addElement (string $type, [ $params = ''], array $parrams)
void addEndnote ([string $paramsEndnote = ''])
void addFont (array $fonts)
void addFooter ([string $dat = ''], [array $paramsFooter = ''])
void addFootnote ([array $paramsFootnote = ''])
void addGraphic (array $dats)
void addGraphicImg (array $dats)
void addGraphicTemplate (array $dats)
void addHeader ([string $text = 'Header'], [array $paramsHeader = ''])
void addHTML ([string $html = ''])
void addImage ([array $dats = ''])
void addLink ([string $text = ''], [ $textLink = ''], [string $font = ''], string $link)
void addList (array $dats, [array $paramsList = ''])
void addMacroFromDoc (string $path)
void addMathDocx (string $path)
void addMathEq (string $eq)
void addMathMML (string $eq)
void addObject (string $path, string $type)
void addProperties (array $values)
void addRawWordML (string $wml)
void addRTF (string $pathRTF)
void addSection ([array $dats = ''])
void addShape (string $type, [array $style = ''])
void addTable (array $dats, [array $parameters = ''])
void addTableContents ([string $font = ''])
void addTemplate (string $path)
void addTemplateChart (string $var, string $chart)
void addTemplateCheckBox (string $var, [string $value = false])
void addTemplateImage (string $var, string $pathImage)
void addTemplateVariable (mixed $var, [string $value = ''], [array $settings = ''])
void addText (mixed $value, [array $style = ''])
void addTextBox (mixed $text, [array $style = ''])
void addTitle (string $text, [array $style = ''])
void clearBlocks ()
void createDocx (string $args[0], string $args[1])
void createDocxAndDownload (string $args[0], string $args[1])
void deleteTemplateBlock (string $blockName)
void disableDebug ()
void enableDebug ()
void getXmlRelsRels ()
void mergeDOCX (string $path, string $newXML)
Document.xml readDOCX (string $path)
void setDefaultFont (string $font)
void setEncodeUTF8 ()
void setLanguage ([$lang $lang = 'en-US'])
void setMarkAsFinal ()
void setTemplateSymbol ([string $symbol = '$'])
void setTemporaryDirectory ( $tempDir)
void setXmlContentTypes ( $xmlContentTypes)
void setXmlDocPropsApp ( $xmlDocPropsApp)
void setXmlDocPropsCore ( $xmlDocPropsCore)
void setXmlDocPropsCustom ( $xmlDocPropsCustom)
void setXmlRelsRels ( $xmlRelsRels)
void setXmlWordDocument ( $xmlWordDocument)
void setXmlWordDocumentStyles ( $xmlWordDocumentStyles)
void setXmlWordEndnotes ( $xmlWordEndnotes)
void setXmlWordFontTable ( $xmlWordFontTable)
void setXmlWordFooter1 ( $xmlWordFooter)
void setXmlWordHeader1 ( $xmlWordHeader)
void setXmlWordRelsDocumentRels ( $xmlWordRelsDocumentRels)
void setXmlWordSettings ( $xmlWordSettings)
void setXmlWordStyles ( $xmlWordStyles)
void setXmlWordThemeTheme1 ( $xmlWordThemeTheme)
void setXmlWordWebSettings ( $xmlWordWebSettings)
string __toString ()
Variables
static int $intIdWord (line 59)
  • access: public
static Logger $log (line 66)
  • access: public
array $fileGraphicTemplate (line 46)
  • access: public
string $graphicTemplate (line 52)
  • access: public
Methods
Constructor __construct (line 389)

Construct

  • access: public
CreateDocx __construct ([string $extension = 'docx'])
  • string $extension: File extension. Optional, docx as default
Destructor __destruct (line 467)

Destruct

  • access: public
void __destruct ()
addBreak (line 837)

Add a break

void addBreak ([string $type = ''])
  • string $type: Break type. Values: 'line', 'page'
addDOCX (line 853)

Merge DOCX. Keep content and styles.

  • access: public
  • example: example not found
  • example: example
void addDOCX (string $pathDOCX)
  • string $pathDOCX: Path to DOCX
addElement (line 888)

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
addEndnote (line 1035)

Add an endnote

void addEndnote ([string $paramsEndnote = ''])
  • string $paramsEndnote: Parameters of endnote. Optional, default empty. Values: 'font', 'textDocument', 'textEndNote'
addFont (line 1056)

Add a new font

  • access: public
void addFont (array $fonts)
  • array $fonts: Fonts to add
addFooter (line 1077)

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)
addFootnote (line 1107)

Add a footnote

void addFootnote ([array $paramsFootnote = ''])
  • array $paramsFootnote: Parameters of footnote Values: 'font', 'textDocument', 'textEndNote'
addGraphic (line 1141)

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)
addGraphicImg (line 1219)

Add a graphic image

  • access: public
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)
addGraphicTemplate (line 1252)

Add a graphic template. Replace placeholder with a graphic

  • access: public
void addGraphicTemplate (array $dats)
  • array $dats: Parameters of graphic Values: same as charts
addHeader (line 1329)

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))
addHTML (line 1357)

Add HTML to the document. Transform HTML to DOCX.

void addHTML ([string $html = ''])
  • string $html: HTML to add
addImage (line 1385)

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))
addLink (line 1456)

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
addList (line 1480)

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 ())
addMacroFromDoc (line 1507)

Add a macro from a DOC

  • access: public
void addMacroFromDoc (string $path)
  • string $path: Path to a file with macro
addMathDocx (line 1553)

Convert a math eq to DOCX

void addMathDocx (string $path)
  • string $path: Path to a file with math eq
addMathEq (line 1572)

Add an existing math eq to DOCX

void addMathEq (string $eq)
  • string $eq: Math eq
addMathMML (line 1585)

Convert a math MML eq to DOCX

  • access: public
void addMathMML (string $eq)
  • string $eq: Math eq
addObject (line 1603)

Add an existing object (XLS or PPTX)

  • access: public
  • example: example not found
void addObject (string $path, string $type)
  • string $path: Object path
  • string $type: Object type Values: xlsx, pptx
addProperties (line 1661)

Add properties to document

void addProperties (array $values)
  • array $values: Parameters to use Values: 'title', 'subject', 'creator', 'keywords', 'description', 'category', 'manager', 'custom' ('title', 'value')
addRawWordML (line 1685)

Add a raw WordML

  • access: public
void addRawWordML (string $wml)
  • string $wml: WordML to add
addRTF (line 1699)

Add a RTF file. Keep content and styles.

  • access: public
  • example: example not found
  • example: example
void addRTF (string $pathRTF)
  • string $pathRTF: Path to RTF
addSection (line 1732)

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)
addShape (line 1750)

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...)
addTable (line 1775)

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)
addTableContents (line 1791)

Add a table of contents (TOC)

void addTableContents ([string $font = ''])
  • string $font: Set font type Values: 'Arial', 'Times New Roman'...
addTemplate (line 1806)

Add a DOCX file as a template

void addTemplate (string $path)
  • string $path: Path to the file
addTemplateChart (line 1832)

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.
addTemplateCheckBox (line 1848)

Replace a variable with a checkbox.

  • access: public
void addTemplateCheckBox (string $var, [string $value = false])
  • string $var: Value of the variable. String
  • string $value
addTemplateImage (line 1865)

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
addTemplateVariable (line 1885)

Replace a variable with a text, HTML, DOCX, RTF.

  • access: public
  • example: example not found
  • example: example
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
addText (line 1922)

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...
addTextBox (line 1943)

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...)
addTitle (line 1967)

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)
clearBlocks (line 2439)

Clear all blocks

  • access: public
void clearBlocks ()
createDocx (line 1987)

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)
createDocxAndDownload (line 2401)

Generate and download a new DOCX file

  • access: public
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)
deleteTemplateBlock (line 2451)

Delete a block

  • access: public
void deleteTemplateBlock (string $blockName)
  • string $blockName: Block to remove
disableDebug (line 2463)

Disable debug mode

  • deprecated:
  • access: public
void disableDebug ()
enableDebug (line 2475)

Enable debug mode

  • deprecated:
  • access: public
void enableDebug ()
getTemplateVariables (line 2582)

Return template variables (placeholders)

  • access: public
array getTemplateVariables ()
getTemporaryDirectory (line 500)

Getter

  • access: public
void getTemporaryDirectory ()
getXmlContentTypes (line 520)

Getter

  • access: public
void getXmlContentTypes ()
getXmlDocPropsApp (line 560)

Getter

  • access: public
void getXmlDocPropsApp ()
getXmlDocPropsCore (line 580)

Getter

  • access: public
void getXmlDocPropsCore ()
getXmlDocPropsCustom (line 600)

Getter

  • access: public
void getXmlDocPropsCustom ()
getXmlRelsRels (line 540)

Getter

  • access: public
void getXmlRelsRels ()
getXmlWordDocumentContent (line 620)

Getter

  • access: public
void getXmlWordDocumentContent ()
getXmlWordDocumentStyles (line 640)

Getter

  • access: public
void getXmlWordDocumentStyles ()
getXmlWordEndnotes (line 660)

Getter

  • access: public
void getXmlWordEndnotes ()
getXmlWordFontTable (line 680)

Getter

  • access: public
void getXmlWordFontTable ()
getXmlWordFooter1 (line 700)

Getter

  • access: public
void getXmlWordFooter1 ()
getXmlWordHeader1 (line 720)

Getter

  • access: public
void getXmlWordHeader1 ()
getXmlWordRelsDocumentRels (line 740)

Getter

  • access: public
void getXmlWordRelsDocumentRels ()
getXmlWordSettings (line 760)

Getter

  • access: public
void getXmlWordSettings ()
getXmlWordStyles (line 780)

Getter

  • access: public
void getXmlWordStyles ()
getXmlWordThemeTheme1 (line 800)

Getter

  • access: public
void getXmlWordThemeTheme1 ()
getXml_Word_WebSettings (line 820)

Setter

  • access: public
void getXml_Word_WebSettings ()
mergeDOCX (line 2488)

Merge WordML into a DOCX. WordML is added at the end of the document

  • access: public
void mergeDOCX (string $path, string $newXML)
  • string $path: Path to DOCX file
  • string $newXML: WordML to add
readDOCX (line 2502)

Read DOCX file and extract WordML content

  • return: w:body content
  • access: public
Document.xml readDOCX (string $path)
  • string $path: Path to DOCX file
setDefaultFont (line 2523)

Change the default font

  • access: public
void setDefaultFont (string $font)
  • string $font: The new font Values: 'Arial', 'Times New Roman'...
setEncodeUTF8 (line 2534)

Transform to UTF-8 charset

  • access: public
void setEncodeUTF8 ()
setLanguage (line 2544)

Change default language.

  • access: public
void setLanguage ([$lang $lang = 'en-US'])
  • $lang $lang: Locale: en-US, es-ES...
setMarkAsFinal (line 2554)

Mark the document as final

  • access: public
void setMarkAsFinal ()
setTemplateSymbol (line 2570)

Set the symbol surrounding varibles (placeholders)

  • access: public
void setTemplateSymbol ([string $symbol = '$'])
  • string $symbol: The new symbol. Optional, $ as default
setTemporaryDirectory (line 490)

Setter

  • access: public
void setTemporaryDirectory ( $tempDir)
  • $tempDir
setXmlContentTypes (line 510)

Setter

  • access: public
void setXmlContentTypes ( $xmlContentTypes)
  • $xmlContentTypes
setXmlDocPropsApp (line 550)

Setter

  • access: public
void setXmlDocPropsApp ( $xmlDocPropsApp)
  • $xmlDocPropsApp
setXmlDocPropsCore (line 570)

Setter

  • access: public
void setXmlDocPropsCore ( $xmlDocPropsCore)
  • $xmlDocPropsCore
setXmlDocPropsCustom (line 590)

Setter

  • access: public
void setXmlDocPropsCustom ( $xmlDocPropsCustom)
  • $xmlDocPropsCustom
setXmlRelsRels (line 530)

Setter

  • access: public
void setXmlRelsRels ( $xmlRelsRels)
  • $xmlRelsRels
setXmlWordDocument (line 610)

Setter

  • access: public
void setXmlWordDocument ( $xmlWordDocument)
  • $xmlWordDocument
setXmlWordDocumentStyles (line 630)

Setter

  • access: public
void setXmlWordDocumentStyles ( $xmlWordDocumentStyles)
  • $xmlWordDocumentStyles
setXmlWordEndnotes (line 650)

Setter

  • access: public
void setXmlWordEndnotes ( $xmlWordEndnotes)
  • $xmlWordEndnotes
setXmlWordFontTable (line 670)

Setter

  • access: public
void setXmlWordFontTable ( $xmlWordFontTable)
  • $xmlWordFontTable
setXmlWordFooter1 (line 690)

Setter

  • access: public
void setXmlWordFooter1 ( $xmlWordFooter)
  • $xmlWordFooter
setXmlWordHeader1 (line 710)

Setter

  • access: public
void setXmlWordHeader1 ( $xmlWordHeader)
  • $xmlWordHeader
setXmlWordRelsDocumentRels (line 730)

Setter

  • access: public
void setXmlWordRelsDocumentRels ( $xmlWordRelsDocumentRels)
  • $xmlWordRelsDocumentRels
setXmlWordSettings (line 750)

Setter

  • access: public
void setXmlWordSettings ( $xmlWordSettings)
  • $xmlWordSettings
setXmlWordStyles (line 770)

Setter

  • access: public
void setXmlWordStyles ( $xmlWordStyles)
  • $xmlWordStyles
setXmlWordThemeTheme1 (line 790)

Setter

  • access: public
void setXmlWordThemeTheme1 ( $xmlWordThemeTheme)
  • $xmlWordThemeTheme
setXmlWordWebSettings (line 810)

Setter

  • access: public
void setXmlWordWebSettings ( $xmlWordWebSettings)
  • $xmlWordWebSettings
__toString (line 478)

Magic method, returns current word XML

  • return: Return current word
  • access: public
string __toString ()
Class Constants
NAMESPACEWORD = 'w' (line 35)
SCHEMA_IMAGEDOCUMENT =
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image'
(line 36)
SCHEMA_OFFICEDOCUMENT =
'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument'
(line 38)

Documentation generated on Thu, 02 Jun 2011 16:14:43 +0200 by phpDocumentor 1.4.3