Java Code Examples for javax.print.StreamPrintServiceFactory#lookupStreamPrintServiceFactories()

The following examples show how to use javax.print.StreamPrintServiceFactory#lookupStreamPrintServiceFactories() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrintUtils.java    From osp with GNU General Public License v3.0 6 votes vote down vote up
public static void saveComponentAsEPS(Component c) throws IOException {
  // Find a factory object for printing Printable objects to PostScript.
  DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
  String format = "application/postscript"; //$NON-NLS-1$
  StreamPrintServiceFactory factory = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, format)[0];
  // Ask the user to select a file and open the selected file
  //JFileChooser chooser = new JFileChooser();
  JFileChooser chooser = OSPRuntime.getChooser();
  if(chooser.showSaveDialog(c)!=JFileChooser.APPROVE_OPTION) {
    return;
  }
  File f = chooser.getSelectedFile();
  FileOutputStream out = new FileOutputStream(f);
  // Obtain a PrintService that prints to that file
  StreamPrintService service = factory.getPrintService(out);
  // Do the printing with the method below
  printToService(c, service, null);
  // And close the output file.
  out.close();
}
 
Example 2
Source File: PrintSEUmlauts.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        GraphicsEnvironment.getLocalGraphicsEnvironment();

        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
        String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();

        StreamPrintServiceFactory[] factories =
                StreamPrintServiceFactory.
                        lookupStreamPrintServiceFactories(flavor, mime);
        if (factories.length == 0) {
            System.out.println("No print service found.");
            return;
        }

        FileOutputStream output = new FileOutputStream("out.ps");
        StreamPrintService service = factories[0].getPrintService(output);

        SimpleDoc doc =
             new SimpleDoc(new PrintSEUmlauts(),
                           DocFlavor.SERVICE_FORMATTED.PRINTABLE,
                           new HashDocAttributeSet());
        DocPrintJob job = service.createPrintJob();
        job.addPrintJobListener(new PrintJobAdapter() {
            @Override
            public void printJobCompleted(PrintJobEvent pje) {
                testPrintAndExit();
            }
        });

        job.print(doc, new HashPrintRequestAttributeSet());
    }
 
Example 3
Source File: PrintSEUmlauts.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        GraphicsEnvironment.getLocalGraphicsEnvironment();

        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
        String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();

        StreamPrintServiceFactory[] factories =
                StreamPrintServiceFactory.
                        lookupStreamPrintServiceFactories(flavor, mime);
        if (factories.length == 0) {
            System.out.println("No print service found.");
            return;
        }

        FileOutputStream output = new FileOutputStream("out.ps");
        StreamPrintService service = factories[0].getPrintService(output);

        SimpleDoc doc =
             new SimpleDoc(new PrintSEUmlauts(),
                           DocFlavor.SERVICE_FORMATTED.PRINTABLE,
                           new HashDocAttributeSet());
        DocPrintJob job = service.createPrintJob();
        job.addPrintJobListener(new PrintJobAdapter() {
            @Override
            public void printJobCompleted(PrintJobEvent pje) {
                testPrintAndExit();
            }
        });

        job.print(doc, new HashPrintRequestAttributeSet());
    }
 
Example 4
Source File: PrintSEUmlauts.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        GraphicsEnvironment.getLocalGraphicsEnvironment();

        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
        String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();

        StreamPrintServiceFactory[] factories =
                StreamPrintServiceFactory.
                        lookupStreamPrintServiceFactories(flavor, mime);
        if (factories.length == 0) {
            System.out.println("No print service found.");
            return;
        }

        FileOutputStream output = new FileOutputStream("out.ps");
        StreamPrintService service = factories[0].getPrintService(output);

        SimpleDoc doc =
             new SimpleDoc(new PrintSEUmlauts(),
                           DocFlavor.SERVICE_FORMATTED.PRINTABLE,
                           new HashDocAttributeSet());
        DocPrintJob job = service.createPrintJob();
        job.addPrintJobListener(new PrintJobAdapter() {
            @Override
            public void printJobCompleted(PrintJobEvent pje) {
                testPrintAndExit();
            }
        });

        job.print(doc, new HashPrintRequestAttributeSet());
    }
 
