Created
January 31, 2020 11:12
-
-
Save Guley/6f3656770281170f04fd8b03d9ad768b to your computer and use it in GitHub Desktop.
Tcpdf add custom text watermark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require('Pdf.php'); | |
class PDF_Rotate extends Pdf | |
{ | |
var $angle=0; | |
function Header() | |
{ | |
//Put the watermark | |
$this->SetFont('','B',40); | |
$this->SetTextColor( 165, 203, 73 ); | |
$this->RotatedText(10,190,'It is under comapny name proprietor. ',45); | |
} | |
function Rotate($angle,$x=-1,$y=-1) | |
{ | |
if($x==-1) | |
$x=$this->x; | |
if($y==-1) | |
$y=$this->y; | |
if($this->angle!=0) | |
$this->_out('Q'); | |
$this->angle=$angle; | |
if($angle!=0) | |
{ | |
$angle*=M_PI/180; | |
$c=cos($angle); | |
$s=sin($angle); | |
$cx=$x*$this->k; | |
$cy=($this->h-$y)*$this->k; | |
$this->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',$c,$s,-$s,$c,$cx,$cy,-$cx,-$cy)); | |
} | |
} | |
function RotatedText($x, $y, $txt, $angle) | |
{ | |
//Text rotated around its origin | |
$this->Rotate($angle,$x,$y); | |
$this->Text($x,$y,$txt); | |
$this->Rotate(0); | |
} | |
function _endpage() | |
{ | |
if($this->angle!=0) | |
{ | |
$this->angle=0; | |
$this->_out('Q'); | |
} | |
parent::_endpage(); | |
} | |
} | |
$pdf= new PDF_Rotate(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where is 'Pdf.php ?