com.wildcrest.j2printerworks
Class J2Printer14

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended bycom.wildcrest.j2printerworks.J2Printer
                  extended bycom.wildcrest.j2printerworks.J2Printer14
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class J2Printer14
extends J2Printer

A J2Printer subclass supporting JDK 1.4 printing features, including printer discovery and selection, print request attribute sets, cross-platform page setup and print dialogs, and print to Postscript

This class includes methods for specifying a PrintRequestAttributeSet, which is a class in JDK 1.4 (or later) for specifying desired printer characteristics. If setCrossPlatformDialogs(false) is specified, the native page setup and print dialogs are used (the same as are used under JDK 1.2 or 1.3). If setCrossPlatformDialogs(true) is specified, then the cross-platform page setup and print dialogs are used, initialized to the values specified in the PrintRequestAttributeSet.

J2Printer14 includes methods for finding the names of all printers accessible from the user's machine that match a specified PrintRequestAttributeSet (or all printers if no attributes are given) and for finding the name of the user's default printer. J2Printer14 then lets you specify by name which printer to use for printing.

Programs using the J2Printer parent class can build and run on any JDK 1.2 or later.
Use the J2Printer14 subclass to access the JDK 1.4 printing features, but you must build and run under JDK 1.4 or later.

(C) Copyright 2009, Wildcrest Associates (http://www.wildcrest.com). All rights reserved.

Since:
1.4
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class com.wildcrest.j2printerworks.J2Printer
BEFORE, BOTTOM, BOX, CENTER, FIRST, GLOBAL, LANDSCAPE, LEFT, LINE, NEVER, NONE, OUTLINE, PLAIN, PORTRAIT, PPI72, printerJob, printerJobSeparateThread, REST, REVERSE_LANDSCAPE, RIGHT, SHADOW, TOP, WAIT
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
J2Printer14()
          Construct a J2Printer14 object with no serial number, a default printer, and an empty Pageable.
J2Printer14(java.awt.print.PrinterJob printerJob)
          Construct a J2Printer14 object with no serial number, a given PrinterJob, and an empty Pageable.
J2Printer14(java.lang.String serialNum)
          Construct a J2Printer14 object with given serial number, default printer, and empty Pageable.
J2Printer14(java.lang.String serialNum, java.awt.print.PrinterJob printerJob)
          Construct a J2Printer14 object with given serial number and PrinterJob, and empty Pageable.
 
Method Summary
 java.lang.String[] getAllPrinterNames()
          Method which returns the names of all available "Pageable" printers for this system.
 boolean getCollate()
          Returns the SheetCollate attribute from the current print request attribute set as a boolean.
 int getCopies()
          Returns the number of copies to be printed from the Copies attribute in current print request attribute set.
 java.lang.String getDefaultPrinterName()
          Method which returns the name of the default printer for the user's machine.
 java.lang.String getJobName()
          Returns the job name for the print job based on the JobName attribute in current print request attribute set.
 java.lang.String getMediaSize()
          Returns the media size specified in the current print request attribute set as a user-friendly String, e.g., Letter, Legal
 java.lang.String[] getMediaSizes()
          Returns the supported media sizes for the current printer as a String array of user-friendly names, e.g., Letter, Legal.
 double getMinimumBottomMargin(int orientation)
          Returns the minimum (physically unprintable) bottom margin for the current printer.
 double getMinimumLeftMargin(int orientation)
          Returns the minimum (physically unprintable) left margin for the current printer.
 double getMinimumRightMargin(int orientation)
          Returns the minimum (physically unprintable) right margin for the current printer.
 double getMinimumTopMargin(int orientation)
          Returns the minimum (physically unprintable) top margin for the current printer.
 int getOrientation()
          Returns the paper orientation from the specified OrientationRequested attribute in the current print request attribute set.
 java.lang.String getPageRanges()
          Returns the PageRanges attribute from the current print request attribute set as a user-friendly String.
 double getPaperHeight()
          Returns the paper height from the specified MediaSize attribute in the current print request attribute set.
 double getPaperWidth()
          Returns the paper width from the specified MediaSize attribute in the current print request attribute set.
 java.lang.String getPrinter()
          Method used to get the name of the currently selected printer.
 java.lang.String[] getPrinterNames()
          Method which returns the names of available printers given the current PrintRequestAttributeSet, with the printer names returned as an array of Strings.
 javax.print.attribute.PrintRequestAttributeSet getPrintRequestAttributeSet()
          Returns the currently specified PrintRequestAttributeSet used by J2Printer14.
 boolean isCrossPlatformDialogs()
          Returns whether the cross-platform printing dialogs are to be used instead of the native printing dialogs.
 byte[] printToPS()
          Utility method for printing the current document to Postscript stored in an in-memory byte array.
 void printToPS(java.io.OutputStream outputStream)
          Utility method for printing the current document to Postscript and storing in a provided OutputStream.
 void printToPS(java.lang.String file)
          Utility method for printing the current document to a Postscript (.ps) file, suitable for dumping to a Postscript printer, viewing with a program such as GhostScript, or converting to PDF using programs such as Adobe Acrobat Distiller or PS2PDF (part of Ghostscript).
 void sendBytesToPrinter(byte[] byteArray)
          Utility method for sending the specified byte array as raw data to the current printer.
 void setBottomMargin(double bottom)
          Sets the "global" (overall, default) bottom margin below footer in inches from the edge of the page (when viewing content).
 void setCollate(boolean collate)
          Sets the SheetCollate attribute in the current print request attribute set.
 void setCopies(int numCopies)
          Sets the number of copies to be printed as a Copies attribute in the current print request attribute set as well as in the current PrinterJob instance.
 void setCrossPlatformDialogs(boolean crossPlatformDialogs)
          Sets whether to use the cross-platform printing dialogs instead of the native printing dialogs.
 void setJobName(java.lang.String jobName)
          Sets the job name for the print job as a JobName attribute in the current print request attribute set as well as in the current PrinterJob instance.
 void setLeftMargin(double left)
          Sets the "global" (overall, default) left margin in inches from the edge of the page (when viewing content).
 void setMargins(double left, double right, double top, double bottom)
          Convenience method for setting all four margins at once.
 void setMediaSize(java.lang.String mediaName)
          Sets the Media attribute in the current print request attribute set.
 void setOrientation(int o)
          Sets "global" (overall, default) page orientation (causes corresponding reordering of unprintable margin settings)
 void setPageFormat(java.awt.print.PageFormat pf)
          Convenience method for setting this J2Printer's "global" margins, page size, and orientation from an external PageFormat instance.
 void setPageRanges(java.lang.String pageRanges)
          Sets the PageRanges attribute in the current print request attribute set.
 void setPaperSize(double pW, double pH)
          Sets the "global" (overall, default) paper width and height in 1/72nds of an inch when paper viewed in PORTRAIT.
 boolean setPrinter(java.lang.String name)
          Method used to set the desired printer.
 void setPrintRequestAttributeSet(javax.print.attribute.PrintRequestAttributeSet aset)
          Method for setting a PrintRequestAttributeSet for specifying desired printing attributes to be used for printing if the cross-platform dialogs are used.
 void setRightMargin(double right)
          Sets the "global" (overall, default) right margin in inches from the edge of the page (when viewing content).
 void setTopMargin(double top)
          Sets the "global" (overall, default) top margin above header in inches from the edge of the page when viewing content).
 
