您好,欢迎访问一九零五行业门户网

PHP创建PPT文档范例解析_PHP教程

php创建ppt文档代码实例:
 ?php    /** * php 生成 powerpoint 2007 示例脚本.
 * * 本程序需要 php 5.2 以上版本, 
需要 php_zip 和 
php_xml 扩展支持.  * 通常win下程序只要打开 php_zip 扩展即可, 
php_xml 扩展内置支持.  * linux 下需要根据编译条件具体调整.  * * @author: guya  * @since: 2009-4-30  */    //目录分割符号    define('ds', directory_separator);    //定义根目录    define('root', dirname(__file__) . ds);    //修改include路径, phppowerpoint 
包放在当前目录的 libs 目录下.    set_include_path(get_include_path() . 
path_separator . root . 'libs');    //不限制脚本运行时间限制.    set_time_limit(0);    //简单设置自动载入函数.    function __autoload($classname)
 { include_once(str_replace(_, ds,
 $classname) . .php); }    //新建立一个 phppowerpoint 对象.    $ppp = new phppowerpoint();    //获取当前使用的一页幻灯片    $activeslide = $ppp->getactiveslide();    //添加一个图片到幻灯片.    $shape = $activeslide->createdrawingshape();    //设置图片名称.    $shape->setname('mmclub.net logo');    //设置图片的描述信息.    $shape->setdescription('mmclub.net logo');    //图片实际路径    $shape->setpath(root . 'mmclub.net.jpg');    //图片高度    $shape->setheight(103);    //设置图片宽度    $shape->setwidth(339);    //设置图片相对于左上角x位置, 单位像素    $shape->setoffsetx(10);    //设置图片相对于左上角y位置, 单位像素    $shape->setoffsety(10);    //设置图显示状态    $shape->getshadow()->setvisible(true);    $shape->getshadow()->setdirection(45);    $shape->getshadow()->setdistance(10);    //设置一个文本框    $shape = $activeslide->createrichtextshape();    //设置文本框高度, 单位像素    $shape->setheight(150);    //设置文本框宽度, 单位像素    $shape->setwidth(600);    //设置文本框相对于左上角x位置, 单位像素    $shape->setoffsetx(150);    //设置文本框相对于左上角y位置, 单位像素    $shape->setoffsety(200);    //设置文本布局位置为水平居中, 垂直居中.    $shape->getalignment()->sethorizontal(
 phppowerpoint_style_alignment::horizontal_center );   $shape->getalignment()->setvertical(
 phppowerpoint_style_alignment::vertical_center );    //设置文本框文本内容. 在中文环境下测试没中文问题.
 如果在 e 文环境. 注意要指定支持中文的字体. 
否则可能出乱码了.    $textrun = $shape->createtextrun(
'欢迎使用 phppowerpoint2007');    //使用字体加粗    $textrun->getfont()->setbold(true);    //设置字体尺寸为 38, 这里注意一下文字的大小设置. 
前面的文本框的大小是固定的. 如果文字超出的
容器会被出容器被排到下面    $textrun->getfont()->setsize(38);    //设置文字颜色, 这里是argb模式 , 16进制模式, 
前面2位为透明度, 后面为rgb值. 这里设置为 blue蓝色    $textrun->getfont()->setcolor( new 
phppowerpoint_style_color( 'ffff0000' ) );    //下面再设置几个文本框    $shape0 = $activeslide->createrichtextshape();    $shape0->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' ) );    //保存pptx 文件, 使用 2007 格式    $objwriter = phppowerpoint_iofactory::
createwriter($ppp, 'powerpoint2007');    //保存文件    $objwriter->save(root . 'myphpppt.pptx');    echo 'ppt create success!';    ?>  这个php创建ppt文档的应用前景的话. 在web的某些场合还是很有用的. 需要的朋友可以多花点时间去研究了.
http://www.bkjia.com/phpjc/445942.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/445942.htmltecharticlephp创建ppt文档代码实例: ?php /***php生成powerpoint2007示例脚本. **本程序需要php5.2以上版本, 需要php_zip和 php_xml扩展支持. *通常win下程序只要打...
其它类似信息

推荐信息