web 2.0

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

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

PHP & Create Word
.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.