Hi I have made a desktop application and i have to print some data to printer.For this purpose I have done my code

and ran it successfuly and test on xps doucuments and on oneNote . I have no physical printer but i am satisfied

by testing it on xps documents and one note e.t.c.

But actually i have to print receipts and i dont know how to support different receipt printers with my java

application. For example i want to use a Epson TM-T88i receipt printer with my application. So what should i do?
Is there any need to find and download a developer document of this specific printer ? or java automatically finds

it and print content to it as it is , if it is already installed on the computer?

Actually this is first time when i have to support thermal receipt printers with my java application.

Thanx in advance!

Simply something you learn over time. You can't tell folk it will work until you get the printer and test it. There are new to this programmers that will not accept this but time and customer complaints will correct this thinking.

You can also check out https://www.google.com/search?q=Epson+TM-T88iii+printing+from+java

Thanx for your guidance rproffitt. I have visit your provided link , but I am bit confused.

Actually I am not doing a project for specific client , I am developing a product and want to support different receipt printers with it.(which are easily available in the market).

Actually I am doing printing by implementing Printable interface of java. i-e by overridding the Print(Graphics, Pageformat, pageindex) method.

What i actually want is as follows:

I want that first of all i get a list of all the printers by calling printServices methods. Assume that this method gives me names of three printers(1- HP A4 printer, 2- Epson Tm-t88v, 3-CT-S310II thermal line printer)
And assume that i know about paper width of these printers by searching on internet. For example (7cm, 7.5cm, 8cm )respectively.

And then i will made three methods. For example

 @override
PrintForHP(Graphics, Pageformat, pageindex){
// Here i will code that what text to print,
alignment of text and string length by using 
String.format() method, so that data does not
cut off.
}

@override
PrintForEpson(Graphics, Pageformat, pageindex){
// Here i will code that what text to print,
alignment of text and string length by using 
String.format() method, so that data does not
cut off.
}

@override
PrintFor-CT-S310II(Graphics, Pageformat, pageindex){
// Here i will code that what text to print,
alignment of text and string length by using 
String.format() method, so that data does not
cut off.
}

I want that i only know the paper width of the papers and just override the Print(Graphics, Pageformat, pageindex) method for them.
Is that possible? Please guide me.

Can’t you just use the page width that the PrintFormat parameter will give you?

As noted, page width is one way to go at this but the receipts I see today have bar codes, graphics and adverts built in.

My view is without a printer to test with, you just won't know how it will work. I've run into folk that want to do this but didn't have a single receipt printer to test with. Let's hope you are beyond that stage.

Actually I also have no physical printer to test with, so according to you what is the best strategy to tackle this problelm rproffit?

And it seems like that James point is also good. I am thinking that i just get paper width by
using Paper.getWidth(), It will gives me width in points (i-e 1/72 of inch.) For example the width of my page is 612 points at this moment (in xps document) which is equal to 8.5 inches.

Now here I will make a check that if the paper size less than 3 inches then I will call a overridden function "PrintReciept(Graphics, pageFormat, index)". In this function I will align my data by string formatting so that it will properly fit in 3 inch receipt.

And in the else part i will call a overridden function "PrintA4(Graphics, pageFormat,pageIndex )". In this funciton I will align my data by string formatting so that it will properly fit in A4 printer pages.

What do you say rproffitt? Am i thinking right?

It's a start but having seen programmers try to add POS support and not test I can only share the results most of the time.

And it's even worse today. Client expectations are higher than ever. They don't want to be your Alpha or Beta testers. They want it to install and give the results they expected.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.