Methods inherited from class com.wildcrest.j2printerworks.J2Printer
addPageable, addPropertyChangeListener, cancelPrinting, changePrintPreviewLookAndFeel, clearFooters, clearFooters, clearHeaders, clearHeaders, clearPageable, clone, displayPDFFile, dispose, disposePageImageBuffers, fire, getBodyHeight, getBodyWidth, getBottomMargin, getCenterFooter, getCenterFooter, getCenterHeader, getCenterHeader, getCurrentPrintPreviewPageNumber, getCurrentPrintPreviewScale, getException, getFooterFont, getFooterFont, getFooterStyle, getFooterStyle, getGapAboveFooter, getGapBelowHeader, getHeaderFont, getHeaderFont, getHeaderStyle, getHeaderStyle, getLeftFooter, getLeftFooter, getLeftHeader, getLeftHeader, getLeftMargin, getMaximumSize, getMinimumSize, getNumberOfCopies, getNup, getPageable, getPageBeingPrinted, getPageFormat, getPageImage, getPageImage, getPageImage, getPageImage, getPageImage, getParentFrame, getPreferredSize, getPrinterJob, getPrintJobName, getPrintPreviewCloseOnPrint, getPrintPreviewPageNumber, getPrintPreviewPageSetupDialog, getPrintPreviewScale, getPrintPreviewString, getPrintPreviewToolBar, getRightFooter, getRightFooter, getRightHeader, getRightHeader, getRightMargin, getScale, getStartingPageNumber, getTopMargin, getVersion, isCurrentPrintPreviewTwoPageDisplay, isDebug, isPrintDialogResponse, isPrintDialogUsed, isPrintingUnderway, isPrintPreviewClosed, isPrintPreviewTwoPageDisplay, isSeparatePrintThread, joinPageables, main, makePagePanel, mergePageables, paint, print, print, printPDFFile, printToHTML, printToPDF, printToPDF, printToPDF, printToPDFNoFonts, printToPDFNoFonts, printToPDFNoFonts, refreshPrintPreviewDialog, removePropertyChangeListener, saveImageToJPEG, setBusyCursor, setCenterFooter, setCenterFooter, setCenterHeader, setCenterHeader, setDebug, setFooterFont, setFooterFont, setFooterStyle, setFooterStyle, setGapAboveFooter, setGapBelowHeader, setHeaderFont, setHeaderFont, setHeaderStyle, setHeaderStyle, setLeftFooter, setLeftFooter, setLeftHeader, setLeftHeader, setNumberOfCopies, setNumberOfPageImageBuffers, setNup, setPageable, setPageImagesMonochrome, setParam, setParentFrame, setPrintDialogUsed, setPrinterJob, setPrintJobName, setPrintPreviewCloseOnPrint, setPrintPreviewDialogZoomLevels, setPrintPreviewIconImage, setPrintPreviewPageNumber, setPrintPreviewPageSetupDialog, setPrintPreviewScale, setPrintPreviewString, setPrintPreviewTwoPageDisplay, setRightFooter, setRightFooter, setRightHeader, setRightHeader, setScale, setSeparatePrintThread, setStartingPageNumber, showPageSetupDialog, showPageSetupDialog, showPrintPreviewDialog, showPrintPreviewDialog, showPrintPreviewDialog, showPrintPreviewDialog, showPrintPreviewPageSetupButton
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getNextFocusableComponent, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

