How to print coldfusion page which has an <include> tag

I have a coldfusion page which uses an include tag. It works perfectly, but the resulting page on the screen, when printed, does not print that part of the page which is generated by the include tag. Is there a workaround for this ?

many thanks

james
jameskaneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Gurpreet Singh RandhawaCEOCommented:
You should be able to print it

do it something like this:

copy your include file like this:

Assuming your code is like this below:

<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center" bordercolor="#D6D0BF" style="font-family:verdana;">
            <tr style="background:#D6D6D6;">
              <td><strong>Plan</strong></td>
            </tr>
            <tr>
              <td><cfinclude template="abc.cfm"></td>
            </tr>
          </table>

Open in new window


Change it like the below one and it should give you the print you need.

<cfsavecontent variable="a">
<cfinclude template="abc.cfm">
</cfsavecontent>

<table border="0" cellpadding="0" cellspacing="0" width="100%" align="center" bordercolor="#D6D0BF" style="font-family:verdana;">
            <tr style="background:#D6D6D6;">
              <td><strong>Care Plan</strong></td>
            </tr>
            <tr>
              <td><cfoutput>#a#</cfoutput></td>
            </tr>
          </table>

Open in new window


he above will print your included file content :


As a side note, cfinclude should print the contents, do not why this is happening, if the above does not work please provide the included file information
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SidFishesCommented:
It's important to remember how cfinclude works


if you have an include file with the following

include.cfm
-----------
this is the include
-----------

When CFserver sees your page with the include

Main.cfm
<body>
here's the main page
<cfinclude template="include.cfm">
</body>

the include is "read" by the server and inserted into main.cfm as plain html (with JS & CSS if used) producing:

Main.cfm
<body>
here's the main page
-----------
this is the include
-----------
</body>

this is then passed on to the webserver and then on to the client. neither the webserver nor the client have -any- idea that an include happened,. To them it is simply a static webpage. You can see this by simply looking at View Source of the final page in your browser. There are no cf tags at all. This is  in fact the way all cftags function.

So, your issue can not be a problem with cfinclude as such.

You almost certainly have an issue with either invalid html (due to an unclosed tag or similar) or invalid css.

Now it -is- possible that your include is breaking html or css, but that's not an issue with the tag, just how you have it set up.

Look at view source and see if you can determine the issue. One thing that can help is to copy & paste the view source code into http://validator.w3.org/#validate_by_input 

This can help you diagnose where your html is broken.

You can do the same with CSS here http://jigsaw.w3.org/css-validator/#validate_by_input (but that won't validate inline css)
0
jameskaneAuthor Commented:
Thanks  myselfrandhawa, that did the trick for me.

James
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.