Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Printing a txt file
Printing a txt file [message #373252] Thu, 04 September 2003 15:16 Go to next message
Eclipse UserFriend
Originally posted by: provide_team.yahoo.com

I have a txt file stored on the local file system and I would just like to
print it. I would prefer if I didn't have to open it into the workspace
(the user is not supposed to edit it anyway). Does anyone know how I
could accomplish this?

Thanks
Keith
Re: Printing a txt file [message #373259 is a reply to message #373252] Thu, 04 September 2003 23:01 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: MatthiasBecker.hamburg.de

Hi

i look into the SWT-Doku and (after a few tries) got this little code together:

Display dis=new Display();
Shell shell = new Shell(dis,SWT.BORDER);

//Opening the PrinterDialog to get the printer we want
PrintDialog pdlg=new PrintDialog(shell);
PrinterData pd=pdlg.open();

//Getting the Printer itself
Printer prn=new Printer(pd);

//Creating a GC to draw
GC gc=new GC(prn);

//Initiate job!!!!
prn.startJob("Hallo");

//Start a new (the frst Page)!!!!
prn.startPage();

//Write something
gc.drawText("Test",0,0);

//finish Page!!!!
prn.endPage();

//finish Job!!!!
prn.endJob();

//release all reasources!!!!
gc.dispose();
prn.dispose();

the !!!! determin that they are important *g*
I just played a little with this stuff and have no further knowledge but i hope
it helps. Take a look at the doku for more information.
http://www.eclipse.org/documentation/html/plugins/org.eclips e.platform.doc.isv/doc/reference/api/

Sincerely
Matt
Re: Printing a txt file [message #373499 is a reply to message #373259] Thu, 11 September 2003 14:34 Go to previous message
Eclipse UserFriend
Originally posted by: provide_team.yahoo.com

Thanks!

That will work for now. Ideally, I would just like to print the text file
without having to manually redraw it. But this works and it is better
than nothing.

Keith
Previous Topic:Treeviewer from 2.0 to 2.1
Next Topic:Scrollbar on Multi-Page Editor Page
Goto Forum:
  


Current Time: Thu Nov 06 12:54:55 EST 2025

Powered by FUDForum. Page generated in 0.41103 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top