Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Print Page Button in ColdFusion

Posted on 2010-08-25
5
Medium Priority
?
1,116 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

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…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

618 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