1

I made a HTML for a word document and created it via file_put_contents('document.doc', $html_source);

The problem is that the style used as following:

style='page-break-before:always'

Doesn't do anything.

Any ideas or solutions?

Here is an example of what I am trying to do: http://bytes.com/topic/html-css/answers/720863-page-break-html-word-email

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
av_master
  • 51
  • 1
  • 4
  • So you lie to MS Word about file extension and expect it to do whatever you want? – Artjom Kurapov Apr 17 '12 at 12:59
  • Not really sure what you're trying to do here. Perhaps post a bit of the HTML source and what you're trying to apply that style to. – Jim D Apr 17 '12 at 13:03
  • Well, make a document in Word with multiple pages, save it has HTML, then open it with Word again. Do it respect page breaks? if yes, then read the HTML code and see what propietary crap Word expect, and use that. If don't respect line breaks, you are out of luck. – Tei Apr 17 '12 at 13:08
  • As I see it, there is no way this would work using a simple file_put_contents. The best option is to use a GNU Word document creator with PHP like this one http://phpword.codeplex.com/. Thanks for all your comments though! – av_master Apr 17 '12 at 13:54

2 Answers2

2

Microsoft Word will only recognize this style as long as it's applied to a <br /> element.

.pagebreak {
        page-break-before: always;
    }
<br class="pagebreak" />
Wizard of Oz
  • 175
  • 1
  • 1
  • 9
0

This worked for me:

<div class=”WordSection1”></div>

I am was creating a word document from an HTML table.