Solved

cfdocument page breaks for printing

Posted on 2007-11-27
7
680 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
[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
  • 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
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 500 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

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 …
Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 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