addComment
- 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
- addTab
- addTable
- addTableContents
- addTableFigures
- addText
- addTextBox
- addWordFragment
- addWordML
- embedHTML
- addBackgroundImage
- addFooter
- addFooterSection
- addHeader
- addHeaderSection
- addLineNumbering
- addMacroFromDoc
- addPageBorders
- addProperties
- addSection
- createDocx
- createDocxAndDownload
- createCharacterStyle
- createListStyle
- createParagraphStyle
- createTableStyle
- docxSettings
- embedFont
- importChartStyle
- importHeadersAndFooters
- importListStyle
- importStyles
- importStylesWordDefault
- modifyPageLayout
- parseStyles
- removeFooters
- removeHeaders
- setBackgroundColor
- setDecimalSymbol
- setDefaultFont
- setDocumentDefaultStyles
- setEncodeUTF8
- 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
addComment
TRIAL / ADVANCED / PREMIUM
Inserts a comment into the Word document.
Description
public addComment ( array $options )
This method allows the insertion of a Word comment into the current Word document.
You may fully customize the comment content including all kind of elements like paragraphs of text with sophisticated formatting, images, links or even tables and HTML content.
If one wishes to insert a comment within a complex paragraph one should use this method in combination with the addText method.
Parameters
options
An array with the available options.
The possible keys and values of this array are (required options are shown with yellow background):
key | Type | Description |
---|---|---|
textDocument | mixed | This can be a string of text or a WordFragment that will appear in the Word document highlighted or an array with the text and the formatting options (as in the addText method) or a Word fragment. |
textComment | mixed | This is a string of text that will show up in the corresponding footnote or a WordFragment that may include a variety of elements. |
textComments | array | Add multiple comments. |
initials | string | The initial that will be shown in the comment balloon. |
author | string | The name of the author of the comments. |
date | string | A date string as the ones used for the strtotime PHP method. |
completed | bool | False as default, sets the comment as completed. Compatible with MS Word 2013 or newer. |
paraId | string (HEX value) | If null, auto generate it. Comment ID. |
pStyle | string | Paragraph style. Default as CommentTextPHPDOCX. |
rStyle | string | Character style. Default as CommentReferencePHPDOCX. |
Code samples
Release notes
- phpdocx 14.5:
- internal IDs set using sequential unique values.
- phpdocx 13.5:
- WordFragments in textDocument.
- pStyle and rStyle options.
- phpdocx 12.5:
- multiple comments in the same content.
- phpdocx 12.0:
- htmlspecialchars applied in textComment, initials and author options.
- phpdocx 8.5:
- completed option.