Create watermark for pdf using php ?


                                 Create watermark for pdf in php ?
       
                           Today I am writing about watermark for pdf. If you want to create watermark for your pdf then you can follow below code. In my previous posts I have shown you how to generate pdf using your own helper file. I have used mpdf and dom-pdf to generate pdf. So here I am going to show you “ How to generate pdf with watermark “.
Just add below code to generate pdf with watermark.
Method 1 :
<?php
//Generate pdf using mpdf
                $obj_mpdf = new mPDF();
                $obj_mpdf ->SetWatermarkText(“ Sample Watermark”);
                $obj_mpdf ->watermark_font = “Font Name”;
                $obj_mpdf ->showWatermarkText = true;

If You want to add image as your watermark then use below line

$obj_mpdf ->SetWatermarkImage(“/image/personal.jpg ”);
$obj_mpdf ->showWatermarkImage = true;
            $obj_mpdf ->WriteHTML(“ Your HTML Part ”);
?>
Method 2:
You can create a div and set the image for the div. using style sheet make your image opticity 0.1. Have a look on below code.
<style type=”text/css”>
          #watermark { position: fixed; bottom: 0px; right: 0px; width: 180px; height: 180px; opacity: .1; }
</style>
<div id="watermark"><img src="personal.jpg" width="100%"></div>

   Hope this post will help you to create watermark for your pdf. Keep visiting for new posts here. All the best. Have a good day. 





Follow Us On Facebook Open Source Web Developers by Appsntech facebook group Twitter Open Source Web Developers by Appsntech twitter group Google+ Open Source Web Developers by Appsntech Google group Linkedin Open Source Web Developers by Appsntech, LinkedIn group
Copyright @2011-2015 appsntech.com. All rights reserved. Powered By- Sanjoy Dey Productions