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

how to print text file 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
hello
please help me. How to do to print text file? Which Java Class must I use ?
thanks
 
PrinterJob job = new PrinterJob.getPrinterJob();

try{
job.setPrintable(new prn);
job.setCopies(2);
job.print();
}catch(Exception ie){
}



//the inner class

class prn implements Printable{

public int print(Graphics g,PageFormat page,
int pageIndex)throws PrinterException{
g.drawString("your text flows here........",50,50);
if(pageIndex<=1)return PAGE_EXISTS;
else return NO_SUCH_PAGE;
};
}
 
hello
thank you for reply si quickly. My problem is that I must print no a text line but all text file and structure of file (like number of lines) must be preserved. So if i put all my file in string so everything is collapsed. So I'm looking for method for printing not a string but all file...
please help...
 
Hi,

Maybe you would like to take a look at this website. There is this program there that allows you to print a single text file.(7.3.2 Printing a File)

So all you need is just to do a for loop and pass in all the names of the text file to this program and they should be printed out.


Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Thank you zeoliang even this page is help ful to me.

srinivas kandula
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top