PHP Create PPT Document example parsing _php tutorial

Source: Internet
Author: User

PHP creates a PPT document code example:

  1. < ? PHP
  2. /** * PHP generates a PowerPoint 2007 sample script.
    * * This program requires PHP 5.2 or higher,
    Requires Php_zip and
    Php_xml Extended Support.
  3. * Usually win under the program just open the php_zip extension can,
    Php_xml extended built-in support.
  4. * Linux needs to be adjusted according to the compilation conditions.
  5. * * @author: Guya
  6. * @since: 2009-4-30
  7. */
  8. Catalog Split Symbol
  9. Define (' DS ', directory_separator);
  10. Defining the root directory
  11. Define (' ROOT ', DirName (__file__). DS);
  12. Modify the Include path, phppowerpoint
    The package is placed under the Libs directory of the current directory.
  13. Set_include_path (Get_include_path ().
    Path_separator. ROOT. ' Libs ');
  14. Does not limit script run time limits.
  15. Set_time_limit (0);
  16. Simply set the auto-load function.
  17. function __autoload ($className)
    {include_once (Str_replace ("_", DS,
    $className). ". php"); }
  18. Creates a new Phppowerpoint object.
  19. $ PPP = New phppowerpoint ();
  20. Get a page of slides that are currently in use
  21. $ Activeslide = $PPP- > getactiveslide ();
  22. Add a picture to the slideshow.
  23. $ Shape = $activeSlide- > Createdrawingshape ();
  24. Sets the picture name.
  25. $shape- > setName (' mmclub.net Logo ');
  26. Sets the description information for the picture.
  27. $shape- > setdescription (' mmclub.net Logo ');
  28. Picture actual path
  29. $shape- > SetPath (ROOT. ' Mmclub.net.jpg ');
  30. Picture height
  31. $shape- > SetHeight (103);
  32. Set Picture width
  33. $shape- > setwidth (339);
  34. Sets the image relative to the upper-left corner x position, per pixel
  35. $shape- > Setoffsetx (ten);
  36. Sets the picture relative to the upper-left corner of the y position, per pixel
  37. $shape- > Setoffsety (ten);
  38. Set diagram Display status
  39. $shape- > Getshadow ()- > setvisible (true);
  40. $shape- > Getshadow ()- > setdirection ();
  41. $shape- > Getshadow ()- > Setdistance (ten);
  42. Set a text box
  43. $ Shape = $activeSlide- > Createrichtextshape ();
  44. Set text box height, per pixel
  45. $shape- > setheight ();
  46. Set text box width, per pixel
  47. $shape- > SetWidth (+);
  48. Sets the text box relative to the upper-left corner x position, per pixel
  49. $shape- > setoffsetx ();
  50. Sets the text box relative to the upper-left corner of the y position, per pixel
  51. $shape- > setoffsety ($);
  52. Sets the text layout position to be horizontally centered and centered vertically.
  53. $shape- > getalignment ()- > Sethorizontal (
    Phppowerpoint_style_alignment::horizontal_center);
  54. $shape- > getalignment ()- > setvertical (
    Phppowerpoint_style_alignment::vertical_center);
  55. 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.
  56. $ Textrun = $shape- > Createtextrun (
    ' Welcome to use PHPPowerPoint2007 ');
  57. Use font Bold
  58. $textRun- > GetFont ()- > Setbold (true);
  59. 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.
  60. $textRun- > GetFont ()- > setSize (+);
  61. 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
  62. $textRun- > GetFont ()- > SetColor (new
    Phppowerpoint_style_color (' FFFF0000 '));
  63. Set up a few more text boxes below
  64. $ SHAPE0 = $activeSlide- > Createrichtextshape ();
  65. $shape 0- > setheight (+);
  66. $shape 0- > SetWidth (+);
  67. $shape 0- > Setoffsetx (+);
  68. $shape 0- > setoffsety (+);
  69. $shape 0- > getalignment ()- > Sethorizontal (
    Phppowerpoint_style_alignment::horizontal_center);
  70. $shape 0- > getalignment ()- > setvertical
    (Phppowerpoint_style_alignment::vertical_center);
  71. $ TextRun0 = $shape 0- > Createtextrun (' http:
    Www.mmclub.net ');
  72. $textRun 0- > GetFont ()- > setSize (+);
  73. $textRun 0- > GetFont ()- > SetColor (new
    Phppowerpoint_style_color (' ff0000ff '));
  74. $ Shape1 = $activeSlide- > Createrichtextshape ();
  75. $shape 1- > setheight (+);
  76. $shape 1- > SetWidth ($);
  77. $shape 1- > Setoffsetx (a);
  78. $shape 1- > setoffsety (+);
  79. $shape 1- > getalignment ()- > Sethorizontal (
    Phppowerpoint_style_alignment::horizontal_left);
  80. $shape 1- > getalignment ()- > setvertical (
    Phppowerpoint_style_alignment::vertical_center);
  81. $ textRun1 = $shape 1- > createtextrun (' Author:guya ');
  82. $textRun 1- > GetFont ()- > setSize (+);
  83. $textRun 1- > GetFont ()- > SetColor (new
    Phppowerpoint_style_color (' FF000000 '));
  84. $ Shape2 = $activeSlide- > Createrichtextshape ();
  85. $shape 2- > setheight (+);
  86. $shape 2- > SetWidth ($);
  87. $shape 2- > Setoffsetx (a);
  88. $shape 2- > setoffsety (540); $shape 2- > getalignment ()- >
    sethorizontal (phppowerpoint_style_alignment::
    Horizontal_left);
  89. $shape 2- > getalignment ()- > setvertical (
    Phppowerpoint_style_alignment::vertical_center);
  90. $ textRun2 = $shape 2- > createtextrun (' date:2009-4-30 ');
  91. $textRun 2- > GetFont ()- > setSize (+);
  92. $textRun 2- > GetFont ()- > SetColor (
    New Phppowerpoint_style_color (' FF000000 '));
  93. Save pptx file, use 2007 format
  94. $ Objwriter = phppowerpoint_iofactory ::
    Createwriter ($PPP, ' PowerPoint2007 ');
  95. Save File
  96. $objWriter- > Save (ROOT. ' Myphpppt.pptx ');
  97. Echo ' ppt create success! ';
  98. ?>

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.