Merge PNG Images to PDF in PHP
Arrange PNG images on a slide and export the result as PDF with Aspose.Slides for PHP via Java.
Merge PNG to PDF in PHP
Load the source files with Images::fromFile, add them to the slide with addPictureFrame, and save the presentation with SaveFormat::Pdf.
PHP code for merging PNG to PDF
$presentation = new Presentation();
try {
$slide = $presentation->getSlides()->get_Item(0);
$firstSourceImage = Images::fromFile("image1.png");
try {
$firstPresentationImage = $presentation->getImages()->addImage($firstSourceImage);
} finally {
$firstSourceImage->dispose();
}
$secondSourceImage = Images::fromFile("image2.png");
try {
$secondPresentationImage = $presentation->getImages()->addImage($secondSourceImage);
} finally {
$secondSourceImage->dispose();
}
$slide->getShapes()->addPictureFrame(
ShapeType::Rectangle, 0, 0, 360, 540, $firstPresentationImage);
$slide->getShapes()->addPictureFrame(
ShapeType::Rectangle, 360, 0, 360, 540, $secondPresentationImage);
$presentation->save("merged.pdf", SaveFormat::Pdf);
} finally {
$presentation->dispose();
}Merge PNG to PDF using Aspose.Slides
Aspose.Slides for PHP via Java lets you place multiple PNG images in a custom layout on a presentation slide and export the composed slide as a single PDF file.
How to merge PNG images to PDF in PHP
Follow these steps to merge multiple PNG images into a PDF in PHP.
- Install Aspose.Slides for PHP via Java. See Installation.
- Configure Aspose.Slides in your PHP project.
- Create a
Presentationinstance and access its first slide through a variable. - Load the PNG images with
Images::fromFileand place them on the slide withaddPictureFrame. - Call
savewith the output file path andSaveFormat::Pdf.
Built with Aspose.Slides
Merge PNG to PDF Online
The free Aspose.Slides Merger app is built with Aspose.Slides for PHP via Java, the same API as the code above. Open it and see what the API can do with your own PNG files.
- Runs in your browser, nothing to install.
- See how Aspose.Slides merges files before you write code.
- Upload several PNG files and combine them into one PDF file.
- Download the merged result as one file.
Merge Other Files
You can also combine files in other supported formats.