PHP creates a PPT document code example:
- < ? PHP
- /** * PHP generates a PowerPoint 2007 sample script.
* * This program requires PHP 5.2 or higher,
Requires Php_zip and
Php_xml Extended Support.
- * Usually win under the program just open the php_zip extension can,
Php_xml extended built-in support.
- * Linux needs to be adjusted according to the compilation conditions.
- * * @author: Guya
- * @since: 2009-4-30
- */
- Catalog Split Symbol
- Define (' DS ', directory_separator);
- Defining the root directory
- Define (' ROOT ', DirName (__file__). DS);
- Modify the Include path, phppowerpoint
The package is placed under the Libs directory of the current directory.
- Set_include_path (Get_include_path ().
Path_separator. ROOT. ' Libs ');
- Does not limit script run time limits.
- Set_time_limit (0);
- Simply set the auto-load function.
- function __autoload ($className)
{include_once (Str_replace ("_", DS,
$className). ". php"); }
- Creates a new Phppowerpoint object.
- $ PPP = New phppowerpoint ();
- Get a page of slides that are currently in use
- $ Activeslide = $PPP- > getactiveslide ();
- Add a picture to the slideshow.
- $ Shape = $activeSlide- > Createdrawingshape ();
- Sets the picture name.
- $shape- > setName (' mmclub.net Logo ');
- Sets the description information for the picture.
- $shape- > setdescription (' mmclub.net Logo ');
- Picture actual path
- $shape- > SetPath (ROOT. ' Mmclub.net.jpg ');
- Picture height
- $shape- > SetHeight (103);
- Set Picture width
- $shape- > setwidth (339);
- Sets the image relative to the upper-left corner x position, per pixel
- $shape- > Setoffsetx (ten);
- Sets the picture relative to the upper-left corner of the y position, per pixel
- $shape- > Setoffsety (ten);
- Set diagram Display status
- $shape- > Getshadow ()- > setvisible (true);
- $shape- > Getshadow ()- > setdirection ();
- $shape- > Getshadow ()- > Setdistance (ten);
- Set a text box
- $ Shape = $activeSlide- > Createrichtextshape ();
- Set text box height, per pixel
- $shape- > setheight ();
- Set text box width, per pixel
- $shape- > SetWidth (+);
- Sets the text box relative to the upper-left corner x position, per pixel
- $shape- > setoffsetx ();
- Sets the text box relative to the upper-left corner of the y position, per pixel
- $shape- > setoffsety ($);
- Sets the text layout position to be horizontally centered and centered vertically.
- $shape- > getalignment ()- > Sethorizontal (
Phppowerpoint_style_alignment::horizontal_center);
- $shape- > getalignment ()- > setvertical (
Phppowerpoint_style_alignment::vertical_center);
- Sets the text contents of the text box. In the Chinese environment Test no Chinese problem.
If the environment is in e-text. Note To specify a font that supports Chinese.
Otherwise it might be garbled.
- $ Textrun = $shape- > Createtextrun (
' Welcome to use PHPPowerPoint2007 ');
- Use font Bold
- $textRun- > GetFont ()- > Setbold (true);
- Set the font size to 38, and note the text size setting here.
The size of the preceding text box is fixed. If the text exceeds the
The container will be discharged below the container.
- $textRun- > GetFont ()- > setSize (+);
- Set the text color, here is the ARGB mode, 16 binary mode,
The front 2 bits are transparency, followed by an RGB value. This is set as blue Blue
- $textRun- > GetFont ()- > SetColor (new
Phppowerpoint_style_color (' FFFF0000 '));
- Set up a few more text boxes below
- $ SHAPE0 = $activeSlide- > Createrichtextshape ();
- $shape 0- > setheight (+);
- $shape 0- > SetWidth (+);
- $shape 0- > Setoffsetx (+);
- $shape 0- > setoffsety (+);
- $shape 0- > getalignment ()- > Sethorizontal (
Phppowerpoint_style_alignment::horizontal_center);
- $shape 0- > getalignment ()- > setvertical
(Phppowerpoint_style_alignment::vertical_center);
- $ TextRun0 = $shape 0- > Createtextrun (' http:
Www.mmclub.net ');
- $textRun 0- > GetFont ()- > setSize (+);
- $textRun 0- > GetFont ()- > SetColor (new
Phppowerpoint_style_color (' ff0000ff '));
- $ Shape1 = $activeSlide- > Createrichtextshape ();
- $shape 1- > setheight (+);
- $shape 1- > SetWidth ($);
- $shape 1- > Setoffsetx (a);
- $shape 1- > setoffsety (+);
- $shape 1- > getalignment ()- > Sethorizontal (
Phppowerpoint_style_alignment::horizontal_left);
- $shape 1- > getalignment ()- > setvertical (
Phppowerpoint_style_alignment::vertical_center);
- $ textRun1 = $shape 1- > createtextrun (' Author:guya ');
- $textRun 1- > GetFont ()- > setSize (+);
- $textRun 1- > GetFont ()- > SetColor (new
Phppowerpoint_style_color (' FF000000 '));
- $ Shape2 = $activeSlide- > Createrichtextshape ();
- $shape 2- > setheight (+);
- $shape 2- > SetWidth ($);
- $shape 2- > Setoffsetx (a);
- $shape 2- > setoffsety (540); $shape 2- > getalignment ()- >
sethorizontal (phppowerpoint_style_alignment::
Horizontal_left);
- $shape 2- > getalignment ()- > setvertical (
Phppowerpoint_style_alignment::vertical_center);
- $ textRun2 = $shape 2- > createtextrun (' date:2009-4-30 ');
- $textRun 2- > GetFont ()- > setSize (+);
- $textRun 2- > GetFont ()- > SetColor (
New Phppowerpoint_style_color (' FF000000 '));
- Save pptx file, use 2007 format
- $ Objwriter = phppowerpoint_iofactory ::
Createwriter ($PPP, ' PowerPoint2007 ');
- Save File
- $objWriter- > Save (ROOT. ' Myphpppt.pptx ');
- Echo ' ppt create success! ';
- ?>
This PHP creates the application foreground of PPT document. It's still useful in some places on the web. The friends you need can spend a little more time studying.
http://www.bkjia.com/PHPjc/445942.html www.bkjia.com true http://www.bkjia.com/PHPjc/445942.html techarticle PHP creates a PPT document code example: PHP/***php generates a PowerPoint2007 sample script. * * This program needs to PHP5.2 above version, need php_zip and php_xml extension support. * Usually win next program just hit ...