Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

cfdocument page breaks for printing

Posted on 2007-11-27
7
Medium Priority
?
687 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
Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

 
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

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.

Question has a verified solution.

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

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…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

715 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