PHP code example of yasapurnama / document-watermark

1. Go to this page and download the library: Download yasapurnama/document-watermark library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yasapurnama / document-watermark example snippets


$wordWatermark = WatermarkFactory::load(__DIR__ . '/files/word-sample.docx')
                            ->subDirectory('watermark')
                            ->setText('Last update on ' . date('m/d/Y'))
                            ->generate();

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

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

$pdfWatermark  = WatermarkFactory::load(__DIR__ . '/files/pdf-sample.pdf')
    ->outputFile(__DIR__ . '/files/watermark/pdf-image-stamp.pdf')
    ->setImage(__DIR__ . '/files/stamp.png')
    ->generate();