Example 5
Source File: PrintSEUmlauts.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        GraphicsEnvironment.getLocalGraphicsEnvironment();

        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
        String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();

        StreamPrintServiceFactory[] factories =
                StreamPrintServiceFactory.
                        lookupStreamPrintServiceFactories(flavor, mime);
        if (factories.length == 0) {
            System.out.println("No print service found.");
            return;
        }

        FileOutputStream output = new FileOutputStream("out.ps");
        StreamPrintService service = factories[0].getPrintService(output);

        SimpleDoc doc =
             new SimpleDoc(new PrintSEUmlauts(),
                           DocFlavor.SERVICE_FORMATTED.PRINTABLE,
                           new HashDocAttributeSet());
        DocPrintJob job = service.createPrintJob();
        job.addPrintJobListener(new PrintJobAdapter() {
            @Override
            public void printJobCompleted(PrintJobEvent pje) {
                testPrintAndExit();
            }
        });

        job.print(doc, new HashPrintRequestAttributeSet());
    }
 
Example 6
Source File: PrintSEUmlauts.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        GraphicsEnvironment.getLocalGraphicsEnvironment();

        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
        String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();

        StreamPrintServiceFactory[] factories =
                StreamPrintServiceFactory.
                        lookupStreamPrintServiceFactories(flavor, mime);
        if (factories.length == 0) {
            System.out.println("No print service found.");
            return;
        }

        FileOutputStream output = new FileOutputStream("out.ps");
        StreamPrintService service = factories[0].getPrintService(output);

        SimpleDoc doc =
             new SimpleDoc(new PrintSEUmlauts(),
                           DocFlavor.SERVICE_FORMATTED.PRINTABLE,
                           new HashDocAttributeSet());
        DocPrintJob job = service.createPrintJob();
        job.addPrintJobListener(new PrintJobAdapter() {
            @Override
            public void printJobCompleted(PrintJobEvent pje) {
                testPrintAndExit();
            }
        });

        job.print(doc, new HashPrintRequestAttributeSet());
    }
 
Example 7
Source File: PrintSEUmlauts.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        GraphicsEnvironment.getLocalGraphicsEnvironment();

        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
        String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();

        StreamPrintServiceFactory[] factories =
                StreamPrintServiceFactory.
                        lookupStreamPrintServiceFactories(flavor, mime);
        if (factories.length == 0) {
            System.out.println("No print service found.");
            return;
        }

        FileOutputStream output = new FileOutputStream("out.ps");
        StreamPrintService service = factories[0].getPrintService(output);

        SimpleDoc doc =
             new SimpleDoc(new PrintSEUmlauts(),
                           DocFlavor.SERVICE_FORMATTED.PRINTABLE,
                           new HashDocAttributeSet());
        DocPrintJob job = service.createPrintJob();
        job.addPrintJobListener(new PrintJobAdapter() {
            @Override
            public void printJobCompleted(PrintJobEvent pje) {
                testPrintAndExit();
            }
        });

        job.print(doc, new HashPrintRequestAttributeSet());
    }
 
Example 8
Source File: PrintSEUmlauts.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        GraphicsEnvironment.getLocalGraphicsEnvironment();

        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
        String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();

        StreamPrintServiceFactory[] factories =
                StreamPrintServiceFactory.
                        lookupStreamPrintServiceFactories(flavor, mime);
        if (factories.length == 0) {
            System.out.println("No print service found.");
            return;
        }

        FileOutputStream output = new FileOutputStream("out.ps");
        StreamPrintService service = factories[0].getPrintService(output);

        SimpleDoc doc =
             new SimpleDoc(new PrintSEUmlauts(),
                           DocFlavor.SERVICE_FORMATTED.PRINTABLE,
                           new HashDocAttributeSet());
        DocPrintJob job = service.createPrintJob();
        job.addPrintJobListener(new PrintJobAdapter() {
            @Override
            public void printJobCompleted(PrintJobEvent pje) {
                testPrintAndExit();
            }
        });

        job.print(doc, new HashPrintRequestAttributeSet());
    }
 
Example 9
Source File: PrintSEUmlauts.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        GraphicsEnvironment.getLocalGraphicsEnvironment();

        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
        String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();

        StreamPrintServiceFactory[] factories =
                StreamPrintServiceFactory.
                        lookupStreamPrintServiceFactories(flavor, mime);
        if (factories.length == 0) {
            System.out.println("No print service found.");
            return;
        }

        FileOutputStream output = new FileOutputStream("out.ps");
        StreamPrintService service = factories[0].getPrintService(output);

        SimpleDoc doc =
             new SimpleDoc(new PrintSEUmlauts(),
                           DocFlavor.SERVICE_FORMATTED.PRINTABLE,
                           new HashDocAttributeSet());
        DocPrintJob job = service.createPrintJob();
        job.addPrintJobListener(new PrintJobAdapter() {
            @Override
            public void printJobCompleted(PrintJobEvent pje) {
                testPrintAndExit();
            }
        });

        job.print(doc, new HashPrintRequestAttributeSet());
    }
 
