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
How to add watermarks and background images
Word allows to add watermarks and backgrounds to a page. Each of them has its own strenghts and weaknesses. The main difference between these two formats is that a background doesn't appear in PDFs nor in print copies, while the watermark does.
phpdocx supports them both.
Add a background image in documents
The addBackgroundImage method lets you place a background image that covers the whole page. If the image doesn't cover it entirely, the method repeats it as many times as necessary to fill the page.
To insert a background image, run the following code:
Insert a watermark to a DOCX (Advanced and Premium licenses only)
The DocxUtilities class includes the watermarkDocx method, that places a watermark with an image format to a page. The image that works as a watermark keeps its original size and doesn't repeat itself along the page like the images added using the addBackgroundImage method.
You can place a watermark with this code:
Beside images, the watermarkDocx method also allows to add texts as watermarks.
Insert a watermark to a PDF (Advanced and Premium licenses only)
The DocxUtilities class includes the watermarkPdf method, to insert a watermark image or text in PDF documents.
You can place a watermark with this code:
Beside images, the watermarkPdf method also allows to add texts as watermarks.
