Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Non-printing output - possible? 1

Status
Not open for further replies.

CHeighlund

Programmer
Jun 11, 2007
163
0
0
US
I'm working on a set of reports, and my boss has requested that I create a visual matchup the lines between report item and associated score by using a chain of periods.

Here, might be easier to show this way:
Code:
Before:
Report Item                               Item Value
Report Item                               Item Value
Report Item                               Item Value
Report Item                               Item Value

After:
Report Item.........................      Item Value
Report Item.........................      Item Value
Report Item.........................      Item Value
Report Item.........................      Item Value
All items and values are inside a table for formatting purposes.

The reports are supposed to be both web-viewable and print capable. However, the difference in resolution creates a problem between the two when it comes to keeping things neat. If I try to stick enough dots in to make it look good on the screen, it causes annoying wrap chains on the page. If set up for the printout, there's a gap of about a third of the screen between the last dot and the associated value on the monitor.

My question regarding this is: Is there some way to code in text in a php page where it will appear on the screen, but won't be shown when that page is printed?
 
you can use a monospace font.
or you could use css to style the border of a span or floated div or whatever. i'd go with this solution.
 
Why not give a customized print option (may be a button) which gives a printable output, so can keep both web viewable and printable formats.

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Not sure how you would get the dotted lines to end at the same place all the time on the client side. But I know with PHP you could do something like this.

Code:
function appendstar($string, $length)
{
	$strlen = strlen($string);
	$newstring = $string;
	for($i = 1; $i <= ($length - $strlen); $i++)
	{ $newstring.= "*"; }
	return $newstring;
}
the string should now have trailing * but keep the same width of characters as the previous line.

As for the web side of things. You could always use CSS and not even bother with tables. Take a table-less form for example.

CSS code (you could do the same just only use labels, and you can make a different one with media="print" for the printout view)
Code:
		<style media="screen" type="text/css">
			.contact
			{
				width: 500px;
			}
			.contact label,input {
				float: left;
				margin-bottom: 10px;
				font-family: "Courier New", Courier, monospace;
				font-size: 12px;
			}

			.contact label {
				text-align: left;
				width: 250px; //default width you can change 	
			}
			
			.contact br {
				clear: left;
			}
		</style>


The HTML
Code:
<!-- the return false is to prevent hitting enter from trying to send "something" despite lack of action parameter -->
 <form class="contact" onsubmit="return false;">
    <label>Report Item #1</label>
    <label style="width: 50px;">Report Value #1</label><BR/>
    <label>Report Item #2</label>
    <label style="width: 50px;">Report Value #2<BR/>
 </form>

You could essentially modify the CSS and HTML to use DIVs instead of Form, and SPANs instead of labels. And using the CSS above I've confirmed works on Firefox 2.0, Opera 9, Safari 3, and IE7. You'll find that each label will be evenly spaced apart and laid out as if it were a table, but without using tables (Working with an XHTML doctype helps fix some of the cross browser issues as opposed to HTML or without a doctype at all).

If this doesn't help, let me know. You can see the above example live here.

The attached url will show you the PHP source behind it.

Karl Blessing
 
@kb244:
Thank you for your advice. I will look into the information you've given me. An additional thanks for the information regarding Courier New.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top