Skip to main content
New Participant
July 25, 2009
Answered

Use CF to write to blob field and convert files

  • July 25, 2009
  • 1 reply
  • 2257 views

I am trying to use Cold fusion to extract a .doc file from a database and then save it as a .pdf file. Will it work to read it out character by character and then save it as a new file.  Will this work and what is a good routine for it?

This topic has been closed for replies.
Correct answer -__cfSearching__-

Are you asking how to retrieve a blob field from a database and save it to a file -or- how to convert a document to pdf format? If it is the latter, that really has nothing to do with ColdFusion.  There is no built in functionality in CF8 to convert .doc format to .pdf.  So you will need to use an external tool to perform the conversion.  (Though it is possible in CF9 using OpenOffice).

1 reply

-__cfSearching__-Correct answer
Inspiring
July 25, 2009

Are you asking how to retrieve a blob field from a database and save it to a file -or- how to convert a document to pdf format? If it is the latter, that really has nothing to do with ColdFusion.  There is no built in functionality in CF8 to convert .doc format to .pdf.  So you will need to use an external tool to perform the conversion.  (Though it is possible in CF9 using OpenOffice).

karonson1Author
New Participant
July 26, 2009

Thanks,  I was not aware of how to use the Open Office feature in CF 9 at all to do this?  How is it done?  I had thought that I was going to have to use a third party app to do this, or figure a way to pull the characters out of the file and then do a save.  Third party apps will work, but the approval time to use them  is a concern for management.

Inspiring
July 26, 2009

Well technically you would need an external program to do the conversion from one file format to another: OpenOffice.  ColdFusion 9 (which is still in beta) simplifies the process by allowing you to connect to OpenOffice using the cfdocument tag.  I wrote a few entries about the new feature here:

http://cfsearching.blogspot.com/2009/07/cf9-beta-convert-doc-files-to-pdf-if.html

Also another entry that might be of interest talks about using OpenOffice from ColdFusion 8, with the help of the JODConverter

http://cfsearching.blogspot.com/2009/04/coldfusion-in-search-of-wordrtf-to-pdf.html

There are many different options. But which one you choose really depends on teh file formats you are handling (doc,docx,...) and the output quality. But in all cases you will need an external tool  (program, jar, etcetera) to do the conversion.  The .doc and .pdf formats are complex and totally different (ie it is not like converting a simple text file to pdf).