Is it possible to convert a Microsoft Word document to PDF with ColdFusion?
-
21-09-2019 - |
Question
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?
Solution
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>
OTHER TIPS
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?
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.