Link to home
Start Free TrialLog in
Avatar of hefterr
hefterrFlag for United States of America

asked on

Print Page Button in ColdFusion

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
Avatar of JohnHowlett
JohnHowlett
Flag of United Kingdom of Great Britain and Northern Ireland image

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>
Avatar of hefterr

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of JohnHowlett
JohnHowlett
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hefterr

ASKER

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:

https://www.experts-exchange.com/questions/25271624/Print-a-Coldfusion-Page.html

Thanks for your help!!!
hefterr
Avatar of hefterr

ASKER

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