Example 10
Source File: PrintSEUmlauts.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        GraphicsEnvironment.getLocalGraphicsEnvironment();

        DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
        String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();

        StreamPrintServiceFactory[] factories =
                StreamPrintServiceFactory.
                        lookupStreamPrintServiceFactories(flavor, mime);
        if (factories.length == 0) {
            System.out.println("No print service found.");
            return;
        }

        FileOutputStream output = new FileOutputStream("out.ps");
        StreamPrintService service = factories[0].getPrintService(output);

        SimpleDoc doc =
             new SimpleDoc(new PrintSEUmlauts(),
                           DocFlavor.SERVICE_FORMATTED.PRINTABLE,
                           new HashDocAttributeSet());
        DocPrintJob job = service.createPrintJob();
        job.addPrintJobListener(new PrintJobAdapter() {
            @Override
            public void printJobCompleted(PrintJobEvent pje) {
                testPrintAndExit();
            }
        });

        job.print(doc, new HashPrintRequestAttributeSet());
    }
 
Example 11
Source File: ChartPanel.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
private void createChartPrintPostScriptJob() {
// Use the pre-defined flavor for a Printable from an InputStream 
	DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;

		// Specify the type of the output stream 
	String psMimeType = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();

	// Locate factory which can export a GIF image stream as Postscript 
	StreamPrintServiceFactory[] factories =
	StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
				flavor, psMimeType);
	if (factories.length == 0) {
		System.err.println("No suitable factories");
		System.exit(0); // FIXME too
	}
               // Obtain file name from user
               JFileChooser fileChooser = new JFileChooser();
               ExtensionFileFilter filter = new ExtensionFileFilter(
                       localizationResources.getString("PostScript_Files"), ".eps");
               fileChooser.addChoosableFileFilter(filter);
               String filename="";
               int option = fileChooser.showSaveDialog(this);
               if (option == JFileChooser.APPROVE_OPTION) {
                  filename = fileChooser.getSelectedFile().getPath();
                  if (isEnforceFileExtensions()) {
                     if (!filename.endsWith(".eps")) {
                        filename = filename + ".eps";
                     }
                  } else
                     return;
               }

	try {
		// Create a file for the exported postscript
		FileOutputStream fos = new FileOutputStream(filename);

		// Create a Stream printer for Postscript 
		StreamPrintService sps = factories[0].getPrintService(fos);

		// Create and call a Print Job 
		DocPrintJob pj = sps.createPrintJob();
		PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();

		Doc doc = new SimpleDoc(this, flavor, null);

		pj.print(doc, aset);
		fos.close();

	} catch (PrintException pe) { 
		System.err.println(pe);
	} catch (IOException ie) { 
		System.err.println(ie);
	}

  }
 
Example 12
Source File: PrinterJob.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 3 votes vote down vote up
/**
 * A convenience method which locates factories for stream print
 * services which can image 2D graphics.
 * Sample usage :
 * <pre>{@code
 * FileOutputStream outstream;
 * StreamPrintService psPrinter;
 * String psMimeType = "application/postscript";
 * PrinterJob pj = PrinterJob.getPrinterJob();
 *
 * StreamPrintServiceFactory[] factories =
 *     PrinterJob.lookupStreamPrintServices(psMimeType);
 * if (factories.length > 0) {
 *     try {
 *         outstream = new File("out.ps");
 *         psPrinter =  factories[0].getPrintService(outstream);
 *         // psPrinter can now be set as the service on a PrinterJob
 *         pj.setPrintService(psPrinter)
 *     } catch (Exception e) {
 *         e.printStackTrace();
 *     }
 * }
 * }</pre>
 * Services returned from this method may be installed on
 * <code>PrinterJob</code> instances which support print services.
 * Calling this method is equivalent to calling
 * {@link javax.print.StreamPrintServiceFactory#lookupStreamPrintServiceFactories(DocFlavor, String)
 * StreamPrintServiceFactory.lookupStreamPrintServiceFactories()
 * } and specifying a Pageable DocFlavor.
 *
 * @param mimeType the required output format, or null to mean any format.
 * @return a possibly empty array of 2D stream print service factories.
 * @since     1.4
 */
