mergeDocxAt
- addBackgroundImage
- addFooter
- addFooterSection
- addHeader
- addHeaderSection
- addLineNumbering
- addMacroFromDoc
- addPageBorders
- addProperties
- addSection
- createDocx
- createDocxAndDownload
- createCharacterStyle
- createListStyle
- createParagraphStyle
- createTableStyle
- docxSettings
- embedFont
- importChartStyle
- importHeadersAndFooters
- importListStyle
- importStyles
- modifyPageLayout
- parseStyles
- removeFooters
- removeHeaders
- setBackgroundColor
- setDefaultFont
- setDocumentDefaultStyles
- setEncodeUTF8
- setLanguage
- setMarkAsFinal
- setRTL
- addBibliography
- addBookmark
- addBreak
- addChart
- addCitation
- addComment
- addCrossReference
- addDateAndHour
- addEndnote
- addExternalFile
- addFootnote
- addFormElement
- addHeading
- addImage
- addLink
- addList
- addMathEquation
- addMergeField
- addOLE
- addOnlineVideo
- addPageNumber
- addShape
- addSimpleField
- addSource
- addStructuredDocumentTag
- addSVG
- addTable
- addTableContents
- addTableFigures
- addText
- addTextBox
- addWordFragment
- addWordML
- embedHTML
- clearBlocks
- cloneBlock
- deleteBlock
- getTemplateVariables
- getTemplateVariablesType
- modifyInputFields
- modifyMergeFields
- processTemplate
- removeTemplateVariable
- replaceBlock
- replaceListVariable
- replacePlaceholderImage
- replaceTableVariable
- replaceVariableByExternalFile
- replaceVariableByHtml
- replaceVariableByText
- replaceVariableByWordFragment
- replaceVariableByWordML
- setTemplateSymbol
- setTemplateBlockSymbol
- tickCheckboxes
mergeDocxAt


Merges Word documents after a specific position.
This method allows the full merging of DOCX documents after a specific position.
The merging process preserves all contents without internal/external dependencies: paragraphs, tables, bookmarks, run-of-text, text boxes, fields, shapes...
The merging process also preserves the following contents that include internal/external dependencies:
- styles
- images
- charts
- links and cross-references
- lists
- altChunk contents
- footnotes and endnotes
- comments
- OLE objects
- sections with their corresponding headers and footers (optional)
firstDocument
The path to the first Word document to merge.
documentArray
Paths array of the Word documents to merge.
finalDocument
The destination path of the merged file.
referenceNode
An array to get the refence node.
The possible keys and values of this array are:
Key | Type | Description |
---|---|---|
type | string | * (all, default value), bookmark, break, chart, endnote (content reference), footnote (content reference), image, list, paragraph (also for links and lists), section, shape, table. |
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. |
options
The possible keys and values are (required options are shown with yellow background):
Key | Type | Description |
---|---|---|
mergeType | int | The possible values are:
If the mergeType equals 1 or the last section of the first document is of the "continuous" type, there may be some missalignment of absolutely positioned content in the merged document. This is due to the fact that the absolute positioned content of the second document was layed out with respect the second document page distribution that may change after the merging. |
enforceSectionPageBreak | bool | Enforces a page section break between documents even if the first section type of the merged document is of the continuous type. |
numbering | string | The possible values are:
|
lineBreaks | int | Inserts the indicated number of line breaks between the contents of the merging files. |
forceLatestStyles | bool | Keeps the last merged document styles, overwriting the previous styles. |
renameStyles | bool | If true, rename styles of the DOCX to be merged with unique names to keep them. False as default. |
Error while trying to open the (base) template as a zip file.
Example #1: