لم تعُد "مجموعات Google" تتيح المشاركات أو الاشتراكات الجديدة من Usenet. وسيبقى بالإمكان عرض المحتوى السابق.

Word Doc from PHP?

25 مرّة مشاهدة
التخطي إلى أول رسالة غير مقروءة

Tyrone Slothrop

غير مقروءة،
26‏/08‏/2003، 9:29:25 م26‏/8‏/2003
إلى
Has anyone found a way to generate a Word .doc on the fly using PHP on
a Linux server? Are there any libraries out there that support this?
I would use PDF, but none of the libraries seem to support Acrobat
forms. A client needs to generate a partially filled out form using
data from a MySQL table that an applicant will receive via email to
complete, print, sign and snail mail.

Any other suggestions? (Preferably constructive. ;-) )

TIA!

Jochen Buennagel

غير مقروءة،
27‏/08‏/2003، 2:51:34 ص27‏/8‏/2003
إلى
Tyrone Slothrop wrote:
> Has anyone found a way to generate a Word .doc on the fly using PHP on
> a Linux server? Are there any libraries out there that support this?
> I would use PDF, but none of the libraries seem to support Acrobat
> forms. A client needs to generate a partially filled out form using
> data from a MySQL table that an applicant will receive via email to
> complete, print, sign and snail mail.

PDF will be much easier than Word format, because Word format is closed
and proprietary, very complex, and not fully understood. Thanks, Bill!