public static StreamPrintServiceFactory[]
    lookupStreamPrintServices(String mimeType) {
    return StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
                                   DocFlavor.SERVICE_FORMATTED.PAGEABLE,
                                   mimeType);
}
 
Example 13
Source File: PrinterJob.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * A convenience method which locates factories for stream print
 * services which can image 2D graphics.
 * Sample usage :
 * <pre>{@code
 * FileOutputStream outstream;
 * StreamPrintService psPrinter;
 * String psMimeType = "application/postscript";
 * PrinterJob pj = PrinterJob.getPrinterJob();
 *
 * StreamPrintServiceFactory[] factories =
 *     PrinterJob.lookupStreamPrintServices(psMimeType);
 * if (factories.length > 0) {
 *     try {
 *         outstream = new File("out.ps");
 *         psPrinter =  factories[0].getPrintService(outstream);
 *         // psPrinter can now be set as the service on a PrinterJob
 *         pj.setPrintService(psPrinter)
 *     } catch (Exception e) {
 *         e.printStackTrace();
 *     }
 * }
 * }</pre>
 * Services returned from this method may be installed on
 * <code>PrinterJob</code> instances which support print services.
 * Calling this method is equivalent to calling
 * {@link javax.print.StreamPrintServiceFactory#lookupStreamPrintServiceFactories(DocFlavor, String)
 * StreamPrintServiceFactory.lookupStreamPrintServiceFactories()
 * } and specifying a Pageable DocFlavor.
 *
 * @param mimeType the required output format, or null to mean any format.
 * @return a possibly empty array of 2D stream print service factories.
 * @since     1.4
 */
public static StreamPrintServiceFactory[]
    lookupStreamPrintServices(String mimeType) {
    return StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
                                   DocFlavor.SERVICE_FORMATTED.PAGEABLE,
                                   mimeType);
}
 
Example 14
Source File: PrinterJob.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * A convenience method which locates factories for stream print
 * services which can image 2D graphics.
 * Sample usage :
 * <pre>{@code
 * FileOutputStream outstream;
 * StreamPrintService psPrinter;
 * String psMimeType = "application/postscript";
 * PrinterJob pj = PrinterJob.getPrinterJob();
 *
 * StreamPrintServiceFactory[] factories =
 *     PrinterJob.lookupStreamPrintServices(psMimeType);
 * if (factories.length > 0) {
 *     try {
 *         outstream = new File("out.ps");
 *         psPrinter =  factories[0].getPrintService(outstream);
 *         // psPrinter can now be set as the service on a PrinterJob
 *         pj.setPrintService(psPrinter)
 *     } catch (Exception e) {
 *         e.printStackTrace();
 *     }
 * }
 * }</pre>
 * Services returned from this method may be installed on
 * <code>PrinterJob</code> instances which support print services.
 * Calling this method is equivalent to calling
 * {@link javax.print.StreamPrintServiceFactory#lookupStreamPrintServiceFactories(DocFlavor, String)
 * StreamPrintServiceFactory.lookupStreamPrintServiceFactories()
 * } and specifying a Pageable DocFlavor.
 *
 * @param mimeType the required output format, or null to mean any format.
 * @return a possibly empty array of 2D stream print service factories.
 * @since     1.4
 */
public static StreamPrintServiceFactory[]
    lookupStreamPrintServices(String mimeType) {
    return StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
                                   DocFlavor.SERVICE_FORMATTED.PAGEABLE,
                                   mimeType);
}
 
Example 15
Source File: PrinterJob.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * A convenience method which locates factories for stream print
 * services which can image 2D graphics.
 * Sample usage :
 * <pre>{@code
 * FileOutputStream outstream;
 * StreamPrintService psPrinter;
 * String psMimeType = "application/postscript";
 * PrinterJob pj = PrinterJob.getPrinterJob();
 *
 * StreamPrintServiceFactory[] factories =
 *     PrinterJob.lookupStreamPrintServices(psMimeType);
 * if (factories.length > 0) {
 *     try {
 *         outstream = new File("out.ps");
 *         psPrinter =  factories[0].getPrintService(outstream);
 *         // psPrinter can now be set as the service on a PrinterJob
 *         pj.setPrintService(psPrinter)
 *     } catch (Exception e) {
 *         e.printStackTrace();
 *     }
 * }
 * }</pre>
 * Services returned from this method may be installed on
 * <code>PrinterJob</code> instances which support print services.
 * Calling this method is equivalent to calling
 * {@link javax.print.StreamPrintServiceFactory#lookupStreamPrintServiceFactories(DocFlavor, String)
 * StreamPrintServiceFactory.lookupStreamPrintServiceFactories()
 * } and specifying a Pageable DocFlavor.
 *
 * @param mimeType the required output format, or null to mean any format.
 * @return a possibly empty array of 2D stream print service factories.
 * @since     1.4
 */
