コード例 #1
0
echo date('H:i:s') . " Set properties\n";
$objPHPPowerPoint->getProperties()->setCreator("Maarten Balliauw")->setLastModifiedBy("Maarten Balliauw")->setTitle("Office 2007 PPTX Test Document")->setSubject("Office 2007 PPTX Test Document")->setDescription("Test document for Office 2007 PPTX, generated using PHP classes.")->setKeywords("office 2007 openxml php")->setCategory("Test result file");
// Create slide
echo date('H:i:s') . " Create slide\n";
$currentSlide = $objPHPPowerPoint->getActiveSlide();
// Create a shape (drawing)
echo date('H:i:s') . " Create a shape (drawing)\n";
$shape = $currentSlide->createDrawingShape();
$shape->setName('PHPPowerPoint logo')->setDescription('PHPPowerPoint logo')->setPath('./images/phppowerpoint_logo.gif')->setHeight(36)->setOffsetX(10)->setOffsetY(10);
$shape->getShadow()->setVisible(true)->setDirection(45)->setDistance(10);
// Create a shape (text)
echo date('H:i:s') . " Create a shape (rich text)\n";
$shape = $currentSlide->createRichTextShape()->setHeight(300)->setWidth(600)->setOffsetX(170)->setOffsetY(180);
$shape->getActiveParagraph()->getAlignment()->setHorizontal(PHPPowerPoint_Style_Alignment::HORIZONTAL_CENTER);
$textRun = $shape->createTextRun('Thank you for using PHPPowerPoint!');
$textRun->getFont()->setBold(true)->setSize(60)->setColor(new PHPPowerPoint_Style_Color('FFC00000'));
// Save serialized file
echo date('H:i:s') . " Write to serialized format\n";
$objWriter = PHPPowerPoint_IOFactory::createWriter($objPHPPowerPoint, 'Serialized');
$objWriter->save(str_replace('.php', '.phppt', __FILE__));
// Read from serialized file
echo date('H:i:s') . " Read from serialized format\n";
$objPHPPowerPoint = PHPPowerPoint_IOFactory::load(str_replace('.php', '.phppt', __FILE__));
// Save PowerPoint 2007 file
echo date('H:i:s') . " Write to PowerPoint2007 format\n";
$objWriter = PHPPowerPoint_IOFactory::createWriter($objPHPPowerPoint, 'PowerPoint2007');
$objWriter->save(str_replace('.php', '.pptx', __FILE__));
// Echo memory peak usage
echo date('H:i:s') . " Peak memory usage: " . memory_get_peak_usage(true) / 1024 / 1024 . " MB\r\n";
// Echo done
echo date('H:i:s') . " Done writing file.\r\n";