I am going to generate a word document according to html page. I need some formatting like page break and customize heading of the document such as .can i achieve them using html?
3 Answers
I'm not sure how you would go about customizing the header using HTML. In general, what you're planning on doing is probably a bad idea. I would look at libraries that let you generate regular .docx
files (the Word XML format).
With that said, I think you can get your page breaks with:
<br clear="all" style="mso-special-character:line-break; page-break-before:always" />

- 105,112
- 20
- 162
- 194
-
yes thanks it is one of the commands i wanted, it works, Is there any other html phrases we can use to customize msword – Dinidu Hewage Nov 23 '12 at 09:13
-
I'm not sure where you will find a good list, but you may want to do things like change the page margins, etc. There's an example [here](http://www.codeproject.com/Articles/7341/Dynamically-generate-a-MS-Word-document-using-HTML) for that. – Cᴏʀʏ Nov 23 '12 at 09:16
Pure HTML would be hard. But keep in mind the current Word-Dokument-Format is OPENXML (or sort of Microsoftish). I bet there are libraries that could help you assemble or compile word doxs with javascript.
Generate office open XML excel file from javascript
http://openxmldeveloper.org/wiki/w/wiki/open-xml-and-javascript.aspx
as far as I know a page-break in OpenXml could be acomplished like this...
<w:p>
<w:r>
<w:br w:type="page" />
</w:r>
</w:p>
HTH

- 1
- 1

- 6,762
- 10
- 46
- 73
Maybe. Select the page in the browser and use cut&pase. Word does recognize HTML in the clipboard and then tries its best to preserve the formatting.
If you need something more complex, you need to write a program that converts HTML to the OOXML format.

- 321,842
- 108
- 597
- 820
-
no here I m going to customize JIRA report generation format according to my company report format. Then generation is done by a java class which i dont have the permission to change. So i have to give html codes which can generate msword commands at the runtime. – Dinidu Hewage Nov 23 '12 at 09:24