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).
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.
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:
Also another entry that might be of interest talks about using OpenOffice from ColdFusion 8, with the help of the JODConverter
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).
Thank you. I had been tasked to find out if there was a way to do fairly standard, not extreme hihg quality doc and docx conversion to PDF ffor files alrady stored in a database in a blob file. I just did not see that utility in CF at all, and since it is government related, the approval process for new 3rd party software was/is up to a year. It was intimated to me that there was a way to do it, but i have been unable to find anything.
The best I have been able to find is oneparty that has an SDK kit that will allow the embedding of lines in the CF code, apparently,
to permit this to happen, as a sample
ConverterLib::IPDF2WordPtr pConvObj = NULL;
this is my first experience at embedding an SDK in CF. Does this work? And i take it from your last that there just is not a way to do it without a thrid party app in CF
How does the Open Office interface with the third party app?
THANKS SO MUCH !!!
Further, I take it one cannot simply read to characters out of the database into a new file simply with a PDF extension? That seemed too simple and I didn't think the formatting would be preserved.?
No, you cannot. The closest you could get would be to extract the text only. But you would still need an external tool and you would lose all formatting, which does not sound like it meets your requirements.
The reason you cannot just save the document directly is that .doc, .docx and .pdf formats are more than just plain text. They contain a lot of other formatting information (styles, links, images, etcetera). But each file format stores that information in different ways. To give a silly example, think of it like three different languages. You need a program that understands how to say "bold text" or "left aligned" in each language so it can transform the content from one format to another.
As I said, there is no built in tool for performing those conversions in CF. So you are going to need an external program, regardless of which one you choose. Given the restrictions you are working with, have you looked into using Office? (That has to be on the approved list) I do not know how recommended it is, but there is an example in livedocs on connectting to Office from CF. That combined with a pdf plugin might do the trick. Though it does require that Office be installed on the server. I have not done it myself in quite a while, so I do not know if it works or not.
BTW, the general concept of using OpenOffice is similar. You install OpenOffice on the server. Then send conversion requests from CF to OpenOffice. OpenOffice does the conversions and sends the results back to CF.
That looks like C++ code. You can certainly use dll's from CF, if you are more comfortable with that. I tend to use java applications/jars as CF runs on java. So I cannot really help you out there ;-)
Would you have a java snippet that would do the same thing?
The same as the C++ code? No, I am not familiar with that application. Check if they have a java version, most commercial products do. If so, I am sure they have a java sample.