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
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?
$Wrd = new COM("Word.Application");
$Wrd->Application->Visible = False;
$Wrd->Documents->Add();
$DocName = "MyDoc/MyWord.doc";
//$strPath = realpath(basename(getenv($_SERVER["SCRIPT_NAME"]))); // C:/AppServ/www/myphp
$Wrd->Selection->PageSetup->LeftMargin = "0.25";
$Wrd->Selection->PageSetup->RightMargin = "0.25";
$Wrd->Selection->PageSetup->TopMargin = "0.25";
$Wrd->Selection->PageSetup->BottomMargin = "0.25";
$Wrd->Selection->TypeText("Welcome To www.ShotDev.Com");
//$Wrd->ActiveDocument->SaveAs($strPath."/".$DocName);
$Wrd->ActiveDocument->SaveAs(realpath($DocName));
$Wrd->Application->Quit;
$Wrd = null;
?>
Word Created <a href="<?=$DocName?>">Click here</a> to Download.
</body>
</html>
Create a php file and save to path root-path/myphp/
Run
http://localhost/myphp/php_word_pagesetup.php
Screenshot


