Skip to content

Generate text watermark on PDF and Word documents using PHP

License

Notifications You must be signed in to change notification settings

yasapurnama/document-watermark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Document Watermark

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.