


Analysis of Examples of Creating PPT Documents with PHP_PHP Tutorial
Code example for creating PPT document with PHP:
- < ?php
- / *** PHP generates PowerPoint 2007 sample script.
* * This program requires PHP 5.2 or above,
requires php_zip and
php_xml extension support. - * Usually under WIN The program only needs to open the php_zip extension.
The php_xml extension has built-in support. - * Under Linux, specific adjustments need to be made according to the compilation conditions.
- * * @author: Guya
- * @since: 2009-4-30
- */
- //Directory separation symbol
- define('DS', DIRECTORY_SEPARATOR);
- //Define the root directory
- define('ROOT', dirname(__FILE__) . DS);
- //Modify the include path, PHPPowerPoint
package is placed in the libs directory of the current directory. - set_include_path(get_include_path() .
PATH_SEPARATOR . ROOT . 'libs'); - //No limit on script running time.
- set_time_limit(0);
- //Simple setting of autoload function.
- function __autoload($className)
{ include_once(str_replace("_", DS,
$className) . ".php"); } - //Create a new PHPPowerPoint object.
- $ppp = new PHPPowerPoint();
- //Get the currently used slideshow
- $activeSlide = $ppp->getActiveSlide();
- //Add a picture to the slide. > shape
- = $activeSlide->createDrawingShape() ; //Set the image name.
- $shape-
- >setName('MmClub.net Logo'); //Set the description information of the picture. 🎜>$shape-
- >
- setDescription('MmClub.net Logo'); //The actual path of the image $shape-
- >
- setPath (ROOT . 'mmclub.net.jpg'); //Picture height $shape-
- >
- setHeight(103); //Set image width $shape-
- >
- setWidth(339); / /Set the X position of the picture relative to the upper left corner, unit pixel $shape-
- >
- setOffsetX(10); //Set the Y position of the image relative to the upper left corner, unit pixels $shape-
- >
- setOffsetY(10); $shape-> getShadow()-
- >
- setVisible(true); >getShadow()->setDirection(45); $shape-
- >getShadow()- >setDistance(10); //Set a text box
- $shape = $activeSlide->createRichTextShape();
- //Set text box height, unit pixels
- $shape->setHeight(150); //Set the text box width in pixels $shape-
- >
- setWidth(600); //Set the X position of the text box relative to the upper left corner, unit pixels $shape-
- >
- setOffsetX(150); //Set the Y position of the text box relative to the upper left corner, unit pixels $shape-
- >
-
setOffsetY(200);
- //Set the text layout position to be horizontally centered and vertically centered.
- $shape->getAlignment()->setHorizontal(
PHPPowerPoint_Style_Alignment::HORIZONTAL_CENTER ) ;- $shape->getAlignment()->setVertical(
PHPPowerPoint_Style_Alignment::VERTICAL_CENTER );- //Set the text box Text content. There is no Chinese problem when testing in a Chinese environment.
If in an e-text environment, be sure to specify a font that supports Chinese.
Otherwise, garbled characters may appear.- $textRun = $shape-> createTextRun(
'Welcome to PHPPowerPoint2007');- //Use font bold
- $textRun->getFont()->setBold(true);
- //Set the font size to 38, pay attention to the text size setting here.
The size of the previous text box is fixed. If the text exceeds The
container will be out of the container and queued to the bottom- $textRun->getFont()->setSize(38);
- //Set text color, here is ARGB mode, hexadecimal mode,
The first 2 digits are transparency, and the back is RGB value. Here is set to blue- $ textRun->getFont()->setColor( new
PHPPowerPoint_Style_Color( 'FFFF0000' ) );- //Set a few more text boxes below
- $shape0 = $activeSlide->createRichTextShape(); setHeight(50);
- $shape0->setWidth(400) ;
- $shape0->setOffsetX(250);
- $shape0->setOffsetY(400);
- $shape0->getAlignment()-
- >setHorizontal( PHPPowerPoint_Style_Alignment::HORIZONTAL_CENTER ); $shape0->
getAlignment()-- >setVertical ( PHPPowerPoint_Style_Alignment::VERTICAL_CENTER ); $textRun0 = $shape0-
>
- createTextRun('http://www.mmclub.net');
- $textRun0->getFont()->setSize(26);
- $textRun0->getFont()->setColor( new
PHPPowerPoint_Style_Color( 'FF0000FF' ) );- $shape1 = $activeSlide->createRichTextShape();
- $shape1->setHeight(30);
- $shape1->setWidth(200);
- $shape1->setOffsetX(700);
- $shape1->setOffsetY(500);
- $shape1->getAlignment()->setHorizontal(
PHPPowerPoint_Style_Alignment::HORIZONTAL_LEFT );- $shape1->getAlignment()->setVertical(
PHPPowerPoint_Style_Alignment::VERTICAL_CENTER );- $textRun1 = $shape1->createTextRun('Author: Guya');
- $textRun1->getFont()->setSize(14);
- $textRun1->getFont()->setColor( new
PHPPowerPoint_Style_Color( 'FF000000' ) );- $shape2 = $activeSlide->createRichTextShape();
- $shape2->setHeight(30);
- $shape2->setWidth(200);
- $shape2->setOffsetX(700);
- $shape2->setOffsetY(540); $shape2->getAlignment()->
setHorizontal( PHPPowerPoint_Style_Alignment::
HORIZONTAL_LEFT );- $shape2->getAlignment()->setVertical(
PHPPowerPoint_Style_Alignment::VERTICAL_CENTER );- $textRun2 = $shape2->createTextRun('Date: 2009-4-30');
- $textRun2->getFont()->setSize(14);
- $textRun2->getFont( )->setColor(
new PHPPowerPoint_Style_Color( 'FF000000' ) );- //Save PPTX file, using 2007 format
- $objWriter = PHPPowerPoint_IOFactory::
createWriter($ppp, 'PowerPoint2007');- //Save the file
- $objWriter->save(ROOT . 'myPhpPpt.pptx');
- echo 'ppt create success!'; >
- As for the application prospects of creating PPT documents with PHP, it is still very useful in some WEB situations. Friends who need it can spend more time to study it. http://www.bkjia.com/PHPjc/445942.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/445942.html
TechArticle

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.
