CreateDocument

creates the document

package

Docxpresso

Methods

Construct

__construct(array $params = array()) 
access

public

Arguments

$params

array

the posible keys and values are: 'template' => (string) path to the template we wish to use 'base-font-size' => (int) The default document font size (in points) that will be used for the computation of relative units (em, rem). The default value can be globally set in the config.ini file

selects the following node in the document tree

_followingNode(\Docxpresso\DOMNode $node) : mixed
access

private

Arguments

$node

\Docxpresso\DOMNode

Response

mixed

(DOMnode or NULL)

inserts the styles of each header and footer

_insertHeaderFooterStyle(\Docxpresso\DOMNode $node, string $style) : \Docxpresso\ODFElement
access

private

Arguments

$node

\Docxpresso\DOMNode

$style

string

Response

\Docxpresso\ODFElement

detects if a path is absolute or relative

_isAbsolutePath(string $path) : \Docxpresso\ODFElement
access

private

Arguments

$path

string

Response

\Docxpresso\ODFElement

This method takes care of the document tab positions and styles

_parseTabs() : void
access

private

parses the current template for placeholder variables and stores the result in the placeholderVariables static variable

_parseVars(string $type = 'document', array $options = array()) : \Docxpresso\CreateDocument
access

public

Arguments

$type

string

it can be document header or footer

$options

array

an array with the following keys and values: 'format' => (array) an array with two entries giving the chosen openning and closing symbol for template variables. The default value is array('{{', '}}') but any other combination of symbols is possible. we do not recommend using the same symbol for both arrays entries or symbols that may be used somewhere else within the document because that may lead to "false positives"

Response

\Docxpresso\CreateDocument

This method makes sure that the custom template that is going to be used fulfills certain conditions

_processTemplate() : void
access

private

This method repairs the transparent backgrounds and empty background-image nodes for docx rendering

_removeEmptyBackground(string $dom) : void
access

private

Arguments

$dom

string

This method repairs the luminance attribute that it is not correctly rendered by Word

_removeImageLuminance(string $dom) : void
access

private

Arguments

$dom

string

This method repairs the floating frames that are anchored to 'char' for RTF rendering (this method is not used otherwise)

_repairFloats() : void
access

private

This method repairs the hidden section nodes inserted by DOCXPRESSO for their correct visualization in Word (by default Word shows hidden text in editing mode).

_repairSections(string $key) : void
access

private

Arguments

$key

string

This method repairs the grid of tables generated via the html method

_repairTable(string $key) : void
access

private

Arguments

$key

string

includes the table theme styles

_themeTableStyles(\Docxpresso\DOMNode $tableNode, string $key, string $class, array $mask) : void
access

private

Arguments

$tableNode

\Docxpresso\DOMNode

$key

string

$class

string

$mask

array

adds border information to a style

addBorder(string &$style, string $border) : void
static
access

public

static

Arguments

$style

string

$border

string

adds a bookmark If we try to insert directly a bookmark into the document a wrapping paragraph with default styles will be automatically created

bookmark(array $options, boolean $reference = false) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'name' => (string) the bookmark name needed for cross references
 'text' => (string)  the text to insert (can be empty)
 'style' => (string) a list of properties in CSS format

$reference

boolean

if true returns a reference to the wrapping paragraph element so we can keep nesting. The default value is false, i.e. no nested element

Response

\Docxpresso\ODFElement

adds a button associated with a form within the document

