I am trying to put a Watermark on the PDF it is working fine for a single page but the when the content is multiple page it puts the water mark on the first page only .how can I put this watermark in every page. Is it possible to insert an image instead of text in FPDF.Any help will be highly appreciable.
class PDF_Rotate extends FPDF
{
var $angle=0;
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 _endpage()
{
if($this->angle!=0)
{
$this->angle=0;
$this->_out('Q');
}
parent::_endpage();
}
}
class mypdf extends PDF_Rotate{
function Header1()
{
/* Put the watermark */
$this->SetFont('Arial','B',50);
$this->SetTextColor(225,225,225);
$this->RotatedText(35,190,'I U A C',45);
//$this->RotatedText(135,190,'I U A C',45);
$this->RotatedText(235,190,'I U A C',45);
$this->RotatedText(95,160,'GEOCHRONOLOGY',45);
$this->RotatedText(65,70,'I U A C',45);
//$this->RotatedText(135,60,'I U A C',45);
$this->RotatedText(235,70,'I U A C',45);
}
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 Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(179);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Text color in gray
$this->SetTextColor(128);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
$pdf = new mypdf();
$pdf->AliasNbPages();
$pdf->AddPage('L','A4',0);
$pdf->Header1();
$pdf->headerTable();
$pdf->viewTable();
$pdf->footer();
$pdf->output();
Extending on what Shubham Baranwal and Dave told you... You should add the Header method to your "PDF_Rotate" class and inside that method is where you will add the watermark.
As far as i can see you have a method called Header1 just rename it to Header.
Also for inserting an image it should be the same process, just add an image in the Header method and it'll be replicated.