Unable to print the document using Java printer Services(JPS)
<p>I have implemented a program, to print the document to the specific printer using IP address, printer name and running fine with out any errors and exception. A printer job is being sent from java, I am able to see this on my local printer print pool, but the page is not printing on printer.</p>

<pre><code>URI myURI=null;
FileInputStream psStream=null;
try   {
    psStream = new FileInputStream("sample.doc");
}
catch ( FileNotFoundException e )   {
    e.printStackTrace();
}
DocFlavor psInFormat = DocFlavor.BYTE_ARRAY.GIF;
Doc myDoc = new SimpleDoc( psStream, psInFormat, null );
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet(); 
PrintService[] services = PrintServiceLookup.lookupPrintServices( psInFormat, aset);
if ( services.length &gt; 0 ) {
    DocPrintJob job = services[0].createPrintJob();         
    try {
        job.print( myDoc, aset);
    }
    catch ( PrintException e ){
    }
}
</code></pre>

<p>Could you please help me out on this?</p>

<p>Thanks,
Srikanth Chilukuri</p>

<hr>

<p>I found the problem.</p>

<pre><code>psStream = new FileInputStream("sample.doc");    
</code></pre>

<p>The above statement creating problem. Because It is MS Word Application, So unable to read the file using File Input Stream.</p>

<p>I am using POI jar and reading the doc.</p>

<pre><code>POIFSFileSystem psStream = new POIFSFileSystem(new FileInputStream(filesname));
Doc myDoc = new SimpleDoc( psStream, psInFormat, null );
</code></pre>

<p>But Doc API is not supporing got IllegalArgumentException</p>

<pre><code>Exception in thread "Main Thread" java.lang.IllegalArgumentException: data is not of declared type
    at javax.print.SimpleDoc.&lt;init&gt;(SimpleDoc.java:82)
    at com.src.print.TestPrint2.main(TestPrint2.java:67)
</code></pre>

<p>Could you please help me out on this.</p>
