I am attempting to create Word documents with ColdFusion, but it does not seem there is any way to do it with only ColdFusion. The best solution seems to be docx4j. However, I can't seem to find any in-depth docx4j and ColdFusion examples (Aside from this question). Where can I get some doc4jx and ColdFusion examples?
-
What are you looking for beyond the info provided in the answers to that question? – JasonPlutext Mar 28 '14 at 05:26
-
I expanded the question a bit in my comment below. – RHPT Mar 28 '14 at 13:51
-
Have you taken a look at the Apache POI project? Check out the links in this answer: http://stackoverflow.com/a/13535394/11047 – Adrian J. Moreno Mar 28 '14 at 16:00
-
You should edit your question to expand it. – JasonPlutext Mar 28 '14 at 21:14
2 Answers
pulling the data from a database.
https://stackoverflow.com/a/10845077/1031689 shows one approach to doing this. There are other ways, as to which see http://www.slideshare.net/plutext/document-generation-2012osdcsydney
The document needs page numbers and to
Typically you'd add these via a header or footer. You might find it easier to start with an almost empty docx structured appropriately, rather than creating the necessary structures via ColdFusion calling docx4j. You could still do it this way in conjunction with the final paragraph of this answer below.
create a table of contents.
Search the docx4j forums for how to do this.
In general, it looks like the easiest approach would be to create a Java class file which does everything you want (by invoking docx4j), and for your ColdFusion to just invoke that Java class. In other words, do a bit of Java programming first, get that working, then hook it up to your ColdFusion stuff.

- 1
- 1

- 15,352
- 4
- 44
- 84
I am not sure what exactly you mean with creating word document, which in my opinion is pretty simple. Manipulating yes, a bit tricky with docx4j or so.
<cfsavecontent variable="variables.mydoc">
Your content here
</cfsavecontent>
<cffile action="write" file="#yourFile.doc#" output="#variables.mydoc#">
Also see this post
Creating a Word document in Coldfusion - how to have pagenumbering?

- 1
- 1

- 1,565
- 7
- 18
-
I need to dynamically create Word documents via CF, pulling the data from a database. The document needs page numbers and to create a table of contents. Currently, we just insert HTML into a Word HTML template. I'd like to create a Word document in CF like you can generate a Excel spreadsheet with
– RHPT Mar 28 '14 at 13:49