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
Solved

Print Page Button in ColdFusion

Posted on 2010-08-25
5
987 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

860 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