I don't see where docFlavor has been instantiated. Satya Venkataraman
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 10, 2002 10:53 AM To: JDJList Subject: [jdjlist] printing html document Hi all, I've a problem with the javax.print package. My application create a html file. I would like print it directly in my app whitout launch a browser. This is my code : PrintService sprint[] = PrintServiceLookup.lookupPrintServices(null ,null); DocPrintJob job = sprint[index].createPrintJob(); FileInputStream fin = null; File file = null; try { file = new File("myfile.html"); fin = new FileInputStream(file ); } catch( IOException ex ) { System.err.println(null,"IOError : " + file.getAbsolutePath() + " : " + ex); return; } HashPrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); aset.add(Chromaticity.MONOCHROME); aset.add(new Copies(1)); aset.add(MediaName.ISO_A4_WHITE); aset.add(OrientationRequested.PORTRAIT); aset.add(new JobName("Impression",null)); DocFlavor docflavor; // This line printed the html code, and only a part of the document. // docflavor = new DocFlavor ("application/octet-stream","java.io.InputStream"); docflavor = DocFlavor.INPUT_STREAM.TEXT_HTML_UTF_16 ; Doc d = new SimpleDoc(fin, docflavor, null); try { Thread.sleep(3000); } catch ( Exception ex ) { System.err.println("Erreur de sleep() : " + ex ); } try { System.out.println("Activation du job.............>>"); System.out.println("DocFlavor :" + docflavor.getMediaSubtype()); System.out.println("DocFlavor :" + docflavor.getMediaType() ); System.out.println("DocFlavor :" + docflavor.getMimeType()); System.out.println("DocFlavor :" + docflavor.getRepresentationClassName()); System.out.println("DocFlavor :" + docflavor.hostEncoding ); job.print(d,aset); } catch(Exception ex) { System.err.println(null,"Erreur durant l'impression : " + ex); return; } Exception returned : sun.print.PrintJobFlavorException : invalid fla vor Can anyone explain me how to print a html document and what's my mistake ? Thanks in advance. Jean-Yves Beaujean Service Informatique CORMAN SA ____________________________________________________ To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm Be respectful! Clean up your posts before replying ____________________________________________________ ____________________________________________________ To change your JDJList options, please visit: http://www.sys-con.com/java/list.cfm Be respectful! Clean up your posts before replying ____________________________________________________
