TinyMCE WYSIWYG editor to PDF and DOCX formats using docx4j

Few steps to get this done after the environment set up.  Basically prep html document, convert to xhtml, add to docx4j document, and generate.

1. (Preparing HTML) Wrap TinyMCE generated HTML in a root element such as div.

2. (Preparing HTML) Replace   with

3. (Preparing HTML) Use regEx to remove height and width attributes from images.  Affected version 2.8.1.  See http://stackoverflow.com/questions/15659076/does-docx4j-convert-xhtml-to-docx-in-memory

4. (Convert to XHTML, Generate) Use XHTMLImporter to convert the html into xhtml.  See http://priasardi.wordpress.com/2012/01/17/convert-html-to-docx-using-docx4j/

* Update – 2.8.1 seems to have trouble with underline and background color.  3.0.0 fixes that.  Both versions have trouble with table border and table caption.  3.0.1 (unreleased) should fix table border.  See http://www.docx4java.org/forums/pdf-output-f27/tabl-caption-and-border-issue-docx4j-3-0-0-t1763.html

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s