Cookbook
- Learn phpdocx in 5 minutes
- Tutorial
- API quick guide
- HTML to Word
- HTML Extended
- Conversion plugin
- Word to HTML
- DOCXPath
- Bulk processing
- DOCXCustomizer
- Digital signature
- Cryptophpdocx
- Right to left languages
- phpdocx CLI command
- Tracking
- Artificial Intelligence
- Blockchain for documents
- JavaScript API
- Compiled mode
In-memory DOCX documents
phpdocx Premium licenses include support for in-memory documents. Thanks to this functionality it is possible to work without files in the fs. Instead, you can use in memory objects or from other sources like databases, in-memory data structures, redis… This also enables better performance and flexibility of use.
DOCXStructure is the class that serves as an in-memory DOCX in phpdocx. An object of that class can be generated on the fly with CreateDocx and the static attribute $returnDocxStructure:
Or from an existing file, using the DOCXStructure class:
Or from any valid stream with the DOCXStructureFromStream class, e.g. an URL:
DOCXStructure can be easily serialized: Serializing templates for later reuse. For example, as a template to generate new documents:
The classes and methods that support in-memory DOCX are the following:
- CreateDocxFromTemplate
- docx2txt
- changeStatusComments
- generateDigestDOCX
- Indexer
- importContents
- importHeadersAndFooters
- importListStyle
- importStyles
- mergeDocx
- mergeDocxAt
- modifyDocxSettings
- optimizeDocx
- optimizeTemplate
- parseCheckboxes
- protectDOCX
- rawSearchAndReplace
- removeChapter
- removeLineNumbering
- removeSection
- replaceChartData
- searchAndColor
- searchAndHighlight
- searchAndRemove
- searchAndReplace
- setLineNumbering
- sign (DOCX)
- splitDocx
- TransformDocAdvHTML
- TransformDocAdvPDF
- watermarkDocx
- watermarkRemove
There are many examples available in the directory 'examples' of the Premium package to illustrate its use.
DOCXStructure objects should not be confused with the phpdocx stream mode. The latter generates and returns automatically the DOCX file, but it doesn't allow storing it unless its output is captured. That's why it is useful for specific purporses as generating and downloading DOCX without being neccesary its later reuse.