cfdocument page breaks for printing

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

LVL 3
judsonmusicAsked:
Who is Participating?
 
reitzenCommented:
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
 
reitzenCommented:
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
 
judsonmusicAuthor Commented:
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
reitzenCommented:
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
 
judsonmusicAuthor Commented:
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
 
judsonmusicAuthor Commented:
what is the purpose of the variables scope?
0
 
reitzenCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.