Solved

cfdocument page breaks for printing

Posted on 2007-11-27
7
684 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
CHALLENGE LAB: Troubleshooting Connectivity Issues

Goal: Fix the connectivity issue in the lab's AWS environment so that you can SSH into the provided EC2 instance.  

 
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

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.

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 …
PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

615 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