Merge Images to PDF in PHP
Place multiple images on separate slides and export them as a single PDF document with Aspose.Slides for PHP via Java.
Merge Images to PDF using Aspose.Slides
Aspose.Slides for PHP via Java lets you place each source image on a separate presentation slide and export all the slides as a single multi-page PDF document.
Merge Images to PDF in PHP
Load each source file with Images::fromFile, add a slide with addEmptySlide, place the image with addPictureFrame, and call save with SaveFormat::Pdf.
PHP code for merging images into PDF
$presentation = new Presentation();
try {
$presentation->getSlides()->removeAt(0);
$layoutSlide = $presentation->getLayoutSlides()->get_Item(0);
$imagePaths = ["image1.png", "image2.jpg"];
foreach ($imagePaths as $imagePath) {
$slide = $presentation->getSlides()->addEmptySlide($layoutSlide);
$sourceImage = Images::fromFile($imagePath);
try {
$presentationImage = $presentation->getImages()->addImage($sourceImage);
} finally {
$sourceImage->dispose();
}
$slide->getShapes()->addPictureFrame(
ShapeType::Rectangle, 0, 0, 720, 540, $presentationImage);
}
$presentation->save("merged-images.pdf", SaveFormat::Pdf);
} finally {
$presentation->dispose();
}
How to merge images to PDF in PHP
Install Aspose.Slides for PHP via Java. See Installation .
Configure Aspose.Slides in your PHP project.
Create a
Presentation, remove its default slide, and access a layout slide.Load each source image with
Images::fromFile, add an empty slide withaddEmptySlide, and place the image withaddPictureFrame.Save the presentation with
SaveFormat::Pdf.
Merge Images Online
Merge Other Files
You can also combine files in other supported formats.