protectDOCX
- 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
protectDOCX
Password protects the contents of a Word document.
This method allows to password protect a Word document. One may protect in read only mode or allow the final user to modify comments or form elements.
Notice that this method does not encrypt the contents of the Word document, only protects them from unauthorized modifications. This method is not secure and can be easily overriden by an experienced user.
You may find a detailed description of this package in the cryptophpdocx section of the API documentation.
source
Path to the word document you want to protect.
target
Path to the resulting protected document.
options
The possible keys and values are (required options are shown with yellow background):
Key | Type | Description |
---|---|---|
password | string | The password should be a string of 15 or less characters. If you introduce a password with more than 15 characters it will be automatically truncated. |
type | string | Available protection types:
|
overwrite | bool | True or false. If true (default value) overwrites the existing protection if it exists. |
Incorrect protection type.
Password not set.
Document already protected.
- phpdocx 13.0:
- in-memory DOCX documents.