Solved

Print Page Button in ColdFusion

Posted on 2010-08-25
5
938 Views
Last Modified: 2013-12-24
Hi,
I'm sure I'm not the first to ask this so please be patient.

I have a dynamic "Order Detail" page that I would like to have the user be able to print using a PRINT button.

To do this I will need a "printer friendly" version of the page without the header/footer and some graphic border changes.

I can create a separate CF template (for printing) and dynamically build the page again when the PRINT button is hit - BUT there is a small chance that the data could change in between.

How is this done with dynamic pages - to create printer friendly versions without rebuilding the data in CF.  Is CFdocument involved?

Thanks in advance (but confused)
hefterr
0
Comment
Question by:hefterr
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:JohnHowlett
ID: 33526126
Link the print button to a new page and wrap the cfdocument tag around your current page to output the page as a [printer friendly] pdf:


<cfdocument format = "PDF" pagetype = "A4" orientation = "portrait">
    <cfinclude template="[Your_original_file].cfm" />
</cfdocument>
0
 
LVL 1

Author Comment

by:hefterr
ID: 33526213
Hi JohnHowlett,
Thanks for an answer so quickly.

I am basically doing this - but the new page retrieves again the data from the DB and it's possible an order status (for example) has changed when re-retrieved by the new page.  It's not just making it printer friendly - but also keeping the data the same.

hefterr
0
 
LVL 4

Accepted Solution

by:
JohnHowlett earned 500 total points
ID: 33526267
OK. In which case I would try and save the information to a file - which is later called upon to print within the cfdocument tag.

To save the content:
<cfsavecontent variable = "theContent">
...
[currrent cfm page]
...
</cfsavecontent>

Then save the variable 'theContent' to a file (probably best to save it to an html file), using cffile.
If the Print button is pressed, then use cfdocument:

<cfdocument format = "PDF" pagetype = "A4" orientation = "portrait">
    <cfinclude template="[Your_saved _html_file].html" />
</cfdocument>

0
 
LVL 1

Author Comment

by:hefterr
ID: 33527320
Hi JohnHowlett:
I guess one way or another you have to save the "state" of the data in advance in case the print button is subsequebtly hit.  Can you use the "cfsavecontent" and also output a page at the same time with the same HTML/CF?

This sounds like high overhead as the print page button will not be frequently used.  I found another post on EE using a bit of Javascript that may help out:

http://www.experts-exchange.com/Web_Development/Software/ColdFusion_Studio/Q_25271624.html

Thanks for your help!!!
hefterr
0
 
LVL 1

Author Comment

by:hefterr
ID: 33531343
I guess my question is also "best practices".

Is it acceptable to go to (or pop up) a separate window that "rebuilds" the page with simpler formating (omit the header/footer and remove certain graphics). for printing?  The downside, is that the data could possible change from the original page if (for example) the status of an order changed?

Or is this technique (I mentioned) a standard procedure on sites that provide "printer friendly version" button on a page.  The interval is very small (I would imaging) between showing the original page and rebuilding the page if the user hits the "printer friendly" button.

Thanks in advance,
hefterr
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
A short film showing how OnPage and Connectwise integration works.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

919 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

14 Experts available now in Live!

Get 1:1 Help Now