RE: PHP on an intranet with MSOffice-like templates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Peter,

It is possible to produce word document from a php script.
The data will be extracted from mySQL (in the example provided it is from
msaccess, but it is the same process). Php can open an existing document and
replace Bookmark by a specific value.
The code may talk more than me.

// Create Client Letter
   $documentKey = $agentAccount . "_" .
str_replace("/","_",$clientReference);        
   $word = new COM("word.application") or die("Unable to instantiate Word");
   $template_file = $folder . "welcomeLetterAgent.dot";
   $word->Documents->Open($template_file);
 
   replaceBookmark($word,"clientReference",$clientReference);	      
   replaceBookmark($word,"parentName",$parentName);
   replaceBookmark($word,"businessName",$businessName);        
   replaceBookmark($word,"addressLine1",$addressLine1);
   replaceBookmark($word,"addressLine2",$addressLine2);
   replaceBookmark($word,"addressLine3",$addressLine3);
   replaceBookmark($word,"addressLine4",$addressLine4);
   replaceBookmark($word,"addressPostCode",$addressPostCode);    
   replaceBookmark($word,"paragraph3",$paragraph3);
   replaceBookmark($word,"paragraph4",$paragraph4);
   replaceBookmark($word,"paragraph5",$paragraph5);   
   replaceBookmark($word,"currentDate",$currentDate);       
   
   $new_file = $folder . $documentKey . "_welcomeLetter.doc";
   $word->Documents[1]->SaveAs($new_file);
   $word->Quit();
   $word->Release();
   $word = null;

function replaceBookmark($word,$bookmarkname,$bookmarktext) {
$objBookmark = $word->ActiveDocument->Bookmarks($bookmarkname);
$range = $objBookmark->Range;
$range->Text = $bookmarktext;
}

I hope it is what you wanted!

You can generate pdf document on the fly using the pdflib library
http://www.pdflib.com

Regards,

Alain


 -----Original Message-----
From: 	peter@xxxxxxxxxxxxxx [mailto:peter@xxxxxxxxxxxxxx] 
Sent:	Tuesday, November 16, 2004 10:47 PM
To:	php-windows@xxxxxxxxxxxxx
Subject:	PHP on an intranet with MSOffice-like templates

(originally posted to php-db, but I realized that this list is far more
germane
for the question - apology to those reading it twice).

I don't even know if this is possible, or if I'll have to go the route of
.NET
development to get this sort of functionality (I'm sure it's possible if I
jump
through enough hoops).

But here's what I'm trying to accomplish...
- users are all on a local intranet with access to a shared drive (no prob)
- users navigate a PHP-MySQL application to select records from a database
(no
prob)
- users are able to click a link which will launch some sort of document
(they
have Office, but if something like PDF is available on a Windows platform,
great) where a document template is fetched and updated with information
from
the selected record.    (This is the part I don't understand how to do).

An example... user wants to be able to print one of a variety of letters to
physically mail to a customer, customized with the customer's account info.
(You know:  Dear [first name] [last name], ... Your account [account_id] ...
is
30 days past due... etc )

This way, management can update the template and not have me re-work the
code to
have it work...

Is such a thing possible on a windows PHP platform?  Can someone point me to
somewhere I can learn more about it?

Thanks much,
-P


*******************************************************************************************************************
Premium Credit Limited
Main Switchboard   :01372-748833
Fax                          :01372-748811
This E-mail message together with any attachments transmitted with it is intended only for use by its
addressee and may contain information which is privileged and confidential, disclosure of which may
be prohibited by law.  If you are not (or have not been authorised by) the addressee, you may not
copy, forward, disclose or use any part of this message or its attachments.  If you have received this
message in error, please notify the sender by return E-mail and delete it from your system.  Premium
Credit Limited and its associate group of companies do not endorse opinions and information in this
message and its attachments which do not relate to the official business of Premium Credit Limited
and do not accept liability for errors or omissions arising from the presence of computer viruses or
from interception/corruption in the course of transmission.
********************************************************************************************************************

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux