yasapurnama/document-watermark

Generate text watermark on PDF and Word documents with PHP

v1.0.1 2022-03-07 14:19 UTC

This package is auto-updated.

Last update: 2024-11-07 20:34:50 UTC


README

Latest Stable Version Total Downloads License

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();

example-word-watermark

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();

example-pdf-watermark

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();

example-word-image-stamp

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();

example-pdf-image-stamp

Contribute

Just submit pull request, your contributions are always welcomed!

Credits

This project was inspired by ajaxray's and using markpdf as depedencies.