Learning & Integrating web technology and code help directory

How to use PHP & Word (Word.Application) - Page Setup

No comments
How to use PHP & Word (Word.Application) - Page Setup The Learn / Lutorial / Sctipts php programming how to using  PHP Setup a page in word document.
ShotDev Focus:
- PHP  & Setup a page in word document.
Example
php_word_pagesetup.php
  1. <html>  
  2. <head>  
  3. <title>ShotDev.Com Tutorial</title>  
  4. </head>  
  5. <body>  
  6. <?  
  7. $Wrd = new COM("Word.Application");  
  8. $Wrd->Application->Visible = False;  
  9. $Wrd->Documents->Add();  
  10. $DocName = "MyDoc/MyWord.doc";  
  11.   
  12. //$strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp  
  13.   
  14. $Wrd->Selection->PageSetup->LeftMargin = "0.25";  
  15. $Wrd->Selection->PageSetup->RightMargin = "0.25";  
  16. $Wrd->Selection->PageSetup->TopMargin = "0.25";  
  17. $Wrd->Selection->PageSetup->BottomMargin = "0.25";  
  18. $Wrd->Selection->TypeText("Welcome To www.ShotDev.Com");  
  19.   
  20. //$Wrd->ActiveDocument->SaveAs($strPath."/".$DocName);  
  21. $Wrd->ActiveDocument->SaveAs(realpath($DocName));  
  22. $Wrd->Application->Quit;  
  23. $Wrd = null;  
  24. ?>  
  25. Word Created <a href="<?=$DocName?>">Click here</a> to Download.  
  26. </body>  
  27. </html>  
Create a php file and save to path root-path/myphp/
Screenshot
PHP & Create Word
.
.

No comments :

Post a Comment