Is it possible to use iframe within cfdocument?

Posted on 2007-07-24
Last Modified: 2013-12-24

History: In my online application, users view records from a MS Access database - these records have .pdf attachments associated with them.  I have the .pdf file displayed (via iframe) along with the record set, all showing on one web page.  It works great.

Now, I've created a button which the user will click to see a printable version of the record set they are interested in printing.  It's important to have the .pdf file print together with the record set, however the code breaks when I add iframe.  Is it not possible to have iframe within the cfdocument tags?  I've searched on Google and on EE and haven't found anything definitive.  Maybe I'm not searching with the right words.

Hopefully that makes sense.  I've pasted the code below:

<cfdocument format="pdf" backgroundvisible="no" orientation="portrait" pagetype="letter">
<!--- Display record set --->
  <table align="center" width="90%" border="1" cellspacing="0" cellpadding="10" bordercolor="#000000">
    <td align="left">
        <cfoutput query="qGetRCN">
      RCN#rcnChangeNum# DATE: #dateFormat(rcnDate, "mm/dd/yyyy")#<br><br>
        <cfif qGetAttach.recordCount GT 0>
                <cfoutput query="qGetAttach">
                <iframe src ="#location#/#qGetAttach.fileName#" scrolling="yes" height="1200" width="1000"></iframe>
Question by:RTayefeh
    LVL 9

    Expert Comment

    I've not been able to get this working either.  Have you tried just using a cfinclude to the get the other pdf inserted into the pdf you are createing with the cfdocument.
    LVL 14

    Expert Comment

    An Iframe will work within a cfdocument. try this simple example:

    <cfdocument format="pdf" backgroundvisible="no" orientation="portrait" pagetype="letter">

    <iframe src ="testiframe.cfm" scrolling="yes" height="1200" width="1000"></iframe>


    then in testiframe.cfm put:

    <b>If this text appears in my pdf then it works</b>

    So your problem is probably being caused because the iframe is including a pdf insdtead of html. The cfdocument tag turns html into pdf (for flashpaper) format. It may be breaking when it encounters the pdf data instead of html it is trying to convert.
    LVL 14

    Expert Comment

    just in confirmation I tried my same code but including a pdf file and sure enough I get an error. is this the error you are getting?

    Error Occurred While Processing Request  
    The document has no pages.  
    The error occurred in C:\Inetpub\seesroot\seesweb\scotttemp\cfdocumenttest.cfm: line 1
    1 : <cfdocument format="pdf" backgroundvisible="no" orientation="portrait" pagetype="letter">
    2 :
    3 : <iframe src ="userguide.pdf" scrolling="yes" height="1200" width="1000"></iframe>

    LVL 9

    Expert Comment

    Right.  I've used iframes within cfdocument, but not in trying to pull in a pdf with a iframe within the cfdocument tags.
    LVL 14

    Accepted Solution

    and if I try the same thing using format="flashpaper" in my cfdocument tag then I don't get the CF error but I get a javascript error in my browser and it doesn't show any flashpaper.

    I also tried using cfinclude but that didn't work for me.

    Based on the testing I have done, I'm going to say the answer is that you can't include a pdf file within a cfdocument tag.
    LVL 9

    Assisted Solution

    I agree with SBennett - at a guess this would cause the same error with any binary object data (i.e. anything that is not textural in nature).  

    The way that CFDOCUMENT works is to translate and display/encode - the same as a web browser does - so you're fine with plain text, HTML, XML, bitmaps (gif/jpeg/png), etc. but as soon as it's a different MIME type or you need a separate application/plugin to view/manipulate the thing being included in it... you get the error message!

    Author Comment

    Thanks everyone for the help.  I was afraid it wouldn't work, but I just had to ask.  I didn't get the exact errors that you all got, in fact it did try to create a pdf but it wasn't right - it was of a log in screen several pages before (which is, in itself weird).  Anyway, I split the points because SBennett verified that it can't be done and digicidal offered an explanation as to why.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Introduction (All good things must come to an end ( The original MySQL API ( has gone away, deprecated by PHP in Version 5.5, and removed from PHP in all curre…
    Using Quotation Marks in PHP This question ( seems to come up a lot for developers who are new to PHP.  And it got me thinking, "How can we explain the rule…
    This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now