Может ли рассказать мне, как связать несколько изображений в PowerPoint, используя php powerpoint library? В приведенном ниже коде я использовал foreach loop для добавления нескольких изображений в powerpoint, но только одно изображение добавляет, поэтому PLS мне помогает.Как добавить несколько изображений с помощью библиотеки php powerpoint?
<?php
require_once("db_config.php");
set_include_path(get_include_path() . PATH_SEPARATOR . 'Classes/');
include 'PHPPowerPoint.php';
include 'PHPPowerPoint/IOFactory.php';
?>
<html>
<h3 align="center">Welcome <?php echo $_SESSION['user_name'];?>
<br>
<a href="logout.php">Logout</a>
</h3>
<body>
<?php
echo "<div align='center'>";
echo "<form method='post' action=''>";
echo "<table align='center' border='1'>
<tr>
<th></th>
<th>ID</th>
<th>Firstname</th>
<th>Lastname</th>
<th>UserName</th>
</tr>";
$result = mysql_query("SELECT * FROM users");
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td><input type='checkbox' name='user_id[]' value='".$row['user_id']."' /> </td>";
echo "<td>" . $row['user_id'] . "</td>";
echo "<td>" . $row['first_name'] . "</td>";
echo "<td>" . $row['last_name'] . "</td>";
echo "<td>" . $row['user_name'] . "</td>";
echo "</tr>";
}
echo "</table><br>";
echo "<input type='submit' name='submit' value='Export PPT' />";
echo "</form></div>";
?>
</body>
</html>
<?php
if(isset($_POST['submit']) && isset($_POST['user_id'])){
$user_id = $_POST['user_id'];
foreach($user_id as $selected){
echo $selected."</br>";
$result = mysql_query("SELECT * FROM users WHERE user_id ='".$selected."'");
$row = mysql_fetch_array($result);
$img = '<img src="images/'.$row["image_name"].'" height="200" width="300" />';
$objPHPPowerPoint = new PHPPowerPoint();
// block sets slide logo.
$currentSlide = $objPHPPowerPoint->getActiveSlide();
$shape = $currentSlide->createDrawingShape();
$shape->setPath('images/'.$row["image_name"]);
$shape->setWidth(640);
$shape->setHeight(480);
$shape->setOffsetX(10);
$shape->setOffsetY(10);
// block sets text for first slide.
$shape = $currentSlide->createRichTextShape();
$shape->setHeight(700);
$shape->setWidth(600);
$shape->setOffsetX(10);
$shape->setOffsetY(500);
$shape->getAlignment()->setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_CENTER);
$textRun = $shape->createTextRun('FirstName:'.$row["first_name"].' Lastname:'.$row["last_name"].' UserName:'.$row["user_name"]);
$textRun->getFont()->setBold(true);
$textRun->getFont()->setSize(30);
$textRun->getFont()->setColor(new PHPPowerPoint_Style_Color('#FFFF'));
// block sets text for first slide ends.
$filename = str_replace('.php', '.pptx', __FILE__);
$newname = "PresentationReport-" . date('Y-m-d-H-i-s') . ".pptx";
$objWriter = PHPPowerPoint_IOFactory::createWriter($objPHPPowerPoint, 'PowerPoint2007');
$objWriter->save(str_replace('.php', '.pptx', __FILE__));
// block to download file.
header("Pragma: no-cache");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Disposition: attachment;filename=" . $newname);
ob_clean();
flush();
readfile($filename);
exit();
}
}
else
{
echo "<div align='center'>Please choose the user</div>";
exit;
}
?>