J2Printer14

public J2Printer14()
Construct a J2Printer14 object with no serial number, a default printer, and an empty Pageable.


J2Printer14

public J2Printer14(java.awt.print.PrinterJob printerJob)
Construct a J2Printer14 object with no serial number, a given PrinterJob, and an empty Pageable.


J2Printer14

public J2Printer14(java.lang.String serialNum)
Construct a J2Printer14 object with given serial number, default printer, and empty Pageable.


J2Printer14

public J2Printer14(java.lang.String serialNum,
                   java.awt.print.PrinterJob printerJob)
Construct a J2Printer14 object with given serial number and PrinterJob, and empty Pageable.

Method Detail

setPrintRequestAttributeSet

public void setPrintRequestAttributeSet(javax.print.attribute.PrintRequestAttributeSet aset)
Method for setting a PrintRequestAttributeSet for specifying desired printing attributes to be used for printing if the cross-platform dialogs are used. If setCrossPlatformDialogs(false) is specified, the native page setup and print dialogs will be used with the values set by the J2Printer setNumberOfCopies, setPrintJobName, setPaperSize, and setOrientation methods, and any PrintRequestAttributeSet that has been specified will be ignored.

If setCrossPlatformDialogs(true) is specified, the cross-platform page setup and print dialogs will be used, and the specified PrintRequestAttributeSet will be use to set the desired printing attributes. If the values for number of copies, print job name, paper size, and/or orientation are specified by the PrintRequestAttributeSet, this will be used, otherwise the values set by the J2Printer setNumberOfCopies, setPrintJobName, setPaperSize, and/or setOrientation methods will be used.

Example:

PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
aset.add(new Copies(2));
aset.add(new JobName("My print job name", null));
aset.add(OrientationRequested.LANDSCAPE);
aset.add(MediaSizeName.NA_NUMBER_10_ENVELOPE); // or MediaSizeName.ISO_A4, etc.
aset.add(new PageRanges(1,getPageable().getNumberOfPages()));
aset.add(PrintQuality.DRAFT);
aset.add(Chromaticity.MONOCHROME);
j2printer14.setPrintRequestAttributeSet(aset);

See JDK 1.4 class PrintRequestAttributeSet for additional attributes that may be selected.

The values in the PrintRequestAttributeSet will be used in initializing the page setup and print dialogs. The values may be modified by the system depending on the capabilities of the current printer when presented in the page setup or print dialogs to the end user. The end user may then modify these choices further in the page setup and/or print dialogs to arrive at the settings actually used in printing. The value of the PrintRequestAttributeSet specified by this method (and returned by getPrintRequestAttributeSet()) will automatically be updated to reflect these page setup and/or print dialog modifications.

Default: initialized to new HashPrintRequestAttributeSet(), which is an empty list of attributes.

Parameters:
aset - the printing attributes to be used for this print operation.
Since:
1.4

getPrintRequestAttributeSet

public javax.print.attribute.PrintRequestAttributeSet getPrintRequestAttributeSet()
Returns the currently specified PrintRequestAttributeSet used by J2Printer14.


getPrinterNames

public java.lang.String[] getPrinterNames()
Method which returns the names of available printers given the current PrintRequestAttributeSet, with the printer names returned as an array of Strings. The current PrintRequestAttributeSet is set using the method setPrintRequestAttributeSet. If this value is null or if the PrintRequestAttributeSet is empty, all available printers are returned. This method can take a number of seconds depending on the OS platform, number of available printers, and attributes specified (also note that as of JDK 1.4.2, Apple does not support attribute-based printer discovery so this method finds no printers on the Macintosh if any print request attributes are specified). The default PrintRequestAttributeSet is the attribute set of the default paper size, margin settings, and orientation for your default printer. To discover all available printers regardless of the current PrintRequestAttributeSet (including on the Mac), use getAllPrinterNames().

Since:
1.4

getAllPrinterNames

public java.lang.String[] getAllPrinterNames()
Method which returns the names of all available "Pageable" printers for this system. Printer names returned as an array of Strings. Because this method can take a number of seconds depending on the OS platform and number of available printers, it caches the underlying information so it is only slow the first time.

Since:
1.4

getDefaultPrinterName

public java.lang.String getDefaultPrinterName()
Method which returns the name of the default printer for the user's machine.

Since:
1.4

setPrinter

public boolean setPrinter(java.lang.String name)
Method used to set the desired printer. Printer name should be one of those returned by either getPrinterNames() or getAllPrinterNames(). If the name matches one of the available printers, the method returns true. If name does not match one of the available printers, the default printer for this system is used and the method returns false.

Parameters:
name - String The name of the printer to be used.
Since:
1.4

getPrinter

public java.lang.String getPrinter()
Method used to get the name of the currently selected printer. Printer name will be the name of the printer specified in the current PrinterJob. This will either be the value set by the most recent call to setPrinter or, if no value has been set, the default printer for this system.

Since:
1.4

printToPS

public void printToPS(java.lang.String file)
Utility method for printing the current document to a Postscript (.ps) file, suitable for dumping to a Postscript printer, viewing with a program such as GhostScript, or converting to PDF using programs such as Adobe Acrobat Distiller or PS2PDF (part of Ghostscript). NOTE: This method honors the current setSeparatePrintThread(boolean) setting, for which the default is true, so that by default printToPS(file) is asynchronous and returns immediately. To ensure that the file is completely formed, you need to either call setSeparatePrintThread(false) or wait for the PrintingEventHandler printingDone event.

Parameters:
file - The file name into which the Postscript file will be written (if missing, assumes ./out.ps, if doesn't end in .ps, will add .ps, all folders in path must already exist).
Since:
1.4

printToPS

public byte[] printToPS()
Utility method for printing the current document to Postscript stored in an in-memory byte array. NOTE: This method ignores the current setSeparatePrintThread(boolean) setting, and does not return until printing to the byte array is complete.

Since:
1.4

printToPS

public void printToPS(java.io.OutputStream outputStream)
Utility method for printing the current document to Postscript and storing in a provided OutputStream. NOTE: This method honors the current setSeparatePrintThread(boolean) setting, for which the default is true, so that by default printToPS(outputStream) is asynchronous and returns immediately. To ensure that the outputStream is completely formed, you need to either call setSeparatePrintThread(false) or wait for the PrintingEventHandler printingDone event.

Parameters:
outputStream - A provided java.io.OutputStream into which the Postscript will be written.
Since:
1.4

sendBytesToPrinter

public void sendBytesToPrinter(byte[] byteArray)
Utility method for sending the specified byte array as raw data to the current printer. For example, the code

byte[] bytes = printToPS();
dumpBytesToPrinter(bytes);


will render the current document as Postscript and dump the Postscript to the current printer under the assumption that it is a Postscript printer (if it isn't a Postscript printer, you will typically see a printout of the raw Postscript).

Since:
1.4

getCopies

public int getCopies()
Returns the number of copies to be printed from the Copies attribute in current print request attribute set. If none specified, returns the number of copies specified in the current PrinterJob instance.

Since:
1.4

setCopies

public void setCopies(int numCopies)
Sets the number of copies to be printed as a Copies attribute in the current print request attribute set as well as in the current PrinterJob instance.

Parameters:
numCopies - int number of copies to be printed
Since:
1.4

getJobName

public java.lang.String getJobName()
Returns the job name for the print job based on the JobName attribute in current print request attribute set. If none specified, returns the JobName specified in the current PrinterJob instance.

Since:
1.4

setJobName

public void setJobName(java.lang.String jobName)
Sets the job name for the print job as a JobName attribute in the current print request attribute set as well as in the current PrinterJob instance.

Parameters:
jobName - String job name for the print job to be printed
Since:
1.4

getPageRanges

public java.lang.String getPageRanges()
Returns the PageRanges attribute from the current print request attribute set as a user-friendly String. If none specified, returns an empty String.

Since:
1.4

setPageRanges

public void setPageRanges(java.lang.String pageRanges)
Sets the PageRanges attribute in the current print request attribute set.

Parameters:
pageRanges - String user-friendly page ranges string, e.g. 1-3,6,9-12
Since:
1.4

getCollate

public boolean getCollate()
Returns the SheetCollate attribute from the current print request attribute set as a boolean. If none specified, returns false.

Since:
1.4

setCollate

public void setCollate(boolean collate)
Sets the SheetCollate attribute in the current print request attribute set.

Parameters:
collate - boolean print collated if true, not collated if false
Since:
1.4

getMediaSizes

public java.lang.String[] getMediaSizes()
Returns the supported media sizes for the current printer as a String array of user-friendly names, e.g., Letter, Legal.

Since:
1.4

getMediaSize

public java.lang.String getMediaSize()
Returns the media size specified in the current print request attribute set as a user-friendly String, e.g., Letter, Legal

Since:
1.4

setMediaSize

public void setMediaSize(java.lang.String mediaName)
Sets the Media attribute in the current print request attribute set.

Parameters:
mediaName - String user-friendly media size name, e.g., Letter, Legal.
Since:
1.4

getOrientation

public int getOrientation()
Returns the paper orientation from the specified OrientationRequested attribute in the current print request attribute set. If none specified, returns the orientation specified in the current J2Printer14 instance.

Overrides:
getOrientation in class J2Printer
Since:
1.4

getPaperWidth

public double getPaperWidth()
Returns the paper width from the specified MediaSize attribute in the current print request attribute set. If none specified, returns the paper width specified in the current J2Printer14 instance.

Overrides:
getPaperWidth in class J2Printer
Since:
1.4

getPaperHeight

public double getPaperHeight()
Returns the paper height from the specified MediaSize attribute in the current print request attribute set. If none specified, returns the paper height specified in the current J2Printer14 instance.

Overrides:
getPaperHeight in class J2Printer
Since:
1.4

getMinimumLeftMargin

public double getMinimumLeftMargin(int orientation)
Returns the minimum (physically unprintable) left margin for the current printer.


getMinimumRightMargin

public double getMinimumRightMargin(int orientation)
Returns the minimum (physically unprintable) right margin for the current printer.


getMinimumTopMargin

public double getMinimumTopMargin(int orientation)
Returns the minimum (physically unprintable) top margin for the current printer.


getMinimumBottomMargin

public double getMinimumBottomMargin(int orientation)
Returns the minimum (physically unprintable) bottom margin for the current printer.


setOrientation

public void setOrientation(int o)
Description copied from class: J2Printer
Sets "global" (overall, default) page orientation (causes corresponding reordering of unprintable margin settings)

Overrides:
setOrientation in class J2Printer
Parameters:
o - J2Printer.PORTRAIT or .LANDSCAPE or .REVERSE_LANDSCAPE used when Pageable instance value is negative (e.g., GLOBAL). (same as PageFormat.PORTRAIT, etc.). Default: PORTRAIT

setPaperSize

public void setPaperSize(double pW,
                         double pH)
Description copied from class: J2Printer
Sets the "global" (overall, default) paper width and height in 1/72nds of an inch when paper viewed in PORTRAIT.

Overrides:
setPaperSize in class J2Printer
Parameters:
pW - paper width in 1/72nds of an inch ("points") when viewed in PORTRAIT
pH - paper height in 1/72nds of an inch ("points") when viewed in PORTRAIT

setLeftMargin

public void setLeftMargin(double left)
Description copied from class: J2Printer
Sets the "global" (overall, default) left margin in inches from the edge of the page (when viewing content). Actual margin will not be less than the unprintable left margin.

Overrides:
setLeftMargin in class J2Printer
Parameters:
left - double representing left margin in inches. Used when Pageable instance value is negative (e.g., GLOBAL). Default: 0.0

setRightMargin

public void setRightMargin(double right)
Description copied from class: J2Printer
Sets the "global" (overall, default) right margin in inches from the edge of the page (when viewing content). Actual margin will not be less than the unprintable right margin.

Overrides:
setRightMargin in class J2Printer
Parameters:
right - double representing right margin in inches. Used when Pageable instance value is negative (e.g., GLOBAL). Default: 0.0

setTopMargin

public void setTopMargin(double top)
Description copied from class: J2Printer
Sets the "global" (overall, default) top margin above header in inches from the edge of the page when viewing content). Actual margin will not be less than the unprintable top margin.

Overrides:
setTopMargin in class J2Printer
Parameters:
top - double representing top margin above header in inches. Used when Pageable instance value is negative (e.g., GLOBAL). Default: 0.0

setBottomMargin

public void setBottomMargin(double bottom)
Description copied from class: J2Printer
Sets the "global" (overall, default) bottom margin below footer in inches from the edge of the page (when viewing content). Actual margin will not be less than the unprintable bottom margin.

Overrides:
setBottomMargin in class J2Printer
Parameters:
bottom - double representing bottom margin below footer in inches. Used when Pageable instance value is negative (e.g., GLOBAL). Default: 0.0

setPageFormat

public void setPageFormat(java.awt.print.PageFormat pf)
Description copied from class: J2Printer
Convenience method for setting this J2Printer's "global" margins, page size, and orientation from an external PageFormat instance. Sets this J2Printer's "global" left, right, top, and bottom margins, page size, and orientation based on the values in the PageFormat instance. Note that these values may be ignored by any given Pageable with its own "local" value.

Overrides:
setPageFormat in class J2Printer
Parameters:
pf - PageFormat whose values will be used to set the J2Printer margins, page size, and orientation.

setMargins

public void setMargins(double left,
                       double right,
                       double top,
                       double bottom)
Convenience method for setting all four margins at once. Allows all four margins to be set to desired values before recalculating internal page format and printer attribute values. Useful in situations where, for example, a smaller paper size is specified, the current margins are too big, and reducing them one at a time results in an invalid intermediate state.


setCrossPlatformDialogs

public void setCrossPlatformDialogs(boolean crossPlatformDialogs)
Sets whether to use the cross-platform printing dialogs instead of the native printing dialogs.

Parameters:
crossPlatformDialogs - boolean representing whether to use the cross-platform printing dialogs instead of the native printing dialogs. Default: true

isCrossPlatformDialogs

public boolean isCrossPlatformDialogs()
Returns whether the cross-platform printing dialogs are to be used instead of the native printing dialogs.

Overrides:
isCrossPlatformDialogs in class J2Printer