Searching for mPdf Code Example to convert multiple images into a single Pdf. but I failed. Anyone having any code example or link to read please suggest. Thanks in advance.
<?php
require_once("mpdf60/mpdf.php");
$imageStorage='';
$p1=$_FILES['p1']['name'];
$p1Temp=$_FILES['p1']['tmp_name'];
$p2=$_FILES['p2']['name'];
$p2Temp=$_FILES['p2']['tmp_name'];
$p3=$_FILES['p3']['name'];
$p3Temp=$_FILES['p3']['tmp_name'];
$p4=$_FILES['p4']['name'];
$p4Temp=$_FILES['p4']['tmp_name'];
$imageStorage=$_FILES['p1']['tmp_name'],$_FILES['p2']['tmp_name'],$_FILES['p3']['tmp_name'];,$_FILES['p4']['tmp_name'];
class PDF extends MPDF {
const DPI = 96;
const MM_IN_INCH = 25.4;
const A4_HEIGHT = 297;
const A4_WIDTH = 210;
// tweak these values (in pixels)
const MAX_WIDTH = 800;
const MAX_HEIGHT = 500;
function pixelsToMM($val) {
return $val * self::MM_IN_INCH / self::DPI;
}
function resizeToFit($imgFilename) {
list($width, $height) = getimagesize($imgFilename);
$widthScale = self::MAX_WIDTH / $width;
$heightScale = self::MAX_HEIGHT / $height;
$scale = min($widthScale, $heightScale);
return array(
round($this->pixelsToMM($scale * $width)),
round($this->pixelsToMM($scale * $height))
);
}
function centreImage($img) {
list($width, $height) = $this->resizeToFit($img);
$this->Image(
$img, (self::A4_HEIGHT - $width) / 2,
(self::A4_WIDTH - $height) / 2,
$width,
$height
);
}
}
$pdf = new PDF();
$pdf->AddPage("L");
$pdf->centreImage($imageStorage);
$pdf->Output();
?>
Here is the code i tried.But Failed