1 /*
   2  * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 /**
  27  * Provides the principal classes and interfaces for the Java™ Print
  28  * Service API. The Java Print Service API enables client and server
  29  * applications to:
  30  * <ul>
  31  *   <li>Discover and select print services based on their capabilities
  32  *   <li>Specify the format of print data
  33  *   <li>Submit print jobs to services that support the document type to be
  34  *   printed.
  35  * </ul>
  36  *
  37  * <h3>Print Service Discovery</h3>
  38  * An application invokes the static methods of the abstract class
  39  * {@link javax.print.PrintServiceLookup PrintServiceLookup} to locate print
  40  * services that have the capabilities to satisfy the application's print
  41  * request. For example, to print a double-sided document, the application first
  42  * needs to find printers that have the double-sided printing capability.
  43  * <p>
  44  * The JDK includes {@code PrintServiceLookup} implementations that can locate
  45  * the standard platform printers. To locate other types of printers, such as
  46  * IPP printers or JINI printers, a print-service provider can write
  47  * implementations of {@code PrintServiceLookup}. The print-service provider can
  48  * dynamically install these {@code PrintServiceLookup} implementations using
  49  * the {@link java.util.ServiceLoader} facility.
  50  *
  51  * <h3>Attribute Definitions</h3>
  52  * The {@link javax.print.attribute} and {@link javax.print.attribute.standard}
  53  * packages define print attributes, which describe the capabilities of a print
  54  * service, specify the requirements of a print job, and track the progress of a
  55  * print job.
  56  * <p>
  57  * The {@code javax.print.attribute} package describes the types of attributes
  58  * and how they can be collected into sets. The
  59  * {@code javax.print.attribute.standard} package enumerates all of the standard
  60  * attributes supported by the API, most of which are implementations of
  61  * attributes specified in the IETF Specification,
  62  * <a href="http://www.ietf.org/rfc/rfc2911.txt">RFC 2911 Internet Printing
  63  * Protocol, 1.1: Model and Semantics</a>, dated September 2000. The attributes
  64  * specified in {@code javax.print.attribute.standard} include common
  65  * capabilities, such as: resolution, copies, media sizes, job priority, and
  66  * page ranges.
  67  *
  68  * <h3>Document Type Specification</h3>
  69  * The {@link javax.print.DocFlavor DocFlavor} class represents the print data
  70  * format, such as JPEG or PostScript. A {@code DocFlavor} object consists of a
  71  * MIME type, which describes the format, and a document representation class
  72  * name that indicates how the document is delivered to the printer or output
  73  * stream. An application uses the {@code DocFlavor} and an attribute set to
  74  * find printers that can print the document type specified by the
  75  * {@code DocFlavor} and have the capabilities specified by the attribute set.
  76  *
  77  * <h3>Using the API</h3>
  78  * A typical application using the Java Print Service API performs these steps
  79  * to process a print request:
  80  * <ol>
  81  *   <li>Chooses a {@code DocFlavor}.
  82  *   <li>Creates a set of attributes.
  83  *   <li>Locates a print service that can handle the print request as specified
  84  *   by the {@code DocFlavor} and the attribute set.
  85  *   <li>Creates a {@link javax.print.Doc Doc} object encapsulating the
  86  *   {@code DocFlavor} and the actual print data, which can take many forms
  87  *   including: a Postscript file, a JPEG image, a {@code URL}, or plain text.
  88  *   <li>Gets a print job, represented by
  89  *   {@link javax.print.DocPrintJob DocPrintJob}, from the print service.
  90  *   <li>Calls the print method of the print job.
  91  * </ol>
  92  * The following code sample demonstrates a typical use of the Java Print
  93  * Service API: locating printers that can print five double-sided copies of a
  94  * Postscript document on size A4 paper, creating a print job from one of the
  95  * returned print services, and calling print.
  96  * <blockquote>
  97  * <pre>{@code
  98  * FileInputStream psStream;
  99  * try {
 100  *     psStream = new FileInputStream("file.ps");
 101  * } catch (FileNotFoundException ffne) {
 102  * }
 103  * if (psStream == null) {
 104  *     return;
 105  * }
 106  * DocFlavor psInFormat = DocFlavor.INPUT_STREAM.POSTSCRIPT;
 107  * Doc myDoc = new SimpleDoc(psStream, psInFormat, null);
 108  * PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
 109  * aset.add(new Copies(5));
 110  * aset.add(MediaSizeName.ISO_A4);
 111  * aset.add(Sides.DUPLEX);
 112  * PrintService[] services =
 113  * PrintServiceLookup.lookupPrintServices(psInFormat, aset);
 114  * if (services.length > 0) {
 115  *     DocPrintJob job = services[0].createPrintJob();
 116  *     try {
 117  *         job.print(myDoc, aset);
 118  *     } catch (PrintException pe) {}
 119  * }
 120  * }</pre>
 121  * </blockquote>
 122  * <p>
 123  * Please note: In the {@code javax.print} APIs, a {@code null} reference
 124  * parameter to methods is incorrect unless explicitly documented on the method
 125  * as having a meaningful interpretation. Usage to the contrary is incorrect
 126  * coding and may result in a run time exception either immediately or at some
 127  * later time. {@code IllegalArgumentException} and {@code NullPointerException}
 128  * are the examples of typical and acceptable run time exceptions for such cases.
 129  *
 130  * @since 1.4
 131  */
 132 package javax.print;