Discover Streaming Print Services

With this example we shall show you how to discover streaming print services in a Java Desktop Application. You will find this particularly useful when you want to create and handle print jobs from you application.

Discovering streaming print services is very easy as it requires that you :

  • Use StreamPrintServiceFactory.lookupStreamPrintServiceFactories(null, null) to locates factories for print services that can be used with a print.
  • Use StreamPrintServiceFactory.lookupStreamPrintServiceFactories to find all streaming factories that support particular input

Let’s see the code snippet that follows:

package com.javacodegeeks.snippets.desktop;

import javax.print.DocFlavor;
import javax.print.StreamPrintServiceFactory;

public class DiscoverStreamingPrintServices {

	public static void main(String[] args) {

		// locates factories for print services that can be used with a print
		// job to output a stream of data in the format specified by flavor
		// with null no constraints are used
		StreamPrintServiceFactory[] factories = StreamPrintServiceFactory
				.lookupStreamPrintServiceFactories(null, null);

		System.out.println("Streaming Printer Factories found:");

		// find all streaming factories that support particular input
		// formats (e.g. JPEG and Postscript)
		factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(

		System.out.println("Streaming Printer Factories found (with JPEG/Postscript):");


	private static void printFactories(StreamPrintServiceFactory[] factories) {
		if (factories!=null && factories.length>0) {
			for (int i = 0; i < factories.length; i++) {
				System.out.println("t" + factories[i].getClass().getCanonicalName());



Streaming Printer Factories found:
Streaming Printer Factories found (with JPEG/Postscript):

This was an example on discovering Streaming Print Services.

Ilias Tsagklis

Ilias is a software developer turned online entrepreneur. He is co-founder and Executive Editor at Java Code Geeks.
Notify of

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

Inline Feedbacks
View all comments
Back to top button