Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 67497

inserting the watermark and printing the PDF after generating by FPDF

$
0
0

I have generated one PDF using FPDF library.Now I am not able to Get any Clue to Insert water mark Onthe PDF and Print the PDF.I tried Different method available on the ne but I m not able to achieve it any help is highlyy appreciated.Please don't downvote the question I am new to the FPDF my code for this is

<?php
require_once("includes/config.php");
//

require('C:\xampp\htdocs\geochronology\vendor\setasign\fpdf\fpdf.php');
require('C:\xampp\htdocs\geochronology\vendor\setasign\fpdi\src\autoload.php');
require('C:\xampp\htdocs\geochronology\vendor\setasign\fpdi\src\fpdi.php');

    class mypdf extends FPDF{
    function Heeader()
    {
function Header()
{
    /* Put the watermark */
    $this->SetFont('Arial','B',50);
    $this->SetTextColor(255,192,203);
    $this->RotatedText(35,190,'W a t e r m a r k   d e m o',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');
    }
    function headerTable(){
        $this->setfont('Arial','BU',14);
        $this->Ln();
        $this->cell(270,14,'List Of Records' ,0,0,'C');
        $this->Ln();
        $currentDate = date("j/n/Y");
        $this->cell(270,14,$currentDate,0,0,'R');
        $this->Ln();
        $this->Ln();
        $this->setfont('Arial','B',12);
        $this->cell(12,10,'Sl No',1,0,'L');
        $this->cell(75,10,'USER NAME' ,1,0,'c');
        $this->cell(80,10,'AFFILIATION',1,0,'c');
        $this->cell(34,10,'SAMPLE TYPE' ,1,0,'c');
        $this->cell(30,10,'SAMPLE ID',1,0,'c');
        $this->cell(50,10,'DATE',1,0,'c');
        $this->Ln();        
        }

    function viewTable(){
        $this->setfont('Arial','B',12);
        $search=$_POST['search1'];
        $option=$_POST['option1'];
        $period=$_POST['period1'];
        $datefrom=$_POST['datefrom1'];
        $dateto=$_POST['dateto1'];
        $dbh = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME,DB_USER, DB_PASS,array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));


            if($period ==null){
            $sql = "SELECT tbluser.user,tbluser.affiliation,tblfacility.type,tblfacility.sampleid,tblfacility.time,DATE_FORMAT(tblfacility.time, '%d-%m-%y') AS formatted_date 
            FROM tblfacility 
            JOIN tbluser on tbluser.id=tblfacility.user 
            where ".$search." ='".$option."'";}
            else{
            $sql="SELECT * FROM tblfacility JOIN tbluser on tbluser.id=tblfacility.user where ".$search." ='".$option."' AND time between '".$datefrom."' and '".$dateto."'";
            }
            $query = $dbh->prepare($sql);
            $query->execute();
            $results=$query->fetchAll(PDO::FETCH_OBJ);
            //echo "<prep>";
            //echo "this is the final";
            //print_r($sql);
            $i=1;           
            foreach($results as $result){
                $this->cell(12,10,$i,1,0,'L');
                $this->cell(75,10,$result->user,1,0,'L');
                $this->cell(80,10,$result->affiliation,1,0,'L');
                $this->cell(34,10,$result->type,1,0,'L');
                $this->cell(30,10,$result->sampleid,1,0,'L');
                $this->cell(50,10,$result->time,1,0,'L');
                $this->Ln();
                $i++;
            }


    }

    }
$pdf = new mypdf();
$pdf->AliasNbPages();
$pdf->AddPage('L','A4',0);
$pdf->header();
$pdf->headerTable();
$pdf->viewTable();
$pdf->footer();
$pdf->output();


?>

What may be problem with my code


Viewing all articles
Browse latest Browse all 67497

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>