public static StreamPrintServiceFactory[]
    lookupStreamPrintServices(String mimeType) {
    return StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
                                   DocFlavor.SERVICE_FORMATTED.PAGEABLE,
                                   mimeType);
}
 
Example 16
Source File: PrinterJob.java    From jdk8u-dev-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * A convenience method which locates factories for stream print
 * services which can image 2D graphics.
 * Sample usage :
 * <pre>{@code
 * FileOutputStream outstream;
 * StreamPrintService psPrinter;
 * String psMimeType = "application/postscript";
 * PrinterJob pj = PrinterJob.getPrinterJob();
 *
 * StreamPrintServiceFactory[] factories =
 *     PrinterJob.lookupStreamPrintServices(psMimeType);
 * if (factories.length > 0) {
 *     try {
 *         outstream = new File("out.ps");
 *         psPrinter =  factories[0].getPrintService(outstream);
 *         // psPrinter can now be set as the service on a PrinterJob
 *         pj.setPrintService(psPrinter)
 *     } catch (Exception e) {
 *         e.printStackTrace();
 *     }
 * }
 * }</pre>
 * Services returned from this method may be installed on
 * <code>PrinterJob</code> instances which support print services.
 * Calling this method is equivalent to calling
 * {@link javax.print.StreamPrintServiceFactory#lookupStreamPrintServiceFactories(DocFlavor, String)
 * StreamPrintServiceFactory.lookupStreamPrintServiceFactories()
 * } and specifying a Pageable DocFlavor.
 *
 * @param mimeType the required output format, or null to mean any format.
 * @return a possibly empty array of 2D stream print service factories.
 * @since     1.4
 */
public static StreamPrintServiceFactory[]
    lookupStreamPrintServices(String mimeType) {
    return StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
                                   DocFlavor.SERVICE_FORMATTED.PAGEABLE,
                                   mimeType);
}
 
Example 17
Source File: PrinterJob.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * A convenience method which locates factories for stream print
 * services which can image 2D graphics.
 * Sample usage :
 * <pre>{@code
 * FileOutputStream outstream;
 * StreamPrintService psPrinter;
 * String psMimeType = "application/postscript";
 * PrinterJob pj = PrinterJob.getPrinterJob();
 *
 * StreamPrintServiceFactory[] factories =
 *     PrinterJob.lookupStreamPrintServices(psMimeType);
 * if (factories.length > 0) {
 *     try {
 *         outstream = new File("out.ps");
 *         psPrinter =  factories[0].getPrintService(outstream);
 *         // psPrinter can now be set as the service on a PrinterJob
 *         pj.setPrintService(psPrinter)
 *     } catch (Exception e) {
 *         e.printStackTrace();
 *     }
 * }
 * }</pre>
 * Services returned from this method may be installed on
 * <code>PrinterJob</code> instances which support print services.
 * Calling this method is equivalent to calling
 * {@link javax.print.StreamPrintServiceFactory#lookupStreamPrintServiceFactories(DocFlavor, String)
 * StreamPrintServiceFactory.lookupStreamPrintServiceFactories()
 * } and specifying a Pageable DocFlavor.
 *
 * @param mimeType the required output format, or null to mean any format.
 * @return a possibly empty array of 2D stream print service factories.
 * @since     1.4
 */
public static StreamPrintServiceFactory[]
    lookupStreamPrintServices(String mimeType) {
    return StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
                                   DocFlavor.SERVICE_FORMATTED.PAGEABLE,
                                   mimeType);
}
 
