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

Is it possible to use iframe within cfdocument?


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>
2 Solutions
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.
Scott BennettManager TechnologyCommented:
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.
Scott BennettManager TechnologyCommented:
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>

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Right.  I've used iframes within cfdocument, but not in trying to pull in a pdf with a iframe within the cfdocument tags.
Scott BennettManager TechnologyCommented:
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.
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!
RTayefehAuthor Commented:
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.

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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