tags:

views:

31

answers:

1

Hi, i need to create a .doc file that has more than one page. I want to create the doc file from html (setting the headers so that it is interpreted as a doc file) but i don't know how to add a page break in html that is correctly recognized from word.

Thanx in advance

+3  A: 

You may find PHPWord to be useful.

PHPWord is a library written in PHP that create word documents.

Update:

Method One:

Here is a method using COM (requires Word to be installed)

Method Two:

Use appropriate headers, here is an example:

header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename=document_name.doc");

echo "<html>";
echo "<body>";
echo "<b>My first document</b>";
echo "</body>";
echo "</html>";
Sarfraz
That one is for .docx files
alcuadrado
Cool. But it creates .docx files, not .doc. I was looking forward to seeing PHP code that generates a .doc file. Still, nice to know PHPWord is there.
eje211
@Nicola Peluchetti: See my updated answer please.
Sarfraz
@alcuadrado: You are right but now i have updated my answer :)
Sarfraz
@sAc, method two is what i meant. I was just wondering if there was an html tag that would interpreted by MsWord as a page break!
Nicola Peluchetti
Actually the best way to do what i wanted to do is to create an html file on the server, pass it to the open-office converter to create a .doc file and then send it back to the client! Thx for your posts!
Nicola Peluchetti