encryptDOCX
- 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
encryptDOCX
PREMIUM
TRIAL / ADVANCED
Encrypts a Word document.
Description
public encryptDOCX (string $source, string $target, array $options)
This method allows to encrypt a Word document. The final user needs to insert the password included in the options array to access the content of the resulting file.
The encrypted file is a Microsoft Binary Compound File that is directly recognized as an encrypted Word document by the standard Word interface.
Parameters
source
Path to the Word document that you want to encrypt.
target
Path to the resulting encrypted 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. |
Exceptions
File does not exist.
Password not set.
Release notes
- phpdocx 15.0:
- supported files bigger than 6.5MB.
- phpdocx 13.0:
- removed external files.
- phpdocx 9.0:
- AES-256-CBC to get the cipher iv length.
- phpdocx 8.2:
- OpenSSL support.
- replaced mcrypt methods with OpenSSL methods.