import javax.print.*;
import javax.print.attribute.*;
import javax.print.attribute.standard.*;
import javax.print.event.*;

public class  {
    public static void main(String[] args) {
        try {
            // Open the image file
            InputStream is = new BufferedInputStream(
                new FileInputStream("filename.gif"));

            // Find the default service
            DocFlavor flavor = DocFlavor.INPUT_STREAM.GIF;
            PrintService service = PrintServiceLookup.lookupDefaultPrintService();

            // Create the print job
            DocPrintJob job = service.createPrintJob();
            Doc doc = new SimpleDoc(is, flavor, null);

            // Monitor print job events; for the implementation of PrintJobWatcher,
            // see Determining When a Print Job Has Finished
            PrintJobWatcher pjDone = new PrintJobWatcher(job);

            // Print it
            job.print(doc, null);

            // Wait for the print job to be done

            // It is now safe to close the input stream
        } catch (PrintException e) {
        } catch (IOException e) {

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.