views:

687

answers:

4

Hi,

I'm currently making a project where I need to print out a receipt on a receipt printer. At the moment i'm using the CSS mechanism media=screen , media=print to indicate what to print.

Problem is of course the header and footer which can't be removed, as it is client browser specific.

So i'm wondering if anyone has another suggestion on how to do the printing. Preferbly without using too much IO.

A: 

Do you mean the page header and footer?

If that's the case, wrap the header and footer in IDs and create CSS tags to target them and give them a much simpler styling, or you can use the CSS element display:none to remove them altogether in the print css.

cloudhead
+1  A: 

Generally speaking, if you need precise control, your best bet is to have a pdf, or other doocument format that is generated from the server, for your printing. (if the machines printing receipts are controlled, and have word, than .doc (html with an output type) is the easiest method. There are a number of third party controls for generating PDF from server-side code as well. Hope this leads you in a usable direction, since you didn't specify if you controlled the client machines in use.

One benefit to PDF is you can use it as a hard archive, as well as being able to email receipts as an attachment.

Tracker1
Yeah, i think you are right in PDF being the best way to go.
Hotspur
A: 

You could load the content you want to print into an iframe, focus on it, and print that. That way you'll have exact control over what appears on the receipt.

It'd take a small bit of javascript, but I've had success doing similiar things when I wrote a custom contract printer.

Mike Robinson
A: 

The header and footer information (Assuming you're talking about the URL showing up at the bottom of a page) is client-side and there is nothing you can do to change that from server side.

If all of your printing is going to be done from inside your company, you could have a group policy created for Internet Explorer printing to remove these company-wide. You could also just have instructions on your page on how to change these setting manually.

Another option is to print with a 3rd party application, such as PDF, or print it directly from the server if that option is available to you.

AaronS