Skip to main content
WolfShade
Legend
January 14, 2013
Answered

CF9 - display binary from database as inline PDF

  • January 14, 2013
  • 1 reply
  • 3486 views

Hello, everyone.

Is it possible to get binary data from C/BLOB and display it as an inline PDF?  Not to download, just embed it in HTML/CFML?

Thank you,

^_^

    This topic has been closed for replies.
    Correct answer Tim Cunningham

    You may try cfcontent rather than cfdocument

    Sent from my iPhone

    1 reply

    Tim Cunningham
    Participating Frequently
    January 14, 2013

    You should be able to have it download using cfheader

    <!--- USES THE VARIABLE DEFINED ABOVE TO CREATE THE PDF USING CF TAGS --->
    <cfheader name="Content-Disposition" value="inline; filename=Test.pdf">
    <cfdocument format="pdf">
     
    <cfoutput>
      #tobase64(myquery.PDFhtml)#
     
    </cfoutput>
    </cfdocument>

    WolfShade
    WolfShadeAuthor
    Legend
    January 14, 2013

    Hi, Tim.

    Thank you for your idea.  I'm closer, but getting an odd result.

    No matter which PDF I try to display, it's loading in the PDF plugin for the browser, but every one is nothing but one line of characters (identical for each PDF.)  Looks like just a jumble of letters (upper and lower case) and numbers.  No actual PDF.  I've tried "toBase64()" and "binaryEncode(column,'base64')", same result.  Is there something else I should be doing?

    Thank you,

    ^_^

    Tim Cunningham
    Tim CunninghamCorrect answer
    Participating Frequently
    January 14, 2013

    You may try cfcontent rather than cfdocument

    Sent from my iPhone