Generate text watermark on PDF and Word documents
Install document-watermark via composer
$ composer require yasapurnama/document-watermark
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();
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();
Just submit pull request, your contributions are always welcomed!
This project was inspired by ajaxray's and using markpdf as depedencies.