Merge Image to PDF in PHP
High-speed and cross-platform PHP library for merging Image to PDF files using PHP code
Merge Image to PDF using Aspose.Slides
Aspose.Slides for PHP via Java is a powerful PHP library used to create, convert, merge, and manipulate presentations, PDFs, images, and other files. When you merge image to PDF, you are effectively combining images to obtain a single PDF file.
Merge Image to PDF in PHP
Using Aspose.Slides for PHP via Java , you can merge image to PDF quickly with just a few lines of code
PHP code for merging Image to PDF
<?php
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
require_once("lib/aspose.slides.php");
$pres = new Presentation();
try
{
$slide = $pres->getSlides()->get_Item(0);
$filename1 = 'image1.png';
$f1 = fopen($filename1, 'r');
if ($f1) {
$contents1 = fread($f1, filesize($filename1));
fclose($f1);
}
$filename2 = 'image1.png';
$f2 = fopen($filename2, 'r');
if ($f2) {
$contents2 = fread($f2, filesize($filename2));
fclose($f2);
}
$image1 = $pres->getImages()->addImage($contents1);
$slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 0, 0, 360, 540, $image1);
$image2 = $pres->getImages()->addImage($contents2);
$slide->getShapes()->addPictureFrame(ShapeType::Rectangle, 360, 0, 360, 540, $image2);
$pres->save("merged-pdf.pdf", SaveFormat::Pdf);
}
finally
{
if ($pres != null) $pres->dispose();
}
?>
How to merge Image to PDF in PHP
Install Aspose.Slides for PHP via Java. See Installation .
Add the library as a reference in your project.
Create an instance of the Presentation class.
Load the images you want to merge together as picture frames.
Save the resulting PDF.
Merge PDF Files Online
Merge other files
You can also combine files in other formats to get a single file