yasapurnama / document-watermark
Generate text watermark on PDF and Word documents with PHP
v1.0.1
2022-03-07 14:19 UTC
Requires
- phpoffice/phpword: ^0.18.2
- yasapurnama/php-shellrotation: ^1.0
README
Generate text watermark on PDF and Word documents
Installation
Install document-watermark via composer
$ composer require yasapurnama/document-watermark
Examples
Generate word document watermark. Using default section footer
, text align right
, font color 000000
and font size 10
$wordWatermark = WatermarkFactory::load(__DIR__ . '/files/word-sample.docx') ->subDirectory('watermark') ->setText('Last update on ' . date('m/d/Y')) ->generate();
Generate PDF watermark with custom options
$pdfWatermark = WatermarkFactory::load(__DIR__ . '/files/pdf-sample.pdf') ->subDirectory('watermark') ->setText('Last update on ' . date('m/d/Y')) ->sectionHeader() ->alignRight() ->fontSize(9) ->fontColor('ff0000') ->generate();
Image watermark
Generate word document watermark using image at footer, with page margins x=1 y=1, align right, only in first page
$wordWatermark = WatermarkFactory::load(__DIR__ . '/files/word-sample.docx') ->outputFile(__DIR__ . '/files/watermark/word-image-stamp-custom.docx') ->setImage(__DIR__ . '/files/stamp.png') ->sectionFooter(1, 1) ->alignRight() ->onlyFirstPage() ->generate();
Generate pdf document watermark using image with default values
$pdfWatermark = WatermarkFactory::load(__DIR__ . '/files/pdf-sample.pdf') ->outputFile(__DIR__ . '/files/watermark/pdf-image-stamp.pdf') ->setImage(__DIR__ . '/files/stamp.png') ->generate();
Contribute
Just submit pull request, your contributions are always welcomed!
Credits
This project was inspired by ajaxray's and using markpdf as depedencies.