Results 1 to 10 of 10
  1. #1
    Join Date
    Feb 2004
    Location
    India
    Posts
    135

    Unanswered: CREATE a POWERPOINT File using PHP COM on FLY

    Hi ALL,

    I need more info about methods and properties which is to insert a TEXT in TEXT BOX for Powerpoint Slides, and i have to change the background image, FONT, SIZE, Etc... for my Powerpoint Slides on FLY.

    I have displays the code below.
    Code:
    <?php
    $powerpnt = new COM("powerpoint.application");
    //Creating a new presentation
    $pres=$powerpnt->Presentations->Add();
    //Adds the first slide. "12" means blank slide
    $pres->Slides->Add(1,12);
    //Adds another slide. "10" means a slide with a clipart and text
    $pres->Slides->Add(2,10);
    //Adds a textbox (1=horizontal, 20=left margin, 50=top margin, 300=width, 40=height)
    $pres->Slides[1]->Shapes->AddTextbox(1,20,50,300,40);
    //Adds a 16-point star (94=16 point star, 100=left margin, 200=top margin, 300=width, 300=height)
    $pres->Slides[1]->Shapes->AddShape(94,100,200,300,300);
    //Save the document as PPT file
    $powerpnt->Presentations[1]->SaveAs("D:\byeworld.ppt");
    //And of course, quit Power Point
    $powerpnt->quit();
    //Give the user a download link
    echo '<a href="byeworld.ppt">Download file as .ppt</a>';
    ?>
    Thanks in advance.


    awaiting for earlies reply.

    Saravanan.R

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    WWGS (what would google say)
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Feb 2004
    Location
    India
    Posts
    135
    i didn't get any help in this regard, rather than that code i have posted in this THREAD.

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    PHP by definiton knows nothing at all about Powerpoint, to set anything within Powerpoint you need to know details of the powerpoint API. Once you know (part or all of) the powerpoint API then you can make the appropriate settings using the Powerpoint object you first cretaed as $powerpnt = new COM("powerpoint.application");

    You need to use the the methods with that API to make what ever changes you wish

    So, in my view, doing a google is avery good first step, unless you happen to have the the Powerpoint documentation in front of you.

    Failing that you could try opening a VBA application (either Access or Excel and create a Powerpoint object int heri and by using intellisense find out what you need.

    Failing that you could buy a book on controlling Powerpoint programatically.

    and icidentally I looked at one or two of the references that that Google search provided and they seem to do, or get very close to, waht you want to achieve
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Feb 2004
    Location
    India
    Posts
    135

    Thumbs up

    Thanks healdem

    I got an VBA powerpoint reference manual. But they r given in based on VB. From that If i use the same methods i cant able to create or insert a TEXT.
    For Ex. In VBA-PowerPoint to add a TExt in a Slide as Follows
    Code:
    Set myDocument = ActivePresentation.Slides(1)
    myDocument.Shapes.AddTextbox(Type:=msoTextOrientationHorizontal, _
        Left:=100, Top:=100, Width:=200, Height:=50).TextFrame _
        .TextRange.Text = "Test Box"
    How could i change this into my PHP format. I have done partly to create textbox as Follows
    Code:
    $powerpnt = new COM("powerpoint.application");
    //Creating a new presentation
    $pres=$powerpnt->Presentations->Add();
    //Adds the first slide. "12" means blank slide
    $pres->Slides->Add(1,12);
    //Adds another slide. "10" means a slide with a clipart and text
    $pres->Slides->Add(2,10);
    //Adds a textbox (1=horizontal, 20=left margin, 50=top margin, 300=width, 40=height)
    $pres->Slides[1]->Shapes->AddTextbox(1,20,50,300,40);
    Assist me in this regard

  6. #6
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I dont know... Ive never had the need to access an MS Offcie object from within PHP
    I suspect that you may need to use something like
    $pres->Slides[1]->Shapes->AddTextbox(1,20,50,300,40);
    $pres->Slides[1]->Shapes->TextRange.Text = "Test Box";
    it could be something a bit dfferent, it could be
    $pres->Slides[1]->Shapes->Text = "Test Box";

    ..you probably need to so some experimenting.

    ...if you dont have a copy of the full API, then a very effective way of learning the api is to create the object from within a VBA application and learn waht particualr settigns do. Quite often Microsoft API's have serveral ways of setting the same thing. It wouldnt surprise me if you could address each of the follwoing settings as
    $pres->Slides[1]->Shapes->AddTextbox
    $pres->Slides[1]->Shapes->Oreintation = 1
    $pres->Slides[1]->Shapes->LeftMargin =20
    $pres->Slides[1]->Shapes->RightMargin = 300
    ....etc
    I'd rather be riding on the Tiger 800 or the Norton

  7. #7
    Join Date
    Feb 2004
    Location
    India
    Posts
    135
    thanks for ur reply.

    But it doesn't work with this syntax.

  8. #8
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    Ok, I've not researched this at all, but it works nicely with word...it might not be what you want at all but thought it might help:

    1. get a sample file (with some slides in)
    2. save as html
    3. make your code spit out the html based on 2
    4. display with the correct content type - and (with word at least) it pops up in word looking like a normal doc.


    Russ

  9. #9
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I seem to remember that on the PHP website their is amechanism which allows you to request a com object exposes/tells you al methods and properties that exist... might be worth a look
    I'd rather be riding on the Tiger 800 or the Norton

  10. #10
    Join Date
    May 2009
    Posts
    1
    How make Diagram in PowerPoint by PHP?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •