APIdia Launch Partner
Top Description Inners Fields Constructors Methods
java.awt

public final Class PageAttributes

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Imports
java.util.Locale

A set of attributes which control the output of a printed page.

Instances of this class control the color state, paper size (media type), orientation, logical origin, print quality, and resolution of every page which uses the instance. Attribute names are compliant with the Internet Printing Protocol (IPP) 1.1 where possible. Attribute values are partially compliant where possible.

To use a method which takes an inner class type, pass a reference to one of the constant fields of the inner class. Client code cannot create new instances of the inner class types because none of those classes has a public constructor. For example, to set the color state to monochrome, use the following code:

import java.awt.PageAttributes;

public class MonochromeExample {
    public void setMonochrome(PageAttributes pageAttributes) {
        pageAttributes.setColor(PageAttributes.ColorType.MONOCHROME);
    }
}

Every IPP attribute which supports an attributeName-default value has a corresponding setattributeNameToDefault method. Default value fields are not provided.

Author
David Mendenhall
Since
1.3

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
PageAttributes.ColorType

A type-safe enumeration of possible color states.

public static class
PageAttributes.MediaType

A type-safe enumeration of possible paper sizes.

public static class
PageAttributes.OrientationRequestedType

A type-safe enumeration of possible orientations.

public static class
PageAttributes.OriginType

A type-safe enumeration of possible origins.

public static class
PageAttributes.PrintQualityType

A type-safe enumeration of possible print qualities.

Field Summary

Modifier and TypeField and Description
private PageAttributes.ColorType
private PageAttributes.MediaType
private PageAttributes.OrientationRequestedType
private PageAttributes.OriginType
private int[]
private PageAttributes.PrintQualityType

Constructor Summary

AccessConstructor and Description
public
PageAttributes()

Constructs a PageAttributes instance with default values for every attribute.

public
PageAttributes(PageAttributes
the PageAttributes to copy.
obj
)

Constructs a PageAttributes instance which is a copy of the supplied PageAttributes.

public
PageAttributes(PageAttributes.ColorType
ColorType.COLOR or ColorType.MONOCHROME.
color
,
PageAttributes.MediaType
one of the constant fields of the MediaType class.
media
,
PageAttributes.OrientationRequestedType
OrientationRequestedType.PORTRAIT or OrientationRequestedType.LANDSCAPE.
orientationRequested
,
PageAttributes.OriginType
OriginType.PHYSICAL or OriginType.PRINTABLE
origin
,
PageAttributes.PrintQualityType
PrintQualityType.DRAFT, PrintQualityType.NORMAL, or PrintQualityType.HIGH
printQuality
,
int[]
an integer array of 3 elements. The first element must be greater than 0. The second element must be must be greater than 0. The third element must be either 3 or 4.
printerResolution
)

Constructs a PageAttributes instance with the specified values for every attribute.

Method Summary

Modifier and TypeMethod and Description
public Object

Returns:

the newly created copy. It is safe to cast this Object into a PageAttributes.
clone
()

Overrides java.lang.Object.clone.

Creates and returns a copy of this PageAttributes.

public boolean

Returns:

whether obj is equal to this PageAttribute according to the above criteria.
equals
(Object
the object whose equality will be checked.
obj
)

Overrides java.lang.Object.equals.

Determines whether two PageAttributes are equal to each other.

public PageAttributes.ColorType

Returns:

ColorType.COLOR or ColorType.MONOCHROME.
getColor
()

Returns whether pages using these attributes will be rendered in color or monochrome.

public PageAttributes.MediaType

Returns:

one of the constant fields of the MediaType class.
getMedia
()

Returns the paper size for pages using these attributes.

public PageAttributes.OrientationRequestedType

Returns:

OrientationRequestedType.PORTRAIT or OrientationRequestedType.LANDSCAPE.
getOrientationRequested
()

Returns the print orientation for pages using these attributes.

public PageAttributes.OriginType

Returns:

OriginType.PHYSICAL or OriginType.PRINTABLE
getOrigin
()

Returns whether drawing at (0, 0) to pages using these attributes draws at the upper-left corner of the physical page, or at the upper-left corner of the printable area.

public int[]

Returns:

an integer array of 3 elements. The first element must be greater than 0. The second element must be must be greater than 0. The third element must be either 3 or 4.
getPrinterResolution
()

Returns the print resolution for pages using these attributes.

public PageAttributes.PrintQualityType

Returns:

PrintQualityType.DRAFT, PrintQualityType.NORMAL, or PrintQualityType.HIGH
getPrintQuality
()

Returns the print quality for pages using these attributes.

public int

Returns:

the hash code.
hashCode
()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this PageAttributes.

public void
set(PageAttributes
the PageAttributes to copy.
obj
)

Sets all of the attributes of this PageAttributes to the same values as the attributes of obj.

public void
setColor(PageAttributes.ColorType
ColorType.COLOR or ColorType.MONOCHROME.
color
)

Specifies whether pages using these attributes will be rendered in color or monochrome.

public void
setMedia(PageAttributes.MediaType
one of the constant fields of the MediaType class.
media
)

Specifies the desired paper size for pages using these attributes.

public void
setMediaToDefault()

Sets the paper size for pages using these attributes to the default size for the default locale.

public void
setOrientationRequested(PageAttributes.OrientationRequestedType
OrientationRequestedType.PORTRAIT or OrientationRequestedType.LANDSCAPE.
orientationRequested
)

Specifies the print orientation for pages using these attributes.

public void
setOrientationRequested(int
3 or 4
orientationRequested
)

Specifies the print orientation for pages using these attributes.

public void
setOrientationRequestedToDefault()

Sets the print orientation for pages using these attributes to the default.

public void
setOrigin(PageAttributes.OriginType
OriginType.PHYSICAL or OriginType.PRINTABLE
origin
)

Specifies whether drawing at (0, 0) to pages using these attributes draws at the upper-left corner of the physical page, or at the upper-left corner of the printable area.

public void
setPrinterResolution(int[]
an integer array of 3 elements. The first element must be greater than 0. The second element must be must be greater than 0. The third element must be either 3 or 4.
printerResolution
)

Specifies the desired print resolution for pages using these attributes.

public void
setPrinterResolution(int
an integer greater than 0.
printerResolution
)

Specifies the desired cross feed and feed print resolutions in dots per inch for pages using these attributes.

public void
setPrinterResolutionToDefault()

Sets the printer resolution for pages using these attributes to the default.

public void
setPrintQuality(PageAttributes.PrintQualityType
PrintQualityType.DRAFT, PrintQualityType.NORMAL, or PrintQualityType.HIGH
printQuality
)

Specifies the print quality for pages using these attributes.

public void
setPrintQuality(int
3, 4, or 5
printQuality
)

Specifies the print quality for pages using these attributes.

public void
setPrintQualityToDefault()

Sets the print quality for pages using these attributes to the default.

public String

Returns:

the string representation.
toString
()

Overrides java.lang.Object.toString.

Returns a string representation of this PageAttributes.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait