• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1590
  • Last Modified:

Coldfusion: display TIFF blob as a PDF

I must read a blob (a TIFF image) from an Oracle database and display it in a browser as a PDF. I write the blob to a TIFF file, then use <cfdocument> to display the TIFF image as a PDF. The second step is very slow, and on the largest blobs there is not enough memory:

java.lang.OutOfMemoryError: Java heap space.

Converting TIFF to PDF in ImageMagick from ColdFusion is even slower.

Is there a better way to do this in ColdFusion?

Here is my code:

<cfimage action="write" source="#queryName.theTIFFblob#" destination="newfile.tif" > 
<cfdocument format="pdf" >
    <img src="newfile.tif">

Thank you.
  • 2
2 Solutions
Been working with cfdocument/cfimage pretty extensively for a while now.  I hope someone can prove me wrong, but the cfimage tag has it's limits.  Sounds like you're hitting them.  Specific tasks (like resizing) can take FOREVER for the tag to keep up.  There's a few studies that I've seen regarding times that it can take to complete requests for the cfimage tag and none of them are blazing fast.  You can reduce quality in some cfimage cases to speed up the function, but in the end it's no photoshop.  I have some functions that take over 5 minutes to complete.  In my case though, I'm actually able to schedule the function to run instead of making people wait for it, so it works out for my needs.  Maybe that's a workaround for you too.
Pretty sure you can just use cffile to write out that blob:

<cffile action="write" output="#queryName.theTIFFblob#" file="newfile.tiff" >

I know cfimage has its limits but in this example your not manipulating it in any way that will stress the server.  I woudl say its the PDF generation thats causeing the issue.

2 things I would try.  In cfadmin bump up the ram to 1024mb

Upgrade the JDK to 1.6.10 atleast preferable 1.6.13
eejonesAuthor Commented:
galadore and Jones911:

Thanks to you both. I suspected there was a limitation to the tools but hoped to get that confirmed by experts before considering other methods.

Jones911 I upped the CF ram to 1024mb and still hit the wall.

galadore if I find no other solution I may do the conversion offline, using cfschedule perhaps, and email it to the user.

eejonesAuthor Commented:
I do not think there is a solution - in the end we are using a different tool than ColdFusion image processing (Java)  -  but the comments were helpful. Thanks for the input to both of you.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now