0

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?

Toby Allen
  • 10,997
  • 11
  • 73
  • 124
Dinidu Hewage
  • 2,169
  • 6
  • 40
  • 51

3 Answers3

1

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" />
Cᴏʀʏ
  • 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
1

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/blog/b/openxmldeveloper/archive/2012/08/02/working-with-open-xml-documents-using-javascript.aspx

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

Community
  • 1
  • 1
silverfighter
  • 6,762
  • 10
  • 46
  • 73
0

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.

Aaron Digulla
  • 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