• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Use CF to write to blob field and convert files

New Here ,
Jul 25, 2009 Jul 25, 2009

Copy link to clipboard

Copied

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?

TOPICS
Advanced techniques

Views

1.9K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Jul 25, 2009 Jul 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).

Votes

Translate

Translate
Valorous Hero ,
Jul 25, 2009 Jul 25, 2009

Copy link to clipboard

Copied

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).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 25, 2009 Jul 25, 2009

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 25, 2009 Jul 25, 2009

Copy link to clipboard

Copied

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).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 26, 2009 Jul 26, 2009

Copy link to clipboard

Copied

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;
pConvObj.CreateInstance(_T("Converter.PDF2Word"));
pConvObj->ConvertToWord (InputFileName,OutputFileName,Password,From,To);

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 !!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 26, 2009 Jul 26, 2009

Copy link to clipboard

Copied

karonson1 wrote:

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...

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 😉

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 26, 2009 Jul 26, 2009

Copy link to clipboard

Copied

Would you have a java snippet that  would do the same thing?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 26, 2009 Jul 26, 2009

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 26, 2009 Jul 26, 2009

Copy link to clipboard

Copied

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.?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 26, 2009 Jul 26, 2009

Copy link to clipboard

Copied

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.
http://www.coldfusionjedi.com/index.cfm/2009/2/5/Reading-Office-documents-with-ColdFusion-2

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.

http://livedocs.adobe.com/coldfusion/8/htmldocs/cfobject_13.html
http://www.microsoft.com/downloads/details.aspx?FamilyID=f1fc413c-6d89-4f15-991b-63b07ba5f2e5

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation