mergeDocxAt
- addBackgroundImage
- addFooter
- addHeader
- addLineNumbering
- addPageBorders
- addProperties
- addSection
- createDocx
- createCharacterStyle
- createListStyle
- createParagraphStyle
- createTableStyle
- docxSettings
- embedFont
- importHeadersAndFooters
- importStyles
- modifyPageLayout
- 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
- addPageNumber
- addShape
- addSimpleField
- addSource
- addStructuredDocumentTag
- addTable
- addTableContents
- addText
- addTextBox
- addWordML
- embedHTML
- clearBlocks
- deleteTemplateBlock
- getTemplateVariables
- getTemplateVariablesType
- modifyInputFields
- modifyMergeFields
- processTemplate
- removeTemplateVariable
- replaceListVariable
- replacePlaceholderImage
- replaceTableVariable
- replaceVariableByExternalFile
- replaceVariableByHtml
- replaceVariableByText
- replaceVariableByWordFragment
- replaceVariableByWordML
- setTemplateSymbol
- tickCheckbox
mergeDocxAt
ADVANCED / PREMIUM
BASIC
Merges Word documents after a specific position.
Description
public void mergeDocxAt(ArrayList documents, String target, OptionsDOCXPath referenceNode) throws Exception
public void mergeDocxAt(ArrayList documents, String target, OptionsDOCXPath referenceNode, Integer mergeType) throws Exception
public void mergeDocxAt(ArrayList documents, String target, OptionsDOCXPath referenceNode, Integer mergeType, Boolean enforceSectionPageBreak) throws Exception
public void mergeDocxAt(ArrayList documents, String target, OptionsDOCXPath referenceNode, Integer mergeType, Boolean enforceSectionPageBreak, String numbering) throws Exception
public void mergeDocxAt(ArrayList documents, String target, OptionsDOCXPath referenceNode, Integer mergeType, Boolean enforceSectionPageBreak, String numbering, Integer lineBreaks) throws Exception
public void mergeDocxAt(ArrayList documents, String target, OptionsDOCXPath referenceNode, Integer mergeType, Boolean enforceSectionPageBreak, String numbering, Integer lineBreaks, Boolean preserveStyleDefaults) throws Exception
This method allows the full merging of DOCX documents.
The merging process preserves:
- styles
- images
- charts
- links and cross-references
- lists
- altChunk contents
- footnotes and endnotes
- comments
- OLE objects
- sections with their corresponding headers and footers (optional)
Parameters
documents
Word documents to merge.
target
The destination path of the merged file.
referenceNode
Option | 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. |
contains | String | Contains a text string. |
occurrence | String | Exact occurrence or range of contents (e.g.: 2..9, 2.., ..9) or first() or last(). If empty iterate all elements. |
attributes | HashMap<String, String> | 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 | String | after (default) or default. |
mergeType
"0", preserves the sections of the merged document with their respective headers and footers. "1", merges the contents at the end of the last section of the first document.
enforceSectionPageBreak
Enforces a page section break between documents even if the first section type of the merged document is of the continuous type.
numbering
The destination path of the merged file.
lineBreaks
Inserts the indicated number of line breaks between the contents of the merging files.
Code samples
Example #1: