cloneWordContent

cloneWordContent

ADVANCED / PREMIUM TRIAL

Clones contents in the document.

Description
public cloneWordContent (array $referenceToBeCloned, array $referenceNodeTo, [string $location, bool $forceAppend])
Parameters

referenceToBeCloned

An array to get the refence node to be cloned.
The possible keys and values of this array are:

Key Type Description
type string * (all, default value), break, chart, endnote (content reference), footnote (content reference), image, list, paragraph (also for bookmarks, links and lists), section, shape, table, table-row, table-cell, table-cell-paragraph.
contains string Contains a text string.
occurrence int or string Exact occurrence (int) or range of contents (e.g.: 2..9, 2.., ..9) (string) or first() or last(). If empty iterate all elements.
attributes array Contains a specific attribute key and value.
parent string Main document body as default, allows to set any parent or a specific one. w:body (default), '/' (any parent) or any other specific parent (/w:tbl/, /w:tc/, /w:r/...).
customQuery string Custom xpath query, overwrites any other reference.

referenceNodeTo

An array to get the destination refence node.
The possible keys and values of this array are:

Key Type Description
type string * (all, default value), break, chart, endnote (content reference, the whole paragraph is removed), footnote (content reference, the whole paragraph is removed), image, list, paragraph (also for bookmarks, links and lists), section, shape, table, table-row, table-cell, table-cell-paragraph.
contains string Contains a text string.
occurrence int Exact occurrence (int) or range of contents (e.g.: 2..9, 2.., ..9) (string) or first() or last(). If empty iterate all elements.
attributes array Contains a specific attribute key and value.
parent string Main document body as default, allows to set any parent or a specific one. w:body (default), '/' (any parent) or any other specific parent (/w:tbl/, /w:tc/, /w:r/...).
customQuery string Custom xpath query, overwrites any other reference.

location

After (default) or before.

forceAppend

If true appends the WordFragment if the reference node could not be found (false as default).

Exceptions

Method not available.

Code samples

Example #1

Release notes
  • phpdocx 15.0:
    • table-row, table-cell and table-cell-paragraph types.
  • phpdocx 14.0:
    • generate new id and name attributes for drawing object non-visual property tags.
  • phpdocx 12.0:
    • improved working with multiple sections that contain multiple headers and footers.
  • phpdocx 8.2:
    • improved performance.
  • phpdocx 7.0:
    • range of elements, iterate all elements not only the first one, siblings.
  • phpdocx 6.5:
    • new method.