Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert HTML & CSS to DOC(X)?

Is there some utility that could be called via command line to produce a doc(x) file? The source file would be HTML and CSS.

I am trying to generate Word documents on the fly with PHP. I am only aware of phpdocx library, which is very low level and not much use for me (I already have one poor implementation of Word document generation).

What I need from a document:

  • TOC
  • Images
  • Footers/Headers (they could be manually made on each HTML page)
  • Table
  • Lists
  • Page break (able to decide what goes to which page, eg one HTML file per page, join multiple HTML files to produce the entire document.)
  • Paragraphs
  • Basic bold/etc styles
like image 516
Tower Avatar asked Jan 04 '12 09:01

Tower


1 Answers

I didn't find PHPDOCX very useful either. An alternative could be PHPWord, i think it covers what you need. According the website it can do these things:

  • Insert and format document sections
  • Insert and format Text elements
  • Insert Text breaks
  • Insert Page breaks
  • Insert and format Images and binary OLE-Objects
  • Insert and format watermarks (new)
  • Insert Header / Footer
  • Insert and format Tables
  • Insert native Titles and Table-of-contents
  • Insert and format List elements
  • Insert and format hyperlinks
  • Very simple template system (new)

In your case that isn't enough, but there is a plugin available to convert (basic) HTML to Docx and it works very good in my opinion. http://htmltodocx.codeplex.com/

I am using this for a year or two now and am happy with it. Altough i have to add that the HTML can't be to complex.

like image 169
mat Avatar answered Sep 29 '22 02:09

mat