• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Printing HTML file

 
Greenhorn
Posts: 4
Android Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
I have a problem in printing..
I want to print an HTML page on the printer, the file resides on the C:// and I want to send it to the printer,
when I do it i get the source code of the file which i don't want, i want a way to print the the HTML page as it is on the browser
how can I do that??
 
Sheriff
Posts: 22656
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!

If supported, you can use java.awt.Desktop to print any file using its native program:
 
hamzeh hirzallah
Greenhorn
Posts: 4
Android Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks rop it worked for me, but i have a small question,
I want to print the file without the print dialog..
is this doable?
 
Rob Spoor
Sheriff
Posts: 22656
126
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not with that method. It's possible using the Java printing libraries, but then you'll have to format the HTML page yourself. Perhaps you can use a third party library for that.

An alternative that's slightly easier if your HTML isn't too complex, is to use JEditorPane. That one can display simple HTML pages, as long as they are HTML 3.2 compatible. It also inherits a few print methods from JTextComponent. One of these takes a PrintService and only optionally shows a dialog. You can get a PrintService reference by calling PrintServiceLookup.lookupDefaultPrintService().
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic