Page 1 of 1

ColdFusion & Docx4j

PostPosted: Fri Feb 10, 2012 9:39 am
by ColdBreeze
I have a project where I have to do Word document manipulation, and the only 3rd party library/API I can find is Aspose.Words (and Apache POI, which doesn't seem like it can do anything with Word documents)... but that costs a crazy amount of money. I just need the ability to find/replace placeholders in a docx word document, and then be able to access the checkbox object within an docx document and mark it as checked, then convert the document into PDF and send it to the user.

What I've been doing is, is saving about a 100 documents as RTF, and reading the file into memory, replacing the placholders, than saving it. The problem is that ColdFusion cannot manipulate doc/docx files directly (such as marking a checkbox inside a document, and also saving the document as PDF). Now ColdFusion can intergrate with any Java library/API (since it runs ontop of Java).

Could I use docx4j to do what I need (I can easily save all the documents as docx)? I am thinking about converting the files into HTML if I can't find an alternative method, but that completely destroys the format and is a major pain.

Re: ColdFusion & Docx4j

PostPosted: Fri Feb 10, 2012 7:00 pm
by jason
If ColdFusion can integrate with any Java library/API, and you are happy to work with docx rather than RTF, docx4j can do what you want.

(Note that finding/replacing placeholders generally relies on the placeholder being represented as a single text run in the underlying format, which is not necessarily the case - see recent post on this)

You may wish to confirm first that its PDF output covers the docx format features you are using.

Re: ColdFusion & Docx4j

PostPosted: Sat Feb 11, 2012 4:50 am
by ColdBreeze
Where's the recent post on placeholders?

ColdFusion itself, cannot read/write to a doc or docx file, but it can with RTF since it is text. So using a Replace() function works well to find/replace placeholders.

Are there any examples out there on using docx4j to read/write to placeholders, and checking the checkbox object inside a docx document?

Re: ColdFusion & Docx4j

PostPosted: Sat Feb 11, 2012 6:06 am
by ColdBreeze
Here's an example I found with ColdFusion with Aspose.Words
http://docs.aspose.com/display/wordsjav ... s+for+Java

I'm guessing, after reading the Docx4J API, I could do something like that, since they are both Java libraries.

Re: ColdFusion & Docx4j

PostPosted: Sat Feb 11, 2012 6:11 am
by jason
ColdBreeze wrote:Are there any examples out there on using docx4j to read/write to placeholders


Search for 'unmarshallFromTemplate'.