Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Coldfusion CFPDF reading a binary database column

Can cfpdf read a binary database column directly?

I currently have it where I run a query to get the column.

Use cffile to write the file to a directory

Then read with cfpdf so I can extracttext.

Is it possible to do this without the cffile write and read the binary file directly?

If so, could I get an example.

like image 879
E Paiz Avatar asked Oct 08 '22 18:10

E Paiz


1 Answers

What version are you using? The following worked for me with CF9 / MS SQL (varbinary column)

<cfquery name="getPdf" ....>
    SELECT Data 
    FROM   someTable
    WHERE  ID = 123
</cfquery>

<cfset pdfBinary = getPdf.data[1]>
<cfpdf action="extractText" source="pdfBinary" name="result">
<cfdump var="#result#">

Edit: To clarify, cfpdf complains when you use queryName.columnName as the "source". I suspect cfpdf sees it as a query column object instead of automatically grabbing the value in the query's first row ie queryName.columnName[ 1 ]. The work-around is to create a reference to it, and use the other variable instead.

like image 170
Leigh Avatar answered Oct 12 '22 02:10

Leigh