As to PDF: PDFlib (http://www.pdflib.com) supports all features of PDF.
I'm not sure if the free PDFlib Lite does that, but the full version is
only 450$, so if it's for a client, that should be fittable in most
budgets. For fancier work I suggest the PDFlib Personalization Server.
It's a bit more expensive, but it allows you to create the PDF files in
any app and then put placeholders in them. Then you can import the PDF
from your PHP app, fill in the placeholders with DB or form data and
present a perfect PDF file to print. With the PSP addon you can even
encrypt it against tampering.

(I'm not affiliated with PDFlib in any way. I just used it for a project
and was very happy with it.)

Jochen
--
/**
* @author Jochen Buennagel <zang at buennagel dot com>
*/

Jon Kraft

غير مقروءة،
27‏/08‏/2003، 4:49:44 ص27‏/8‏/2003
إلى
Tyrone Slothrop wrote:

> Has anyone found a way to generate a Word .doc on the fly using PHP on
> a Linux server? Are there any libraries out there that support this?
> I would use PDF, but none of the libraries seem to support Acrobat
> forms. A client needs to generate a partially filled out form using
> data from a MySQL table that an applicant will receive via email to
> complete, print, sign and snail mail.

Hi Tyrone,

Another (easy) option is creating a normal html form in a MIME email and
adding the content type header for a Word document (as MS Word renders
HTML): Content-type: application/x-ms-word

Test it with a browser:
<?php
header("Content-type: application/x-ms-word");
?>
<form>
Name:<br>
<input type="text" name="fullname" value="John Doe"><br><br>
</form>

HTH;
JOn

Olexiy Merenkov

غير مقروءة،
27‏/08‏/2003، 5:31:33 ص27‏/8‏/2003
إلى
Hello, Tyrone!

There is a way but it is not right for a 'good programmer'...
If the file size,formating,fonts,colors is always the same....
You can make a template document in MS Word and replace
the template text treating it like the common text file. But again, you
should know that it's a wrong way :)

"Tyrone Slothrop" <t...@paranoids.com>

Kindest Regards,
Olexiy Merenkov
http://www.merenkov.com/olexiy/


Ovide

غير مقروءة،
27‏/08‏/2003، 6:04:00 ص27‏/8‏/2003
إلى
I also saw an alternative for PDF generation:
http://www.fpdf.org/

Unfortunately I am not able to give my opinion on it yet, because I still
have to try it out. At least it is already stated at the FPDF website that
it is slower than PDFLib, but that is not a problem for me. The
compatibility problems between PDFLib versions and PHP versions bothers me
more (I upgraded to PHP 4.3.2 and started using the GD2 library instead of
using GD with PHP patch and now my PDFLib PDI functionality is suddenly no
longer part of my license; When moving to PHP 5 I will even have to by a
whole new PDFLib license).
Does anybody else have experience with FPDF?

Greetz,
Ovide

"Jochen Buennagel" <za...@buennagel.com> wrote in message
news:bihkgh$sqk$01$1...@news.t-online.com...

Martin C. Petersen

غير مقروءة،
27‏/08‏/2003، 10:20:15 ص27‏/8‏/2003
إلى
> There is a way but it is not right for a 'good programmer'...
> If the file size,formating,fonts,colors is always the same....
> You can make a template document in MS Word and replace
> the template text treating it like the common text file. But again, you
> should know that it's a wrong way :)
Are you sure about that? - my word xp will not open the document if some of
the plaintext is modified (perhaps the document contains some kind of
checksum)..


Martin


Andres Viikmaa

غير مقروءة،
27‏/08‏/2003، 11:14:38 ص27‏/8‏/2003
إلى
"Martin C. Petersen" <m...@phys.au.dk> wrote in message
news:3f4cbe21$0$83058$edfa...@dtext01.news.tele.dk...
Make sure to open document as binary file and use binary safe functions for
replacing text

Andres


Tyrone Slothrop

غير مقروءة،
27‏/08‏/2003، 12:33:31 م27‏/8‏/2003
إلى
Thank all for the suggestions, but the real issue here are those pesky
form fields which have to be filled out before the document can be
printed and signed. It looks like PDFlib Personalization Server would
work, though it would involve installation on a server without root
access. (Silly thing to have a dedicated server without root access,
but the client does not want to move!)

Phil Roberts

غير مقروءة،
27‏/08‏/2003، 12:56:11 م27‏/8‏/2003
إلى
With total disregard for any kind of safety measures Tyrone
Slothrop <t...@paranoids.com> leapt forth and uttered:

Creating a word document would probably be impossible owing to
its closed binary nature. But it's possible to generate
Rich-Text (.rtf) documents with PHP, these could then be named
with a .doc extension, sent with the MS-Word MIME type and Word
would open them happily.

Link: http://www.paggard.com/projects/rtf.generator/

And a basic tutorial in the Rich-Text format:
http://www.php9.com/index.php/section/articles/name/Using%20PHP%20for%20Rich%20Text%20Format%20RTF

--
There is no signature.....

Roy Rico

غير مقروءة،
01‏/09‏/2003، 5:55:37 ص1‏/9‏/2003
إلى
MS Word can open up a HTML, with some MSO proprietary XML stuff in the
document and treat it as a word document. Only problem is that when you do
a "save as" on the document generated, it defaults to HTML, but if you
select *.DOC, it will create a word document. no problem...

You're "BEST" bet is get a word doucment going, save as HTML, then take the
gerated HTML document as a template, add some of the code below to re-import
it into MS Word, and go from there. MS Word is really picky... one small
change can spiral your config outta control, so save frequently.

Good luck..

<?

header("Content-type: application/msword");
header("Content-Disposition: attachment; filename=" . $resume_name .
".doc");
echo '<html xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:w="urn:schemas-microsoft-com:office:word"
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta name=ProgId content=Word.Document>
<meta name=Generator content="Microsoft Word 9">
<meta name=Originator content="Microsoft Word 9">
<title></title>
</head>
';
echo "<!--[if gte mso 9]>
<xml>
<o:DocumentProperties>
<o:Author>" . $this->Author . "</o:Author>
<o:LastAuthor>" . $this->LastAuthor . "</o:LastAuthor>
<o:Revision>" . $this->Revisions . "</o:Revision>
<o:TotalTime>" . $this->TotalTime . "</o:TotalTime>
<o:Created>" . $this->CreateDate . "</o:Created>
<o:LastSaved>" . $this->LastSaveDate . "</o:LastSaved>
<o:Pages>" . $this->Pages . "</o:Pages>
<o:Company>" . $this->Company . "</o:Company>
<o:Lines>" . $this->Lines . "</o:Lines>
<o:Paragraphs>" . $this->Paragraphs . "</o:Paragraphs>
<o:Version>" . $this->Version . "</o:Version>
</o:DocumentProperties>
</xml>
<![endif]-->
<!--[if gte mso 9]>
<xml>
<w:WordDocument>
<w:View>Print</w:View>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
</w:WordDocument>
</xml>
<![endif]-->";
?>

--
Roy Rico
Halo 8 Productions
Mobile: 602 / 315.1438
http://www.halo8productions.net/
"Tyrone Slothrop" <t...@paranoids.com> wrote in message
news:822okvo65l5gvchpb...@4ax.com...

R. Rajesh Jeba Anbiah

غير مقروءة،
02‏/09‏/2003، 1:34:58 ص2‏/9‏/2003
إلى
"Roy Rico" <roy_...@hotmail.com> wrote in message news:<PEE4b.41571$Qy4.22048@fed1read05>...

> MS Word can open up a HTML, with some MSO proprietary XML stuff in the
> document and treat it as a word document. Only problem is that when you do
> a "save as" on the document generated, it defaults to HTML, but if you
> select *.DOC, it will create a word document. no problem...
>
> You're "BEST" bet is get a word doucment going, save as HTML, then take the
> gerated HTML document as a template, add some of the code below to re-import
> it into MS Word, and go from there. MS Word is really picky... one small
> change can spiral your config outta control, so save frequently.

Great! Seems to be a nice hack. Would be nice if you add this
stuff at php.net/header

R. Rajesh Jeba Anbiah

غير مقروءة،
02‏/09‏/2003، 1:38:35 ص2‏/9‏/2003
إلى
"Andres Viikmaa" <and...@hot.ee> wrote in message news:<3f4cca81$0$149$bb62...@diablo.uninet.ee>...

AFAIK, this "templating" logic is not true for Word DOC, it's true
only for rtf. BTW, rtf created out of Word Pad is less in size and
looks better as compared to the rtf created out of MS Word.

0 رسالة جديدة