Download the PHP package stejaysulli/php-word-cat without Composer
On this page you can find all versions of the php package stejaysulli/php-word-cat. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download stejaysulli/php-word-cat
More information about stejaysulli/php-word-cat
Files in stejaysulli/php-word-cat
Package php-word-cat
Short Description Library to manipulate docx files
License LGPL-3.0-only
Informations about the package php-word-cat
WordCat
Limited manipulation of docx word processed documents
A simple php library for manipulation of docx word processed document; in particular the library is designed to allow content from one document to be inserted into another document, and it also provides some features allowing for searching and replacing content, and inserting new text and images.
Dependencies
This library requires DOMDocument
and SimpleXML
.
Features
This library was designed to solve some fairly specific issues I was having with (mentioning no names) another popular PHP library when creating new documents from a given template; As such there are a lot of features that simply aren't implemented as I have had no need for them. I have added a "limitations" section below to list particularly glaring features which you may want but are missing, but if a feature you want isn't in the bullet list below, take it as read that the library won't do it for you!
- Open a docx document
- Extract and read XML files from the document
- Write XML files to the document
- Manipulate XML within the document's files
- Save docx, either overwriting the original file or as a new document
- Search for text, either as a binary/plain text search or regular expression
- Replace text, either as a binary/plain text search or regular expression
- Insert paragraphs containing plain text
- Insert image files with a specified size (aspect ratio is preserved while constraining the image within the specified size)
- Insert the contents of one docx into another
Limitations
As this library was designed to solver some fairly specific issues, it will not do a lot of things you may require; I may or may not come to add features
- You cannot create a new document from scratch; you need to load an existing docx file to work on
- The library is naive; most operations require some knowledge of the internal XML structure of docx files
- The abstractions provided are designed to perform specific tasks (see tests/example.php to get a feel for this); to be more suitable for general use they will likely need breaking changes so make sure you lock to a specific version if you're using this library now!
Installation
You can install this library using composer:
It should be possible to use the library without composer, but this has not been tested and you will need to provide your own method to autoload the files in the src
directory.
Usage
A nice example of all the basic features are available in tests/example.php - It is adviseable to check that out for proper usage details. Just so you can get a feel for the kind of code you'll be writing with WordCat, here's a brief example though: