optimizeDocx
- 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
optimizeDocx
ADVANCED / PREMIUM
TRIAL
Optimizes a DOCX.
Description
public optimizeDocx (string $source, string $target, [, array $options])
This method optimizes DOCX documents.
Parameters
source
The path to the source Word document.
target
The path to the Word document output.
options
The possible keys and values are:
Key | Type | Description |
---|---|---|
extraAttributes | bool | Remove not needed attributes in the XML files. Default as false. |
imageFiles | bool | Optimize image files. Default as true. |
imageFilesToJpegLevel | int | Optimize all image files transforming them to jpeg. Default as null, set quality value (70, 90...). |
unusedFiles | bool | Remove unused files. Default as false. |
xmlFiles | bool | Optimize XML files. Default as true. |
Exceptions
Error while trying to open the (base) template as a zip file.
Code samples
Example #1
Release notes
- phpdocx 14.0:
- unusedFiles option.
- removed the compressionMethod option.
- DOCXStructure and in-memory DOCX documents.
- return DOCXStructure.
- phpdocx 8.5:
- new method.