button(array $options, boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'form-name' => (string) the name of the form where we want to insert
 this control
 'name' => (string) the control name
 'value' => (string) the associated value
 'style' => (string) a list of properties in CSS format
 'styleId' => (string) if given the styleId is not generated randomly

$reference

boolean

if true returns a reference to the frame element so further elements can be nested. The default value is true.

Response

\Docxpresso\ODFElement

inserts a cell into a row. It can not be directly used in the document

cell() : \Docxpresso\CreateDocument
access

public

Response

\Docxpresso\CreateDocument

adds a chart to the document The charts can be inserted inline (default) or floating to the left, center or right

chart(string $type, array $options = array()) : \Docxpresso\ODFElement
access

public

Arguments

$type

string

the available types are: 2D: column, bar, pie, donut, area, line, scatter, bubble, radar, filled-radar, column-line 3D: 3Dcolumn, 3Dbar, 3Dpie, 3Ddonut, 3Darea, 3Dline, 3Dscatter

$options

array

with the following keys and values

 'data' => (array) it can be an array with different formats:
     pie and donuts charts:
         array( 'category_1' => 3,
                'category_2' => 5,
                'category_3' => 4.3,
               )
     bar, column, area , line, scatter, (filled-)radar
     and column-line charts:
         array( 'series' => array('ser_1', 'ser_2'),
                'category_1' => array(20,40),
                'category_2' => array(30,10),
                'category_3' => array(12.5, 54),
               )
     buble charts
         array( array(2, 5 7),
                array(4.3, 12, 3.5),
                array(6, 3, 5),
               )
 'chart-properties' => (array) with keys and values:
     'data-label-number' => (string) none, value or percentage.
     'label-position' => (string) avoid-overlap, center,
      top, top-right, right, bottom-right, bottom, bottom-left, left,
      top-left, inside, outside or near-origin.
     'label-position-negative' => (string) it only applies if
      the value is negative. If not given the value for
      data-label-position will be used
      top-left, inside, outside or near-origin.
     'hole-size' => (int) specifies the diameter of the inner hole
      of a ring chart as percentage of the outer diameter of the
      outermost ring.
     'pie-offset' => (int) specifies the distance of a segment from
      the center of the circle in case of circle charts. The offset
      is given as an integer which is interpreted as a percentage of
      the radius of the circle. In case of ring charts specifies an
      additional distance of a segment from the center of the circle.
      The distance is given as percentage of the thickness of the
      ring.
     'angle-offset' => (int) it specifies in degrees a counter
      clockwise rotation of a polar coordinate in a circle, ring or
      polar chart.
     'stacked' => (boolean) default value is false. it specifies the
      accumulation of the series values per category. Each value is
      in addition to the other values in the same category.
     'chart-interpolation' => (string) none (if points are to be
      connected by a straight line, b-spline or cubic-spline.
     'spline-resolution' => (int) a positive inetger. It only applies
      if the chart-interpolation option is not equal to none.
     'deep' => (boolean) if true the series will be shown
      in 3D one behind the other and not side by side. It only
      applies to 3D charts.
     'solid-type' => (string) cuboid (default), cylinder, cone or
      pyramid. It only applies to 3D bar charts.
 'style' => (string) a list of properties in CSS format that only
  set the global properties of the chart. In order to customize the
  different chart components you should use the associated
  chart methods.

Response

\Docxpresso\ODFElement

inserts a chart legend into a chart. It can not be directly used on a document

chartLegend() : \Docxpresso\ODFElement
access

public

Response

\Docxpresso\ODFElement

inserts a chart title into a chart. It can not be directly used on a document

chartTitle() : \Docxpresso\ODFElement
access

public

Response

\Docxpresso\ODFElement

adds a checkbox to a form within the document

checkbox(array $options, boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'form-name' => (string) the name of the form where we want to insert
  this control
 'name' => (string) the control name
 'value' => (string) the associated value
 'checked' => (int) 1 or 0
 'style' => (string) a list of properties in CSS format
 'styleId' => (string) if given the styleId is not generated randomly
 'pageNumber' => (int) for absolutely positioned controls (optional).

$reference

boolean

if true returns a reference to the frame element so further elements can be nested. The default value is true.

Response

\Docxpresso\ODFElement

clones the chosen content and replicates it the requested number of times in the chosen location

cloneContent(array $options) : void
access

public

Arguments

$options

array

an array with the following keys and values: 'needle' => (string) the text to be searched in order to select the content to be cloned or the bookmark name if the element option is set to be equal to bookmark. 'element' => (string) the type of element to be cloned. possible values are: paragraph (default), list, list-item, table, table-row, image, chart, heading, section and bookmark. 'match' => (int) if there is more than one resulting element its order of ocurrence. The default is 1 (first match). 'repeat' => (int) The number of times that the cloned element will be repeated. Deafault is 1. 'position' => (mixed) specifies were the clone nodes should be inserted. Possible values are a string:

 self: (default) just before the chosen element
 cursor: just before the current cursor location

or a DOMNode (the cloned nodes will be inserted before it). In the case of list-element and table-row the last option will be ignored. 'heading-level' => (int) only applies if 'heading' is the chosen element value. Default value is 1. 'container' => (bool) if true (default is false) the container paragraph (if any) will be cloned in the case of charts, images and textboxes. 'target' => (string) it can be document (default), header or footer.

Inserts a column break into the document

columnBreak() : void
access

public

sets the cursor at the chosen location

cursor(array $options = array()) : void
access

public

Arguments

$options

array

an array with the following keys and values: 'needle' => (string) if given the (first, if match is not set) node containing it will be chosen as the reference node. 'element' => (string) it sets the type of the reference node. It can be paragraph (default) or table. 'match' => (int) if there is more than one resulting node its order of ocurrence. The default is 1 (first match). 'position' => (string) it can be before (default, the cursor is located before the reference node), after (the cursor is located just after the reference node) or end (end of the document). In the last case the options needle and match will be ignored.

creates a document fragment that can be later inserted directly into the document or within another document element

documentFragment() : \Docxpresso\DocumentFragment
access

public

Response

\Docxpresso\DocumentFragment

Inserts an endnote into a paragraph therefore can not be directly used in the document root

endnote(array $options = array(), boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

$reference

boolean

Response

\Docxpresso\ODFElement

Extracts all files from a ZipArchive object

extractTemplateFiles(\Docxpresso\ZipArchive $zip) : array
static
access

public

static

Arguments

$zip

\Docxpresso\ZipArchive

Response

array

adds a field that generates some "automatic content" out of the document structure (page numbers and count), the metadata or the like

field(string $type, array $options = array(), boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$type

string

the available types are: author-name: the full author name bookmark-ref: reference to a bookmark page date: current date page-count: total number of pages page-number: current page number (with an optional offset) title: document title

$options

array

the possible keys and values are:

 'default-value' => (string) the field default value
 'number-format' => (string) used for page-count and page-number
     1: Hindu-Arabic number sequence starts with 1.
     a: number sequence of lowercase Modern Latin basic alphabet
     characters starts with “a”.
     A: number sequence of uppercase Modern Latin basic alphabet
     characters starts with “A”.
     i: number sequence of lowercase Roman numerals starts with “i”.
     I: number sequence of uppercase Roman numerals start with “I”.
 'number-offset' => (int) allows to start the numbering with a given
 offset. For example, if we would like to ignore the front page for
 page numbering we should choose a value of -1.
 'reference-format' => (string) used for bookmark-ref
     page: displays the number of the page on which the
     referenced item appears.
     text: displays the text of the referenced item.
 'reference-name' => (string) the name of the linked reference
 'date-format' => (array) the date is built by running consecutively
 through the array entries. possible values are:
     day: day of the month with two digits
     day-short: day of the month with one/two digits (as required)
     day-of-week: day of the week in textual format
     day-of-week-short: abbreviated day of the week in textual format
     month: month of the year with two digits
     month-short: month of the year with one/two digits (as required)
     month-of-year: month of year in textual form
     month-of-year-short: month of year in abbreviated textual form
     year: year number with four digits
     year-short: year number with 2 digits
     text (string): an arbitrary string of text
     Examples:
     1. array('day', '/', 'month', '/', 'year') yields 07/03/2014
     2. array('day-of-week', ' ', 'day-short', ', 'month-of-year', '-', 'year')
     yields Thursday 7, November-2014
 'style' => (string) a list of properties in CSS format

$reference

boolean

if true returns a reference to the form element so further elements can be nested. The default value is true.

Response

\Docxpresso\ODFElement

inserts a footnote into a paragraph therefore can not be directly used in the document root

footnote(array $options = array(), boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

$reference

boolean

Response

\Docxpresso\ODFElement

inserts a form container into the document. The form itself does not accept styling options so if you want to include them you should wrap the form within a table or frame.

form(array $options, boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

the avalaible key and values are: 'name' => (string) a unique name that identifies the form. If not given will be automatically generated. 'target' => (string) that can be '_blank (default), _self or _top or a frame name 'action' => (string) points to the URL (if any) where the data of the form should be sent and processed 'method' => (string) may be get (default) or post

$reference

boolean

if true returns a reference to the form element so further elements can be nested. The default value is true.

Response

\Docxpresso\ODFElement

adds a frame to the document The frame can be floating or enjoy absolute or relative positioning

frame(array $options = array(), boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'style' => (string) a list of properties in CSS format
 'styleId' => (string) if given the styleId is not generated randomly

$reference

boolean

if true returns a reference to the frame element so further elements can be nested. The default value is true.

Response

\Docxpresso\ODFElement

returns the array that holds reference to the associated DOMDocument objects (content, styles, metas, manifest)

getDOM() : array
access

public

Response

array

adds a header to a document section

header(array $options = array()) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'section' => (int) the section number. If not given it is assumed
 that the header will be inserted in the current section
 'dynamic-spacing' => (bool) select true if you wish that the
  package accomodates the header properties to the general document
  layout. Default value is false.
 'left-page' => (bool) if true the header will be specific of left
 pages only
 'style' => (string) a list of properties in CSS format
 'styleId' => (string) if given the styleId is not generated randomly

Response

\Docxpresso\ODFElement

adds a heading to the document

heading(array $options, boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'level' => (int) the heading level: 1 (h1), 2 (h2),... up to 6
 'text' => (string)  an optional text (it can also be added later
  with the text method)
 'style' => (string) a list of properties in CSS format
 'enforce' => (bool) if set to true and the current element does not
 accept paragraphs the method searches for the first ancestor that
 allows for the isnsertion. Beware that the return element is a
 reference to the inserted paragraph and the chaining may result
 affected consequently!!

$reference

boolean

if true returns a reference to the paragraph element. The default value is true

Response

\Docxpresso\ODFElement

adds an "horizontal rule" to the document

hr(array $options = array()) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'style' => (string) a list of properties in CSS format
 'styleId' => (string) if given the styleId is not generated randomly

Response

\Docxpresso\ODFElement

This method allows to "insert" HTML content into the document

html(array $options) : \Docxpresso\CreateDocument
access

public

Arguments

$options

array

the available keys and values are: 'baseURL' => (string) if set enforces the base URL used for relative paths, otherwise it will be autodetected (if possible). 'encoding' => (string) if set enforces the encoding to be used otherwise it will be autodetected. 'isFile' => (boolean) true if the HTML code has to be retrieved from a file. Default value is false, i.e. the HTML is a string. 'context' => (array) this option is only taken into account if we need to fetch the HTML code via a http request. Its use is optional and if not set standard values, valid in the majority of cases, will be used. This option sets the http context (headers) for the http request. Depending on the server this option may be mandatory, i.e. the server will not return anything unless it receives this additional info. The keys and values are(http://www.php.net/manual/en/context.http.php):

 'method': GET (default value) or POST.
 'header': an array with the required headers that may include among
  others: 'Referer', 'User-agent', 'Referer', 'Connection', ...
 'proxy':address of the proxy server
 'request_fulluri' true or false (default).
 'follow_location': Follow Location header redirects. Set to 0
  to disable. Default value is 1.
 'max_redirects'The maximum number of redirects to follow.
  1 or less means that no redirects are followed (default is 20).
 'protocol_version': HTTP protocol version (default is 1.0).

'html' => (string) it can be a string of HTML code or the path to the the path to the HTML file if the 'isFile' option is set to true.

Response

\Docxpresso\CreateDocument

adds an image to the document The images can be inserted inline (default) or floating to the left or right

image(array $options, boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'src' => (string) path to the image we want to insert
 'title' => (string) the image title should be included for
  accesibility reasons
 'description' => (string) the image description should be included
  for accesibility reasons
 'style' => (string) a list of properties in CSS format

$reference

boolean

if true returns a reference to the image element so further elements can be nested. The default value is false.

Response

\Docxpresso\ODFElement

adds an input field to a form within the document

inputField(array $options, boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'form-name' => (string) the name of the form where we want to insert
 this control
 'name' => (string) the control name.
 'value' => (string) the associated default value, if any.
 'style' => (string) a list of properties in CSS format.
 'styleId' => (string) if given the styleId is not generated randomly
 'pageNumber' => (int) for absolutely positioned controls (optional).

$reference

boolean

if true returns a reference to the frame element so further elements can be nested. The default value is true.

Response

\Docxpresso\ODFElement

inserts a document fragment previously created with the documentFragment method

insertDocumentFragment(\Docxpresso\DocumentFragment $fragment) : \Docxpresso\CreateDocument
access

public

Arguments

$fragment

\Docxpresso\DocumentFragment

Response

\Docxpresso\CreateDocument

Inserts a line break into the document

lineBreak() : void
access

public

inserts an item into a list. It can not be directly inserted into the document

listItem() : \Docxpresso\CreateDocument
access

public

Response

\Docxpresso\CreateDocument

loads a custom theme

loadTheme(string $path = '') : \Docxpresso\CreateDocument
access

public

Arguments

$path

string

the path to the correponding CSS file. The

Response

\Docxpresso\CreateDocument

adds a math equation to the document The equations can be inserted inline (default) or floating to the left, right or center.

math(string $equation, array $options = array()) : \Docxpresso\ODFElement
access

public

Arguments

$equation

string

the equation that we want to insert in MathML 1.0 or StarMath 5.0 format

$options

array

with the following keys and values

 'math-settings' => (array) with the following keys and values:
     'base-font-size' => (int) base font size used in the equation.
      The default size is 12 (pt).
     'rel-text-size' => (int) relative text size (default: 100)
     'rel-indexes-size' => (int) relative index size (default: 60)
     'rel-functions-size' => (int) relative function size (default: 100)
     'rel-operators-size' => (int) relative operator size (default: 100)
     'rel-limits-size' => (int) relative limit size (default: 60)
     'variables-font' => (string) default is Times New Roman
     'functions-font' => (string) default is Times New Roman
     'numbers-font' => (string) default is Times New Roman
     'text-font' => (string) default is Times New Roman
     'custom-serif-font' => (string) default is Times New Roman
     'custom-sans-serif-font' => (string) default is Arial
     'custom-fixed-font' => (string) default is Courier New
 'style' => (string) a list of properties in CSS format

NOTE: Only MathML 1.0 is supported. You can check the documentation in

   http://www.w3.org/TR/1998/REC-MathML-19980407/.
   For StarMath 5.0 syntax you may refer to the official docs in:
   https://wiki.openoffice.org/wiki/Documentation/OOo3_User_Guides/Math_Guide/Math_commands_reference
   http://www.openoffice.org/documentation/manuals/oooauthors/MathObjects.pdf

Response

\Docxpresso\ODFElement

replaces the chosen template content with the given content

ODF2HTML5(string $path, array $options = array()) : void
access

public

Arguments

$path

string

the path to the resulting HTML5 file. The path should include the extension (html or htm)

$options

array

an array with the following keys and values: 'format' => (string) the values can be:

 standard: (default) the styles and images are stored in a folder
 with the same name of the HTML5 file
 single-file: the styles are integrated within the <head> tag
 element and the images are base64 encoded an integrated within the
 HTML5 file

adds an ordered list to the document

orderedList(array $options = array(), boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'items' => (array) a (nested) array with the items to be included
  in the list (plain text or document fragments). This argument is
  optional because the items can also be added via the itemList
  method.
 'style' => (string) a list of properties in CSS format
 'styleId' => (string) if given the styleId is not generated randomly

$reference

boolean

if true returns a reference to the element so further elements can be nested. The default value is true.

Response

\Docxpresso\ODFElement

Inserts a page break into the document

pageBreak() : void
access

public

Stablish the page layout properties.

pageLayout(array $options = array()) : \Docxpresso\CreateDocument
access

public

Arguments

$options

array

the availables keys and values are:

 'orientation' => (string) can be portrait (default) or landscape
 'paperSize' => (string) the predefined available options are:
     A3
     A4 (default)
     letter
     legal
 If the width and height properties are set in the style option this
 value will be ignored
 'section' => (int)  the section number to which we want to apply
 the custom layout. If not set or empty the style is applied to all
 document sections.
 'style' => (string) a list of properties in CSS format
 'styleId' => (string) if given the styleId is not generated randomly

Response

\Docxpresso\CreateDocument

adds a paragraph to the document

paragraph(array $options = array(), boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'text' => (string)  an optional text (it can also be added later
  with the text method)
 'style' => (string) a list of properties in CSS format
 'styleId' => (string) if given the styleId is not generated randomly

$reference

boolean

if true returns a reference to the paragraph element. The default value is true

Response

\Docxpresso\ODFElement

parses the cell childs of a row to set inherited table properties

parseRowCellChilds(array $options) : void
static
access

public

static

Arguments

$options

array

with the following keys and values

 'dom' => (DOMDocument) the dom we need to search
 'id' => (string) unique identifier
 'idType' => (string) it can be styleId or xml:id
 'tag' => (string)  the tag we want to parse
 'style' => (array) the preparsed CSS styles

parses the cell childs of a table to set inherited table properties

parseTableCellChilds(array $options) : void
static
access

public

static

Arguments

$options

array

with the following keys and values

 'dom' => (DOMDocument) the dom we need to search
 'id' => (string) unique identifier
 'idType' => (string) it can be styleId or xml:id
 'tag' => (string)  the tag we want to parse
 'style' => (array) the preparsed CSS styles

parses the current template for placeholder variables and stores the result in the placeholderVariables static variable

parseVariables(array $options = array()) : \Docxpresso\CreateDocument
access

public

Arguments

$options

array

an array with the following keys and values: 'format' => (array) an array with two entries giving the chosen openning and closing symbol for template variables. The default value is array('{{', '}}') but any other combination of symbols is possible. Althoug allowed, we do not recommend using the same symbol for both arrays entries or symbols that may be used somewhere else within the document because that may lead to "false positives"

Response

\Docxpresso\CreateDocument

adds a radio button to a form within the document

radioButton(array $options, boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'form-name' => (string) the name of the form where we want to insert
 this control
 'name' => (string) the control name. Radio buttons belonging to the
 same group should share the same name
 'value' => (string) the associated value
 'selected' => (bool) true or false. only one readio button should be
 selected by group otherwise use a checkbox control component
 'style' => (string) a list of properties in CSS format
 'styleId' => (string) if given the styleId is not generated randomly
 'pageNumber' => (int) for absolutely positioned controls (optional).

$reference

boolean

if true returns a reference to the frame element so further elements can be nested. The default value is true.

Response

\Docxpresso\ODFElement

removes the chosen content from the document

removeContent(array $options) : \Docxpresso\CreateDocument
access

public

Arguments

$options

array

an array with the following keys and values: 'needle' => (string) the text to be searched to select the content to be removed or the bookmark name if the element option is set to be equal to bookmark. 'element' => (string) the type of element to be removed. possible values are:

 text: (default)the text given in the needle is removed from the
 document,
 paragraph: the paragraphs that contain the needle text are removed,
 list: the lists that contain the needle text are removed,
 list-item: the list items that contain the needle text are removed,
 table: the table that contains the needle text is removed unless the
 text fall within a subtable,
 table-row: the same that for table but just for a table row
 image: the images which title include the needle text are removed,
 chart: the charts which title description include the given text
 are removed,
 section: all section content of a section that contains the needle
 text is removed,
 textbox: all textbox content of a textbox that contains the needle
 text is removed,
 heading: all the contents that fall under a given heading are
 removed whenever the heading contains the needle text

'heading-level' => (int) only applies if 'heading' is the chosen element value. Default value is 1. 'match' => (mixed) if an integer (defining its order of appareance) only that match will be removed if 'all'(default value)all the matches will be removed. 'container' => (bool) if true (default is false) the container paragraph (if any) will be removed in the case of charts, images and textboxes. 'target' => (string) possible values are: document (default), header or footer

Response

\Docxpresso\CreateDocument

This method removes the customCursor element

removeCursor(\Docxpresso\DOMNode $node = NULL) : void
access

public

Arguments

$node

\Docxpresso\DOMNode

This method generates the final document

render(string $path = '', array $options = array()) : void
access

public

Arguments

$path

string

the path where we want to save the generated file

$options

array

rendering options with the following keys and values The avalaible keys and values are: 'soffice' => (string) path to soffice.exe . If not explicitely given the path for soffice stored in config.ini is used. 'legacy' => (bool) if true converts the ouput to Word 97 compatible .doc file. Only applies to .doc format. 'PageRange' => (string) if empty (default) includes all pages. If a single number it renders only the corresponding page and if a range, i.e. 1-3 renders from the page 1 to three both included. 'UseLosslessCompression' => (bool) if true images are not compressed. The default is false. 'Quality' => (int) the quality of the compressed images (JPG). Deafault value is 90. 'ReduceImageResolution' => (bool) if true the image resolution is changed. Default is false. 'MaxImageResolution' => (int) maximum image resolution. Default value is 300. 'SelectPdfVersion => (int) PDF version:

 0: PDF 1.4 (default).
 1: PDF/A-1 (ISO 19005-1:2005).

'UseTaggedPDF => (bool) if true the generated PDF will be tagged for accesibility. Default value is false. 'ExportFormFields => (bool) exports form fields. Default value is true. 'FormsType' => (int) form protocol:

 0: FDF.
 1: PDF.
 2: HTML(default value).
 3: XML.

'ExportBookmarks' => (bool) exports bookmarks. Default value is true. 'EmbedStandardFonts' => (bool) embeds the standard PDF fonts. Default value is false. 'Watermark' => (string) watermark text. Default is an empty string. 'InitialView' => (int) initial view:

 0: (default) default view mode, neither outlines or thumbnails.
 1: outline pane opened.
 2: thumbnail pane opened.

'Magnification' => (int) PDF magnification on openning:

 0: (default) default magnification.
 1: fit entire page within the viewer window.
 2: fit entire page width within the viewer window.
 3: fit entire page width (cutting margins) within the viewer window.
 4: opens with the zoom specified in the Zoom option.

'Zoom' => (int) zoom level on openning. Default is 100 (it only applies if Maginification equals 4). The available range is 50-1600. 'PageLayout' => (int) PDF layout on openning:

 0: (default) default viewer configuration.
 1: one page at a time.
 2: display pages in one column.
 3: display pages in two columns.

'FirstPageOnLeft' => (bool) if true the first page should be on the left. Default is false (only used if PageLayout equals 3). 'CenterWindow' => (bool) if true the PDF window is centered in the screen. Default is false. 'OpenInFullScreenMode' => (bool) if true the PDF opens in full screen mode. Default is false. 'DisplayPDFDocumentTitle' => (bool) if true the PDF window shows the document title. Default is true. 'HideViewerMenubar' => (bool) if true hides the viewer menu. Default is false. 'HideViewerToolbar' => (bool) if true hides the viewer toolbar. Default is false. 'HideViewerWindowControls' => (bool) if true hides the viewer window controls. Default is false. 'EncryptFile' => (bool) if true encrypts the file. Default is false. 'DocumentOpenPassword' => (string) password to open file if the option EncryptFile is set to true. Default is an empty string. 'RestrictPermissions' => (bool) if true restricts you may restrict printing, copying and modifying. Default is false. 'PermissionPassword' => (string) password to to access the restricted functionalities if the option DocumentOpenPassword is set to true. Default is an empty string. 'Printing' => (int) printing configuration:

 0: the document can not be printed.
 1: the document can only be printed in low resolution.
 2: (default) the document can be printed with no restrictions.

'Changes' => (int) specify which changes are allowed:

 0: protected against any change.
 1: pages can be added, deleted or rotated.
 2: filling forms.
 3: filling forms and adding comments.
 4: (default) all changes are allowed but page extraction.

'EnableCopyingOfContent' => (bool) if true the content can be copied and pasted elsewhere. Default is true.

replaces the chosen template content with the given content

replace(array $vars, array $options = array()) : void
access

public

Arguments

$vars

array

an array with keys the name of the variables and values:

 'value' => (mixed) it can be:
     1. A string or DocumentFragment object
     2. An array with entries that are themselves
        strings or DocumentFragment objects
 'html' => (bool) if true (default) detects if the content is plain
  text or a HTML code. It overwrites the global html option if any.
 'parse-line-breaks' => (bool) if true parses line breaks. If the
  method detects that the string is HTML the default is false,
  otherwise defaults to true. It overwrites the global
  parse-line-breaks option if any.
 'block-type' => (bool) if true removes and replaces the containing
  paragraph. Default is false. It overwrites the global block-type
  option if any.
 'image' => (bool) set only to true if the variable name is
  associated with the title of a placeholder image. Default is false.
  It overwrites the element option if any.
 'match' => (int) if given and if the 'value' option is not an array
  only the selected match will be replaced, i.e. if match equals 1
  the first appearance of the variable will be replaced and the
  others will be ignored. It overwrites the global match option
  if any.
 'width' => (string) an optional new width for image replacement. The
  format must be like in CSS, i.e. 100px or 2cm, 3in, etcetera.
 'height' => (string) an optional new height for image replacement.
  The format must be like in CSS, i.e. 100px or 2cm, 3in, etcetera.

$options

array

an array with the following keys and values: 'format' => (array) an array with two entries giving the chosen openning and closing symbol for template variables. The default value is array('{{', '}}') but any other combination of symbols is possible, even array('', ''), although this is not recommended unless strictly necessary. 'element' => (string) the element level at which we want to carry out the replacement. possible values are: text (default), paragraph, list, table or image. 'target' => (string) it can be document (default), header or footer. 'html' => (bool) if true (default) detects if the content is plain text or a HTML code. It may be overwritten for a single value in the $vars array. 'parse-line-breaks' => (bool) if true parses line breaks. If the method detects that the string is HTML the default is false, otherwise defaults to true. It may be overwritten for a single value in the $vars array. 'block-type' => (bool) if true removes and replaces the containing paragraph. Default is false. It may be overwritten for a single value in the $vars array. 'match' => (int) if given and if the 'value' option is not an array only the selected match will be replaced, i.e. if match equals 1 the first appearance of the variable will be replaced and the others will be ignored. It may be overwritten for a single value in the $vars array

replaces the chosen template chart data with the given content

replaceChartData(string $var, array $options) : void
access

public

Arguments

$var

string

the name used for the chart title. If empty the chatr will be chosen via the match option.

$options

array

with the following keys and values

 'data' => (array) it can be an array with different formats:
     pie and donuts charts:
         array( 'category_1' => 3,
                'category_2' => 5,
                'category_3' => 4.3,
               )
     bar, column, area , line, scatter, (filled-)radar
     and column-line charts:
         array( 'series' => array('ser_1', 'ser_2'),
                'category_1' => array(20,40),
                'category_2' => array(30,10),
                'category_3' => array(12.5, 54),
               )
     buble charts: not supported yet

'format' => (array) an array with two entries giving the chosen openning and closing symbol for the variable. The default value is array('{{', '}}') but any other combination of symbols is possible, even array('', ''), although this is not recommended unless strictly necessary. 'match' => (int) if given, only the selected match will be replaced, i.e. if match equals 1 the first chart tagged with the variable will be replaced and the others will be ignored.

inserts a row into a table. It can not be directly used in the document

row() : \Docxpresso\CreateDocument
access

public

Response

\Docxpresso\CreateDocument

Adds a new section to the document with its own layout.

section(array $options = array()) : \Docxpresso\CreateDocument
access

public

Arguments

$options

array

the availables keys and values are:

 'orientation' => (string) can be portrait (default) or landscape
 'paperSize' => (string) the predwefined available options are:
     A3
     A4 (default)
     letter
     legal
 If the width and height properties are set in the style option this
 value will be ignored
 'style' => (string) a list of properties in CSS format
 'styleId' => (string) if given the styleId is not generated randomly

Response

\Docxpresso\CreateDocument

adds a dropdown select to a form within the document

select(array $options, boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'form-name' => (string) the name of the form where we want to insert
 this control
 'name' => (string) the control name.
 'items' => (array) an associative array with keys as options and
 values the corresponding form values
 'selected' => (string) the name of the selected item
 selected by group otherwise use a checkbox control component
 'style' => (string) a list of properties in CSS format
 'styleId' => (string) if given the styleId is not generated randomly
 'pageNumber' => (int) for absolutely positioned controls (optional).

$reference

boolean

if true returns a reference to the frame element so further elements can be nested. The default value is true.

Response

\Docxpresso\ODFElement

This method inserts a customCursor node within the provided DOMNode just before the provided reference node (if empty the cursor is appended)

setCursor(\Docxpresso\DOMNode $node, \Docxpresso\DOMNode $refNode = NULL, string $position = 'before') : void
access

public

Arguments

$node

\Docxpresso\DOMNode

$refNode

\Docxpresso\DOMNode

$position

string

This method allows to overwrite the global CSS properties defined in globalCSSProps.inc

setGlobalCSSProps(array $props) : void
access

public

Arguments

$props

array

the available global CSS properties that may be modified with the help of this method are: font-size: value in pixels (12px, 14px, ...) font-family: Arial, Calibri, ... color: hexadecimal value (#000000, #ff0000, ...)

A tab can only be added to a run of text

tab(array $options = array()) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

Response

\Docxpresso\ODFElement

adds a table to the document

table(array $options = array(), boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'data' => (array)  an optional array of arrays with the
  values to be included in the different table rows and cells.
  Beware of teh limited formatting capabilities of this option.
  For more advanced formatting one should use
  the row and cell methods.
  Beware of teh limited formatting capabilities of this option.
 'grid' => (mixed) mandatory if tableData is not given.
  It may be:
     The number of columns (integer): all columns are of equal size
     An array where each item represents the respective column width
 'style' => (string) a list of properties in CSS format
 'mask' => (array) this array stablishes the table theme options that
  should be applied to the current table. The default values are:
  array( 'NE'          => true,
         'NW'          => true,
         'SE'          => true,
         'SW'          => false,
         'firstRow'    => true,
         'lastRow'     => false,
         'bandedRow'   => true,
         'firstCol'    => true,
         'lastCol'     => false,
         'bandedCol'   => false)
 'styleId' => (string) if given the styleId is not generated randomly

$reference

boolean

if true returns a reference to the text element so they can be nested.

Response

\Docxpresso\ODFElement

adds text into a paragraph If we try to insert directly text into the document a wrapping paragraph with default styles will be automatically created

text(array $options, boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'text' => (string)  an optional text (it can also be added later
  with the text method)
 'style' => (string) a list of properties in CSS format
 'styleId' => (string) if given the styleId is not generated randomly

$reference

boolean

if true returns a reference to the text element so they can be nested.

Response

\Docxpresso\ODFElement

adds a text area to a form within the document

textArea(array $options, boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'form-name' => (string) the name of the form where we want to insert
 this control
 'name' => (string) the control name
 'value' => (string) the associated value
 'scroll' => (boolean) if true (default) the text area shows vertical
 scrollbars
 'style' => (string) a list of properties in CSS format
 'styleId' => (string) if given the styleId is not generated randomly
 'pageNumber' => (int) for absolutely positioned controls (optional).

$reference

boolean

if true returns a reference to the frame element so further elements can be nested. The default value is true.

Response

\Docxpresso\ODFElement

adds a textbox to the document The textbox can be floating or enjoy absolute or relative positioning

textBox(array $options = array(), boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'pageNumber' => (int) for absolutely positioned textboxes (optional)
 'style' => (string) a list of properties in CSS format
 'styleId' => (string) if given the styleId is not generated randomly

$reference

boolean

if true returns a reference to the frame element so further elements can be nested. The default value is true.

Response

\Docxpresso\ODFElement

adds a table of contents to the document

toc(array $options = array()) : \Docxpresso\CreateDocument
access

public

Arguments

$options

array

with the following keys and values

 'auto-update' => (boolean) if true (default value) the  TOC will
  automatically update on openning and the user will not be prompted
  to do so. This option is ignored unless the target document

is in Open Document Format (.odt)

 'leader-char' => (string) the leader char the joins the name of the
  heading with its page number. The default value is '.'.
 'linked' => (boolean) if true (default value) the toc entry is
  linked to the corresponding heading so on can navegate through the
  contents from the toc.
 'outline-level' => (int) an integer number (smaller than 10) that
  sets the the highest heading level that wil show up in the toc. The
  default value is 3.
 'title' => (string) The title, if any, of the table of contents. The
  format is given in the first array entry of the style option
 'style' => (array) an array with the styles in CSS format
  for the title (style[0]) and the toc levels (the j-th level style
  being given by style[j]).

Response

\Docxpresso\CreateDocument

adds an unordered list to the document

unorderedList(array $options = array(), boolean $reference = true) : \Docxpresso\ODFElement
access

public

Arguments

$options

array

with the following keys and values

 'items' => (array) a (nested) array with the items to be included
  in the list (plain text or document fragments). This argument is
  optional because the items can also be added via the itemList
  method.
 'style' => (string) a list of properties in CSS format
 'styleId' => (string) if given the styleId is not generated randomly

$reference

boolean

if true returns a reference to the element so further elements can be nested. The default value is true.

Response

\Docxpresso\ODFElement

inserts a chart into a document with all data and styling options encoded in a XML string.

XMLChart(string $xml, string $styleId = '') : \Docxpresso\ODFElement
access

public

Arguments

$xml

string

with the following structure <chart style="CSS styles"

   type="column|bar|pie|donut|area|line|scatter|bubble|radar|filled-radar|column-line|3Dcolumn|3Dbar|3Dpie|3Ddonut|3Darea|3Dline|3Dscatter"
   data-label-number="none|value|percentage"
   label-position="avoid-overlap|center|top|top-right|right|bottom-right|bottom|bottom-left|left|top-left|inside|outside|near-origin"
   label-position-negative="top-left|inside|outside|near-origin"
   hole-size="integer"
   pie-offset="integer"
   angle-offset="integer"
   stacked="boolean"
   chart-interpolation="none|b-spline|cubic-spline"
   spline-resolution="integer"
   deep="boolean" >
<title color="hexadecimal color"
       font-family="string"
       font-size="float(pt|cm|in|mm)"
       font-weight="normal|bold"
       font-style="normal|italic"
       stroke="solid|dash|none"
       fill-color="hexadecimal color"
       opacity="integer%"
       stroke-width="float(pt|cm|in|mm)"
       stroke-color="hexadecimal color"
       stroke-opacity="integer%"
       stroke-linejoin="round|bevel|middle|miter|none"
       stroke-linecap="butt|round|square" >Title</title>
<legend legend-position="left|right|top|bottom"
        color="hexadecimal color"
        font-family="string"
        font-size="float(pt|cm|in|mm)"
        font-weight="normal|bold"
        font-style="normal|italic"
        stroke="solid|dash|none"
        fill-color="hexadecimal color"
        opacity="integer%"
        stroke-width="float(pt|cm|in|mm)"
        stroke-color="hexadecimal color"
        stroke-opacity="integer%"
        stroke-linejoin="round|bevel|middle|miter|none"
        stroke-linecap="butt|round|square"/>
<grid dimension="x|y|z"
      type="major|minor"
      stroke="solid|dash|none"
      stroke-width="float(pt|cm|in|mm)"
      stroke-color="hexadecimal color"
      stroke-opacity="integer%"
      stroke-linejoin="round|bevel|middle|miter|none"
      stroke-linecap="butt|round|square" />
<axis dimension="x|y|z"
      visible="boolean"
      logarithmic="boolean"
      font-color="hexadecimal color"
      font-size="float(pt|cm|in|mm)"
      axis-position="start|end"
      origin="float"
      maximum="float"
      minimum ="float"
      label-arrangement="side-by-side|stagger-even|stagger-odd"
      display-level="boolean"
      axis-label-position="near-axis|near-axis-other-side|outside-end|outside-start"
      reverse-direction="boolean"
      text-overlap="boolean"
      line-break="boolean"
      stroke="solid|dash|none"
      stroke-width="float(pt|cm|in|mm)"
      stroke-color="hexadecimal color"
      stroke-opacity="integer%"
      stroke-linejoin="round|bevel|middle|miter|none"
      stroke-linecap="butt|round|square"
      interval-major="float"
      interval-minor-divisor="integer"
      tick-marks-major-inner="boolean"
      tick-marks-minor-inner="boolean"
      tick-marks-major-outer="boolean"
      tick-marks-minor-outer="boolean" />
<component type="wall|floor"
           fill-color="hexadecimal color"
           opacity="integer%"
           stroke="solid|dash|none"
           stroke-width="float(pt|cm|in|mm)"
           stroke-color="hexadecimal color"
           stroke-opacity="integer%"
           stroke-linejoin="round|bevel|middle|miter|none"
           stroke-linecap="butt|round|square" />
<transform3D rotate-x="integer"
             rotate-y="integer"
             rotate-z="integer"
             right-angled-axes="true|false"
             perspective="integer" />
<!-- for pie and donut charts -->
<categories>
    <category name=""
              value=""
              fill-color="hexadecimal color"
              opacity="integer%"
              stroke="solid|dash|none"
              stroke-width="float(pt|cm|in|mm)"
              stroke-color="hexadecimal color"
              stroke-opacity="integer%" />
    <category name=""
              value=""
              fill-color="hexadecimal color"
              opacity="integer%"
              stroke="solid|dash|none"
              stroke-width="float(pt|cm|in|mm)"
              stroke-color="hexadecimal color"
              stroke-opacity="integer%" />
    <category name=""
              value=""
              fill-color="hexadecimal color"
              opacity="integer%"
              stroke="solid|dash|none"
              stroke-width="float(pt|cm|in|mm)"
              stroke-color="hexadecimal color"
              stroke-opacity="integer%" />
</categories>
<!-- for all other charts -->
<series>
    <ser name=""
         fill-color="hexadecimal color"
         opacity="integer%"
         stroke="solid|dash|none"
         stroke-width="float(pt|cm|in|mm)"
         stroke-color="hexadecimal color"
         stroke-opacity="integer%"
         solid-type="cuboid|cylinder|cone|pyramid" />
    <ser name=""
         fill-color="hexadecimal color"
         opacity="integer%"
         stroke="solid|dash|none"
         stroke-width="float(pt|cm|in|mm)"
         stroke-color="hexadecimal color"
         stroke-opacity="integer%"
         solid-type="cuboid|cylinder|cone|pyramid" />
</series>
<categories>
    <category name="">
        <data value="" />
        <data value="" />
    </category>
    <category name="">
        <data value="" />
        <data value="" />
    </category>
    <category name="">
        <data value="" />
        <data value="" />
    </category>
</categories>

$styleId

string

Response

\Docxpresso\ODFElement

Properties

This array holds all the required style information

automaticStyles : array
static
var
access

public

static

Type(s)

array

The base font size that is used to compute relative units

baseFontSize : array
static
var
access

public

static

Type(s)

array

holds the info about an "open current break" it may be: none, line, page or column

break : string
static
var
access

public

static

Type(s)

string

this array holds all the required chart info

charts : array
static
var
access

public

static

Type(s)

array

this array holds the data parse from the config.ini file

config : array
static
var
access

public

static

Type(s)

array

keeps a reference to $this

currentDocument : \Docxpresso\CreateDocument
static
var
access

public

static

Type(s)

\Docxpresso\CreateDocument

endnote counter

currentEndnote : integer
static
var
access

public

static

Type(s)

integer

footnote counter

currentFootnote : integer
static
var
access

public

static

Type(s)

integer

reference to the current "open form"

currentForm : string
static
var
access

public

static

Type(s)

string

Specifies if the used template is a custom one or not

customTemplate : boolean
static
var
access

public

static

Type(s)

boolean

output format it may be pdf, odt, doc, docx or rtf

format : string
static
var
access

public

static

Type(s)

string

stores the document forms ids

forms : array
static
var
access

public

static

Type(s)

array

section counter

counter : integer
static
var
access

public

static

Type(s)

integer

if true the fields should be enforced to be updated

fields : boolean
static
var
access

public

static

Type(s)

boolean

stores the lists ids

list : array
static
var
access

public

static

Type(s)

array

manifest document element

manifest : \Docxpresso\DOMNode
var
access

public

Type(s)

\Docxpresso\DOMNode

stores the info about math formulas

math : array
static
var
access

public

static

Type(s)

array

stores the info about math settings for each equation

mathSettings : array
static
var
access

public

static

Type(s)

array

stores the information about master styles

masterStyles : array
static
var
access

public

static

Type(s)

array

stores the information about inserted images

media : array
static
var
access

public

static

Type(s)

array

This "array" stores the ODFElement associated with a DOMNode The DMONode is the "key" and the ODFElement is the $value

nodeMap : \Docxpresso\splObjectStorage
static
var
access

public

static

Type(s)

\Docxpresso\splObjectStorage

stores the template placeholder variables

placeholderVariables : array
static
var
access

public

static

Type(s)

array

store the section ids

sectionIds : array
static
var
access

public

static

Type(s)

array

stores the style info for headers

styleFooter : array
static
var
access

public

static

Type(s)

array

stores the style info for footers

styleHeader : array
static
var
access

public

static

Type(s)

array

stores the target document for each style it can be: document, header-footer or style

styleTarget : array
static
var
access

public

static

Type(s)

array

stores the style type possible values include: paragraph, text, table, .

styleTypes : array
static

..

var
access

public

static

Type(s)

array

This array holds all the required structural info of tha tabs inserted into the document

tabStops : array
static
var
access

public

static

Type(s)

array

This array holds all the required structural info of tha tables inserted into the document

tables : array
static
var
access

public

static

Type(s)

array

the name of the current theme if any

theme : string
static
var
access

public

static

Type(s)

string

specifies if the document contains a TOC or not

toc : boolean
static
var
access

public

static

Type(s)

boolean

unique id

unid : string
static
var
access

public

static

Type(s)

string

specifies if the document contains fields that need to be updated

updateFields : array
static
var
access

public

static

Type(s)

array

specifies if the document contains math equations that need to be updated

updateMath : array
static
var
access

public

static

Type(s)

array

hold the ids of the parsed extended HTML5 <math> tag

XMLMath : array
static
var
access

public

static

Type(s)

array

stores all the structural chart data

XMLCharts : array
static
var
access

public

static

Type(s)

array

holds the document element as an ODFElement

contentODF : \Docxpresso\ODFElement
var
access

public

Type(s)

\Docxpresso\ODFElement

holds all the XMLs and media of the document zip file

template : array
var
access

public

Type(s)

array

holds all the DOMDocument instances of the XMLs of the document

_dom : array
var
access

private

Type(s)

array

holds a reference to an instance of the styleProcessor class

_styleProcessor : \Docxpresso\StyleProcessor
var
access

private

Type(s)

\Docxpresso\StyleProcessor