• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JavaX Printing of HTML

 
merwin pinto
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • 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
 
Joe Ess
Bartender
Posts: 9256
9
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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: 9256
9
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
I guess i will do that ... Thanks a lot
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic