JSON API - replaceVariableByText

replaceVariableByText

PREMIUM TRIAL / ADVANCED

Replaces placeholder variables by text.

Note

You are reading the JSON API documentation. For the PHP API method please go to replaceVariableByText.

JSON data
Key Description
variables The names of the placeholder template variables as keys and the plain text 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.
parseLineBreaks If true (default is false) parses the line breaks to include them in the Word document.
target Possible values are: document (default), header, footer, footnote, endnote, comment. This option sets the scope of the replacement procedure.
raw if true (default is false) replaces the variable by a string regardless the variable scope (tag values, attributes...). Only allows to replace a variable by a plain string. Use with caution.
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.