Example 18
Source File: PrinterJob.java    From jdk-1.7-annotated with Apache License 2.0 3 votes vote down vote up
/**
 * A convenience method which locates factories for stream print
 * services which can image 2D graphics.
 * Sample usage :
 * <pre>
 * FileOutputStream outstream;
 * StreamPrintService psPrinter;
 * String psMimeType = "application/postscript";
 * PrinterJob pj = PrinterJob.getPrinterJob();
 *
 * StreamPrintServiceFactory[] factories =
 *     PrinterJob.lookupStreamPrintServices(psMimeType);
 * if (factories.length > 0) {
 *     try {
 *         outstream = new File("out.ps");
 *         psPrinter =  factories[0].getPrintService(outstream);
 *         // psPrinter can now be set as the service on a PrinterJob
 *         pj.setPrintService(psPrinter)
 *     } catch (Exception e) {
 *         e.printStackTrace();
 *     }
 * }
 * </pre>
 * Services returned from this method may be installed on
 * <code>PrinterJob</code> instances which support print services.
 * Calling this method is equivalent to calling
 * {@link javax.print.StreamPrintServiceFactory#lookupStreamPrintServiceFactories(DocFlavor, String)
 * <code>StreamPrintServiceFactory.lookupStreamPrintServiceFactories()
 * </code>} and specifying a Pageable DocFlavor.
 *
 * @param mimeType the required output format, or null to mean any format.
 * @return a possibly empty array of 2D stream print service factories.
 * @since     1.4
 */
public static StreamPrintServiceFactory[]
    lookupStreamPrintServices(String mimeType) {
    return StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
                                   DocFlavor.SERVICE_FORMATTED.PAGEABLE,
                                   mimeType);
}
 
Example 19
Source File: PrinterJob.java    From jdk8u60 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * A convenience method which locates factories for stream print
 * services which can image 2D graphics.
 * Sample usage :
 * <pre>{@code
 * FileOutputStream outstream;
 * StreamPrintService psPrinter;
 * String psMimeType = "application/postscript";
 * PrinterJob pj = PrinterJob.getPrinterJob();
 *
 * StreamPrintServiceFactory[] factories =
 *     PrinterJob.lookupStreamPrintServices(psMimeType);
 * if (factories.length > 0) {
 *     try {
 *         outstream = new File("out.ps");
 *         psPrinter =  factories[0].getPrintService(outstream);
 *         // psPrinter can now be set as the service on a PrinterJob
 *         pj.setPrintService(psPrinter)
 *     } catch (Exception e) {
 *         e.printStackTrace();
 *     }
 * }
 * }</pre>
 * Services returned from this method may be installed on
 * <code>PrinterJob</code> instances which support print services.
 * Calling this method is equivalent to calling
 * {@link javax.print.StreamPrintServiceFactory#lookupStreamPrintServiceFactories(DocFlavor, String)
 * StreamPrintServiceFactory.lookupStreamPrintServiceFactories()
 * } and specifying a Pageable DocFlavor.
 *
 * @param mimeType the required output format, or null to mean any format.
 * @return a possibly empty array of 2D stream print service factories.
 * @since     1.4
 */
public static StreamPrintServiceFactory[]
    lookupStreamPrintServices(String mimeType) {
    return StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
                                   DocFlavor.SERVICE_FORMATTED.PAGEABLE,
                                   mimeType);
}
 
Example 20
Source File: PrinterJob.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * A convenience method which locates factories for stream print
 * services which can image 2D graphics.
 * Sample usage :
 * <pre>{@code
 * FileOutputStream outstream;
 * StreamPrintService psPrinter;
 * String psMimeType = "application/postscript";
 * PrinterJob pj = PrinterJob.getPrinterJob();
 *
 * StreamPrintServiceFactory[] factories =
 *     PrinterJob.lookupStreamPrintServices(psMimeType);
 * if (factories.length > 0) {
 *     try {
 *         outstream = new File("out.ps");
 *         psPrinter =  factories[0].getPrintService(outstream);
 *         // psPrinter can now be set as the service on a PrinterJob
 *         pj.setPrintService(psPrinter)
 *     } catch (Exception e) {
 *         e.printStackTrace();
 *     }
 * }
 * }</pre>
 * Services returned from this method may be installed on
 * <code>PrinterJob</code> instances which support print services.
 * Calling this method is equivalent to calling
 * {@link javax.print.StreamPrintServiceFactory#lookupStreamPrintServiceFactories(DocFlavor, String)
 * StreamPrintServiceFactory.lookupStreamPrintServiceFactories()
 * } and specifying a Pageable DocFlavor.
 *
 * @param mimeType the required output format, or null to mean any format.
 * @return a possibly empty array of 2D stream print service factories.
 * @since     1.4
 */
public static StreamPrintServiceFactory[]
    lookupStreamPrintServices(String mimeType) {
    return StreamPrintServiceFactory.lookupStreamPrintServiceFactories(
                                   DocFlavor.SERVICE_FORMATTED.PAGEABLE,
                                   mimeType);
}