Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

cfdocument page breaks for printing

Posted on 2007-11-27
7
Medium Priority
?
691 Views
Last Modified: 2012-06-27
I have the following code but want to use the cfdocument tag so that when someone prints, it will know to break the page at the bottom and create a new page without splitting up rows also putting the header with name etc, just on the top of each page. Any suggestions?
<cfif session.locationselect eq 'please select'>
<cfset session.locationselect = 'n/a'>
</cfif>
<cfquery name="calPrint" datasource="hgram_med">
SELECT * from calendar 
</cfquery>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<cfoutput>
<title>Clinical Calendar // Date: #url.startDate# - #url.endDate# // Company: #session.companySelect# // Clinic: #session.locationSelect#</title>
</cfoutput>
<style type="text/css">
<!--
body,td,th {
	font-family: Arial, Helvetica, sans-serif;
	font-size: 11px;
}
td
{
	border-color:#999999;
	border-width: 1px 0 0 1px;
	border-style: solid;
	margin: 0;
	padding: 4px;
	position: relative;
}
table{
border-width:0px 1px 0px 0px;
border-color:#999999;
border-style: solid;
 
}
@media print {
* {
  background-color: inherit;
  background-image: inherit;
}
 
-->
</style>
<script>
function printPage()
{
	window.print();
}
</script>
</head>
 
<body>
 
 
<cfoutput>
<table width="700" border="0" cellpadding="0" cellspacing="0">
<tr>
    <td align="right" colspan="10" bgcolor="eeeeee"><a href="##" onclick="printPage();">Print Calendar</a></td>
  </tr>
    <tr>
    <td colspan="10" bgcolor="eeeeee">Date: <strong>#url.startDate# - #url.endDate#</strong> Company: <strong>#session.companySelect#</strong> Clinic:<strong> #session.locationSelect#</strong> Provider: <strong>#session.nurseSelect#</strong></td>
  </tr>
  </cfoutput>
<cfoutput query="calPrint">
 
  <tr>
    <td bgcolor="##cccccc"><strong>Time Beg.</strong></td>
    <td bgcolor="##cccccc"><strong>Time End</strong></td>
    <td colspan="2" bgcolor="##cccccc"><strong>Name</strong></td>
    <td bgcolor="##cccccc"><strong>MemberNumber</strong></td>
    <td bgcolor="##cccccc"><strong>Company</strong></td>
    <td bgcolor="##cccccc"><strong>Location</strong></td>
    <td bgcolor="##cccccc"><strong>Provider</strong></td>
    <td bgcolor="##cccccc"><strong>Duration</strong></td>
  </tr>
 
<tr bgcolor="##ffffff">
    <td>#timeFormat(calPrint.timeBeg, 'hh:mm tt')#&nbsp;</td>
    <td>#timeFormat(calPrint.timeEnd, 'hh:mm tt')#&nbsp;</td>
    <td colspan="2" >#calPrint.lstnam#, #calPrint.fstnam#&nbsp;</td>
    <td>#calPrint.membno#&nbsp;</td>
    <td>#calPrint.company#&nbsp;</td>
    <td>#calPrint.location#&nbsp;</td>
    <td>#calPrint.provider#&nbsp;</td>
    <td>#calPrint.duration#</td>
  </tr>
  <tr>
    <td colspan="100%">Notes:<br />
      #calPrint.callnotes#</td>
  </tr>
    <tr>
    <td align="right" colspan="10" bgcolor="eeeeee">&nbsp;</td>
  </tr>
  </cfoutput>
 
</table>
</body>
</html>

Open in new window

0
Comment
Question by:judsonmusic
  • 4
  • 3
7 Comments
 
LVL 6

Expert Comment

by:reitzen
ID: 20362475
Your question may have been answered in a previous post.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Cold_Fusion_Markup_Language/Q_22925535.html

If your question is different from this post, please expand your question to include  a little more detail of what you are trying to achieve.

HTH
Rob
0
 
LVL 3

Author Comment

by:judsonmusic
ID: 20398516
Thats all of my code. I am trying to print whats in the output query, It has a tendency to be long to long so  Iwant someway to do a page break and reqrite the top header over to the next apge again, or just write the whole thing to a PDF somehow. make sense???

Judson
0
 
LVL 6

Expert Comment

by:reitzen
ID: 20398666
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Cold_Fusion_Markup_Language/Q_22925535.html

Makes complete sense.  I believe this post should give you the solution you are looking for.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 3

Author Comment

by:judsonmusic
ID: 20402627
that doesnt seem to work, here is my code where would I put this?


<cfoutput query="calPrint">
<tr bgcolor="##ffffff">
    <td>#timeFormat(calPrint.timeBeg, 'hh:mm tt')#&nbsp;</td>
    <td>#timeFormat(calPrint.timeEnd, 'hh:mm tt')#&nbsp;</td>
    <td colspan="2" >#calPrint.lstnam#, #calPrint.fstnam#&nbsp;</td>
    <td>#calPrint.membno#&nbsp;</td>
    <td>#calPrint.company#&nbsp;</td>
    <td>#calPrint.location#&nbsp;</td>
    <td>#calPrint.provider#&nbsp;</td>
    <td>#calPrint.duration#</td>
  </tr>
  <tr>
    <td colspan="100%">Notes:<br />
      #calPrint.callnotes#
      <br />
<br />
</td>
  </tr>
    <tr>
    <td align="right" colspan="10" bgcolor="dddddd" style="height:2px; border-bottom-color:666666; border-bottom-style:solid; border-bottom-width:12px;"><p style="font-size:1px; color:white;">1</p></td>
  </tr>

  </cfoutput>
0
 
LVL 6

Accepted Solution

by:
reitzen earned 2000 total points
ID: 20404413
As the previous solution states, you'll need to determine ahead of time if any of your fields will wrap. This will affect when you insert a page break.  Let's assume you have no fields that will wrap. Something like this should do the trick:
<cfset variables.iMaxRows = 20/>
<cfset variables.iLineCounter = 0/>
 
<cfoutput query="calPrint">
<tr bgcolor="##ffffff">
    <td>#timeFormat(calPrint.timeBeg, 'hh:mm tt')#&nbsp;</td>
    <td>#timeFormat(calPrint.timeEnd, 'hh:mm tt')#&nbsp;</td>
    <td colspan="2" >#calPrint.lstnam#, #calPrint.fstnam#&nbsp;</td>
    <td>#calPrint.membno#&nbsp;</td>
    <td>#calPrint.company#&nbsp;</td>
    <td>#calPrint.location#&nbsp;</td>
    <td>#calPrint.provider#&nbsp;</td>
    <td>#calPrint.duration#</td>
  </tr>
  <tr>
    <td colspan="100%">Notes:<br />
      #calPrint.callnotes#
      <br />
<br />
</td>
  </tr>
    <tr>
    <td align="right" colspan="10" bgcolor="dddddd" style="height:2px; border-bottom-color:666666; border-bottom-style:solid; border-bottom-width:12px;"><p style="font-size:1px; color:white;">1</p></td>
  </tr>
 
 
   <cfset variables.iLineCounter = variables.iLineCounter + 1/>
   <cfif variables.iLineCounter EQ variables.iMaxRows>
      <br style="page-break-before: always"/> <!-- This can be set in css -->
      <cfset variables.iLineCounter = 0/>
   </cfif>
 
</cfoutput>

Open in new window

0
 
LVL 3

Author Comment

by:judsonmusic
ID: 20413245
what is the purpose of the variables scope?
0
 
LVL 6

Expert Comment

by:reitzen
ID: 20413351
A variable is a container that holds a piece of information that can be used anywhere in your code.  Scoping your variables makes the code easier to read and helps speed up your pages (a little).  It also ensures that you will not step on a variable of the same name in a different scope.  Furthermore, it makes site-wide updates easier if you set global variables.

By scoping your variables, you could have two more variables with the same name:
FORM.myVariable
URL.myVariable
REQUEST.myVariable

Here is an article that helps explain this concept
http://www.communitymx.com/content/article.cfm?cid=9A169

Also, if you search livedocs for variable scope, you can get more info.

HTH
Rob
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Loops Section Overview
Suggested Courses

916 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