Accessing PDF files stored in a SQL Server Database
Copy link to clipboard
Copied
Hey gang, need your help. I've tried everything. Here is the situation. I have a client that has stored PDF & Word documents in a SQL Server Database. Now, they want to extract these files and just store them on a file server. The DB column data type where the files are currently stored is set as an "image". So basically they are just storing the files as blobs. The pdf file was originally loaded into the database using a PowerBuilder application that no one knows anything about. The original developer left.
I'm currently using Cold Fusion 9 to try and make this work.
I've been able to access the database no problem. When I write a database query like the following, I get my output:
<CFQUERY NAME="ets_object" DATASOURCE="ets_TSDDB2">
select env_proj_seqn_nbr, obj_seqn_nbr, obj_desc, obj_image
from ets_object
where env_proj_seqn_nbr = 8676 and obj_seqn_nbr = 1
</CFQUERY>
I know in the result set that this file is a PDF. The PDF object is stored in obj_image.
Here is my issue. Every time I try to render the PDF to the screen or write it to a file on the server, I get nothing but garbage.
Here is the code I've used to try and write to the screen:
<cfcontent variable="#ets_object.obj_image#" />
This is what my output looks like (Just posting a few lines):
CONTENTS ���� ������������ ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ hared\DLLShared;d:\Pro �� ����e� ���� ��DEST Acrobat Document AcroExch.Document.7�9�qD:\Program Files\NEON Systems\Shadow\bin;D:\Program Files\Executive Software\Diskeeper\;D:\Program Files\Common Files\Adobe\AGL;D:\Program Files\CA\Unicenter Software
I've tried converting it as a binary, etc..... Nothing seems to be working.
PLEASE HELP.......
Cheers,
bfoster9882
Copy link to clipboard
Copied
Things to try:
1. Set the MIME type to PDF so the browser knows it is getting a PDF file and instruct CF to reset all output prior to your BLOB data like this:
<cfcontent type="application/pdf" variable="#ets_object.obj_image#" reset="yes" />
2. Verify that your CF datasource allows BLOB (image data type) to be queried. Check the "BLOB" option in CFIDE when setting up the datasource.
http://help.adobe.com/en_US/ColdFusion/9.0/Admin/WSc3ff6d0ea77859461172e0811cbf364104-7fe5.html

