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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Positioning section for Print 1

Status
Not open for further replies.

tripwater

Programmer
Oct 13, 2004
12
US
I am building a invoice report from an XML file and converting it to XHTML to display it. What I need to know is, how can I guarantee that certain info is always printed at the bottom of the page.

The invoice is dynamic and can sometimes have pages of notes, or service items and when it gets printed, I always need the totals section to print on the bottom of the page even if it is the only thing on the last page. So how can I do this using CSS (absolute/relative positioning) or Javascript?

Thank you for any help with this.
 
I don't really follow. You want the totals section to print at the bottom of every page?
 
No I want it to print at the bottom of what ever page it ends up on even if it is the only thing there. See what is happening is that we have a windows application that generates reports and they are very clean and neat and certain info has relative X,Y coords to make sure certain sections do not get split up and part of it gets printed on one page then the rest on the next. Now, we are trying to convert all of the data over to XML so others can have access to the data.

So no matter what, the end result needs to have the totals section print at the bottom of the last page. If there is not enough room to fit it then I need it to move to another page by itself and print at the bottom so it is always consistent.

I hope this clears it up. Thanks
 
Ok Below is my XSL code (just for the section I need to be at the bottom). There is a great deal of potential info that could be before this code as it is dynamic. I need all of the below code to print at the bottom of the last page whether there is info above it or not.

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:template match="/">
  <html>
  <body>
<!--***********************************************************************-->
	<!--***********************************************************************-->
	<!--***********************************************************************-->
	<!--***********************************************************************-->
	<!--Invoice Summary-->
	
	<table width="80%" border="1">
		<tr>
			<td>
			
				<table>
					<tr>
						<td align="center">
							Shipping Charges
						</td>
						<td align="center">
							Ship Via
						</td>
						<td align="center">
							Labor
						</td>
						<td align="center">
							Pickup & Delivery
						</td>
						<td align="center">
							Shop Materials
						</td>
						<td align="center">
							EPA Charge
						</td>
						<td align="center">
							Restocking Fee
						</td>
					</tr>
					<tr>
						<td align="center" width="20%">
							<b>$<xsl:value-of select="invoice/summary/shipping"/></b>
						</td>
						<td align="center">
							<b><xsl:value-of select="invoice/summary/shipvia"/></b>
						</td>
						<td align="center">
							<b><xsl:value-of select="invoice/summary/labor"/></b>
						</td>
						<td align="center">
							<b><xsl:value-of select="invoice/summary/pickup_delivery"/></b>
						</td>
					</tr>
				</table>
				
			</td>
		</tr>
	</table>
	<table width="80%" border="1">
		<tr valign="top">
			<td width="33%">
			
				<table>
					<tr>
						<td>
							S/O Items : $<xsl:value-of select="invoice/summary/soitems"/> 
						</td>
					</tr>
					<tr>
						<td>
							S/O Shipping : $<xsl:value-of select="invoice/summary/soship"/> 
						</td>
					</tr>
					<tr>
						<td>
							<br/>
						</td>
					</tr>
					<tr>
						<td>
							S/O Tax : $<xsl:value-of select="invoice/summary/sotax"/> 
						</td>
					</tr>
					<tr>
						<td>
							S/O Total : $<xsl:value-of select="invoice/summary/sototal"/> 
						</td>
					</tr>
					<tr>
						<td>
							<b style="font-size:16px">S/O Deposit Amt : $<xsl:value-of select="invoice/summary/sodeposit"/></b>
						</td>
					</tr>
				</table>
				
			</td>
			<td width="33%">
				
				<table>
					<tr>
						<td>
							Taxable Items : $<xsl:value-of select="invoice/summary/taxableitems"/> 
						</td>
					</tr>
					<tr>
						<td>
							Non Taxable Items : $<xsl:value-of select="invoice/summary/nontaxitems"/> 
						</td>
					</tr>
					<tr>
						<td>
							<br/>
						</td>
					</tr>
					<tr>
						<td>
							<br/>
						</td>
					</tr>
					<tr>
						<td>
							Tax : $<xsl:value-of select="invoice/summary/tax"/> 
						</td>
					</tr>
					<tr>
						<td>
							Sub Total : $<xsl:value-of select="invoice/summary/subtotal"/>
						</td>
					</tr>
				</table>
				
			</td>
			<td width="33%">
				
				<table>
					<tr>
						<td>
							<b>Transaction Total : $<xsl:value-of select="invoice/summary/total"/></b>
						</td>
					</tr>
					<tr>
						<td>
							<b>Payment Method : $<xsl:value-of select="invoice/summary/paymethod"/></b>
						</td>
					</tr>
				</table>
				
			</td>
		</tr>
	</table>
	
	<table width="80%">
		<tr>
			<td align="right">
				<b style="font-size:18px">Balance Due : $<xsl:value-of select="invoice/summary/balance"/></b>
			</td>
		</tr>				
	</table>
	
	Sales Rep : <xsl:value-of select="invoice/summary/salesrep"/>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>


Thanks
 
So, you're printing directly from the HTML page? What determines how your pages are seperated? Or do you have a seperate printing stylesheet? Have you looked at using XSL-FO?
 
That's my problem I guess. I have never set anything like this up and I do not have anything determining how my pages are separated. I really do not know how to do that. So I am assuming you mean there is a way to determine that there is enough info on the page to add a page break? How do you do this with a dynamic solution?

Thank you again.
 
If you are able to, I would spend a little time looking at XSL-FO. You would use XSL to transform your XML into XSL-FO. This format is used primarily for printing and/or producing PDF's. It will automatically assign page breaks for you and allow you to link chunks of text together and place them where you want. As always, w3schools is a decent starting point:


For some more info on page breaks and tables with XSL-FO:


The alternative would produce a separate printing stylesheet (media="print") for your HTML that could possibly do the job, but you probably need to use some hacky javascript to achieve what you want. XSL-FO would be a much cleaner and more extensible solution. Plus you could create some nice PDF's too.

Jon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top