views:

319

answers:

3

The above question says it all. I know you can create a PDF from an image file or HTML in ColdFusion 8 using CFPDF, but I'm wondering if it's possible to create a PDF from a MS Word document directly - in CF8 or CF9.

Could you import the Word document and convert it to HTML or an image file, and then do the conversion? Or is there a shortcut?

+6  A: 

see Doc: Office file interoperability - Using cfdocument

ColdFusion 9 supports OpenOffice, which uses the cfdocument tag to convert a Word document (.doc format) to PDF.

<cfdocument 
    format="pdf" 
    srcfile="C:\documents\MyDocument.doc" 
    filename="C:\documents\MyDocument.pdf"> 
</cfdocument>
Henry
+1. Bingo. Just be sure to have OpenOffice installed on the server.
Jas Panesar
You can do this in CF8- as well by invoking the OpenOffice Java APIs directly.
Justice
+4  A: 

In CF8, you could probably do something with COM object integration or POI integration, but it would not be simple/straightforward.

Converting it to HTML using Word's save as feature is probably the simplest route using CF8. I'll suggest that Henry has the right idea, though, upgrading to CF9 to take advantage of OO.O integration.

Edit: Thanks to @jarofclay, I now know that the POI CFC wrapper has been updated to include Word docs. I remembered it only supporting Excel, but that's clearly changed. Um, is it too late for me to change my vote for how to do this in CF8?

Ben Doom
Vote for POI too. Actually, it should not be so hard, for example http://www.coldfusionjedi.com/index.cfm/2009/2/4/Reading-Office-documents-with-ColdFusion
Sergii
POI works great.
jarofclay
A: 

I am not at all familiar with CF, but if you can make web service calls from it then try this product. It relies on MS-Office rather than Open Office so provides much better conversion fidelity. It also supports additional formats including Infopath, Excel, PowerPoint etc as well as Watermarking support.

Please note that I have worked on this product so the usual disclaimers apply.

Muhimbi