JSON API - replaceVariableByWordFragment
- addBarcode
- addBookmark
- addBreak
- addCaption
- addChart
- addComment
- addCrossReference
- addDateAndHour
- addDropCap
- addEndnote
- addExternalFile
- addFootnote
- addFormElement
- addHeading
- addImage
- addLink
- addList
- addMathEquation
- addMergeField
- addPageNumber
- addRuby
- addSimpleField
- addStructuredDocumentTag
- addSVG
- addTab
- addTable
- addTableContents
- addTableFigures
- addText
- addTextBox
- addWordML
- addWordFragment
- embedHTML
- addBackgroundImage
- addFooter
- addFooterSection
- addHeader
- addHeaderSection
- addLineNumbering
- addPageBorders
- addProperties
- addSection
- createCharacterStyle
- createListStyle
- createParagraphStyle
- createTableStyle
- docxSettings
- embedFont
- modifyPageLayout
- removeFooters
- removeHeaders
- setBackgroundColor
- setCompatibilityMode
- setDefaultFont
- setDocumentDefaultStyles
- setLanguage
- setMarkAsFinal
- setRTL
- clearBlocks
- cloneBlock
- deleteBlock
- getTemplateVariables
- getTemplateVariablesType
- modifyInputFields
- modifyMergeFields
- processTemplate
- removeTemplateVariable
- removeTemplateVariableImage
- replaceBlock
- replaceListVariable
- replacePlaceholderImage
- replaceTableVariable
- replaceVariableByExternalFile
- replaceVariableByHTML
- replaceVariableByText
- replaceVariableByWordFragment
- replaceVariableByWordML
- setTemplateSymbol
- setTemplateBlockSymbol
- tickCheckboxes
replaceVariableByWordFragment
PREMIUM
TRIAL / ADVANCED
Replaces placeholder variables by fragments of Word.
Note
You are reading the JSON API documentation. For the PHP API method please go to replaceVariableByWordFragment.
JSON data
| Key | Description |
|---|---|
| variables | The names of the placeholder template variables as keys and the WordFragments that should replace them as values. |
| firstMatch | If the variable appears more than once within the Word document and firstMatch is set to true, phpdocx will only replace the first occurrence of the variable within the Word document. |
| stylesReplacementType |
Empty as default.
|
| stylesReplacementTypeIgnore | Styles to be ignored from the imported WordFragment. Use with mixPlaceholderStyles. Empty as default. |
| stylesReplacementTypeOverwrite | If true, WordFragment styles overwrite placeholder styles with the same name that are not set in the stylesReplacementTypeIgnore option. Use with mixPlaceholderStyles. Default as false. Only available in Premium licenses. |
| target | Possible values are: document (default), header, footer, footnote, endnote, comment. This option sets the scope of the replacement procedure. |
| type | Possible values are:
|
Code samples
Example #1
A template can be a local file, a Base64 string, or a remote file.
Release notes
- phpdocx 18.0:
- new action.
