• 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
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

JavaX Printing of HTML

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am trying to print HTML data using the javax.print package
Now, i am having problem defining the 'DocFlavor' ...... not sure what to give

here is the code
=============================
String is="<html> <body> <table> <tr> any Print data</tr> </table> </body></html>";
DocFlavor flavor = DocFlavor.BYTE_ARRAY.AUTOSENSE;
PrintService service = PrintServiceLookup.lookupDefaultPrintService();
DocPrintJob job = service.createPrintJob();
Doc doc = new SimpleDoc(is.getBytes(), flavor, null);
job.print(doc, null);

===================================

here it will print every thing including HTML
if i change the DocFlavor to DocFlavor.BYTE_ARRAY.TEXT.HTML.HOST
it throws a invalid flavor exception.....

It would be great if any one could guid me to print html
Thanks a lot
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used javax.print briefly a few months ago, and I seem to remember that the DocFlavor one uses is determined by what the printer will handle, not what the document is, so AUTOSENSE is the one I went with.
The "flavor exception" is thrown because the printer can't render HTML directly. AUTOSENSE works because the printer engine will figure out what the printer can handle and do the translation.
When you use AUTOSENSE do you get the rendered HTML or the source?
[ April 05, 2006: Message edited by: Joe Ess ]
 
merwin pinto
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When i use AUTOSENSE ...... it just prints the source , and is not able to resolve HTML
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's what I expected. I would expect you would need to render the HTML using an editor pane and print that if you don't just want to print the source.
 
merwin pinto
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess i will do that ... Thanks a lot
 
reply
    Bookmark Topic Watch Topic
  • New Topic