PHP 7 FPDF Example to Insert Multiple Images Inside Grid or Graph Layout in PDF Document Using Javascript

You are currently viewing PHP 7 FPDF Example to Insert Multiple Images Inside Grid or Graph Layout in PDF Document Using Javascript

PHP 7 FPDF Example to Insert Multiple Images inside Grid or Graph Layout in PDF Document Using Javascript

<?php
require('fpdf.php');
 
class PDF_Grid extends FPDF {
    var $grid = false;
 
    function DrawGrid()
    {
        if($this->grid===true){
            $spacing = 5;
        } else {
            $spacing = $this->grid;
        }
        $this->SetDrawColor(204,255,255);
        $this->SetLineWidth(0.35);
        for($i=0;$i<$this->w;$i+=$spacing){
.medrectangle-3-multi-320{border:none!important;display:block;float:none;line-height:0;margin-bottom:15px!important;margin-left:auto!important;margin-right:auto!important;margin-top:15px!important;max-width:100%!important;min-height:250px;min-width:250px;padding:0;text-align:center!important;width:100%}            $this->Line($i,0,$i,$this->h);
        }
        for($i=0;$i<$this->h;$i+=$spacing){
            $this->Line(0,$i,$this->w,$i);
        }
        $this->SetDrawColor(0,0,0);
 
        $x = $this->GetX();
        $y = $this->GetY();
        $this->SetFont('Arial','I',8);
        $this->SetTextColor(204,204,204);
        for($i=20;$i<$this->h;$i+=20){
            $this->SetXY(1,$i-3);
            $this->Write(4,$i);
        }
        for($i=20;$i<(($this->w)-($this->rMargin)-10);$i+=20){
            $this->SetXY($i-1,1);
            $this->Write(4,$i);
        }
        $this->SetXY($x,$y);
    }
 
    function Header()
    {
        if($this->grid)
            $this->DrawGrid();
    }
}
?>

<?php
require('grid.php');
 
$pdf = new PDF_Grid();
 
// Add page with a grid and default spacing (5mm)
$pdf->grid = true;
$pdf->AddPage();
 
// Add page with a grid (10mm spacing)
$pdf->grid = 10;
$pdf->AddPage();
 
// Disable grid
$pdf->grid = false;
$pdf->AddPage();
 
$pdf->Output();
?>

Ranjith

Hi, I'm Manoj a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply