dinesh
dinesh

Reputation: 342

how create a PDF with series of images each printed on new page into a single file using FPDF

I need to create a pdf file which will have series of images, where each image will be on new page. How do I do this using FPDF? When I try to create pdf, FPDF creates pdf file with just one image. How do I pass image names array into FPDF and get all images printed as a single file with each image on new page.

Upvotes: 1

Views: 1203

Answers (1)

Adnan
Adnan

Reputation: 26350

Here it is, this will display each image in the array on a new page, all inside one file:

$pdf=new PDF();
$images = array("image1.jpg", "image2.jpg", "image3.jpg"); 

reset($images);
while (list(, $image) = each($images)) {
    $pdf->AddPage();
    $pdf->Image($image,10,8,33);
}

$pdf->Output();

For the reference on how the Image() works, and what type of parameters it can take reference to this link

Upvotes: 6

Related Questions