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
Clean blocks placeholders
phpdocx includes several methods to work with block elements. These elements allow to define regions made of one or more contents in a DOCX, which can be cleaned of placeholders, deleted and cloned.
You can replace any placeholder in a region defined by placeholders. To do it just run the template methods of phpdocx or DOCXPath, just like you would do with any other placeholder or content in the document.
The advantage of blocks is that after working with a document you can call the clearBlocks method to delete all placeholders of the block kind. The content of these placeholders would be unaltered.
For example, the following code substitutes an existing placeholder in a document inside of a region delimited by blocks. Then the code deletes from template.docx all block placeholders.