Search code examples
phpfpdf

how to add more than one image in pdf file using fpdf


<?php 
include 'connection/dbconnect.php';
$id = $_GET['id'];
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->Image('new/'.$id.'/1.png',10,10,-220);
$pdf->Output(); $pdf1->AddPage();
$pdf1->Image('new/'.$id.'/1.png',10,10,-220);
$pdf1->Output(); 
?>

Here I want to add more than one image in pdf file using fpdf. For that I write this code but it displaying only one image. Can anyone tell me what is the problem in my code.


Solution

  • The Solution on This Problem is

    <?php
    include 'connection/dbconnect.php';
    $id = $_GET['id'];
    require('fpdf.php');
    $pdf = new FPDF();
    $pdf->AddPage();
    $pdf->Image('new/'.$id.'/1.png',10,10,-220);
    $pdf->SetAutoPageBreak(true);
    $pdf->AddPage();
    $pdf->Image('new/'.$id.'/2.png',10,10,-220);
    $pdf->Output(); 
    ?>