- java.lang.Object
-
- org.icepdf.ri.common.print.PrintHelper
-
- org.icepdf.ri.common.print.PrintHelperImpl
-
- All Implemented Interfaces:
Printable
public class PrintHelperImpl extends PrintHelper
The
PrintHelperclass is utility class to aid developers in printing PDF document content. The PrintHelper takes advantage of the Pageable and Printable interfaces availabe in Java 2.- Since:
- 2.0
-
-
Field Summary
-
Fields inherited from class org.icepdf.ri.common.print.PrintHelper
CLIPPING_FIX_ENABLED, EMPTY_PRINTSERVICE_ARRAY, PRINTER_NAME_ATTRIBUTE
-
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
-
-
Constructor Summary
Constructors Constructor Description PrintHelperImpl(Container container, PageTree pageTree, float userRotation, DocAttributeSet docAttributeSet, PrintRequestAttributeSet printRequestAttributeSet)Creates a newPrintHelperinstance using the specified doc and print attribute sets.PrintHelperImpl(Container container, PageTree pageTree, float rotation, MediaSizeName paperSizeName, PrintQuality printQuality)Creates a newPrintHelperinstance using the specified media sized and print quality.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CancelablePrintJobcancelablePrint()protected PrintServicegetSetupDialog()Utility for creating a print setup dialog.floatgetUserRotation()Users rotation specified for the print job.voidprint()Print a range of pages from the document as specified by #setupPrintService.intprint(Graphics printGraphics, PageFormat pageFormat, int pageIndex)Prints the page at the specified index into the specified java.awt.Graphics context in the specified format.voidprint(PrintJobWatcher printJobWatcher)voidshowPrintSetupDialog()Utility for showing print dialog for the current printService.-
Methods inherited from class org.icepdf.ri.common.print.PrintHelper
createDocAttributeSet, createPrintRequestAttributeSet, getCurrentPage, getDocAttributeSet, getNumberOfPages, getPrintRequestAttributeSet, getPrintService, getPrintServiceOrDefault, getServices, guessMediaSizeName, hasPrinter, isPaintAnnotation, isPaintSearchHighlight, isPrintFitToMargin, lookForPrintServices, preloadServices, reloadServices, setCurrentPage, setDocAttributeSet, setNumberOfPages, setPaintAnnotation, setPaintSearchHighlight, setPrinter, setPrintFitToMargin, setPrintRequestAttributeSet, setPrintService, setupPrintService, setupPrintService, setupPrintService
-
-
-
-
Constructor Detail
-
PrintHelperImpl
public PrintHelperImpl(Container container, PageTree pageTree, float rotation, MediaSizeName paperSizeName, PrintQuality printQuality)
Creates a newPrintHelperinstance using the specified media sized and print quality.- Parameters:
container- parent container uses to center print dialog.pageTree- document page tree.rotation- rotation at witch to paint document.paperSizeName- MediaSizeName constant of paper size to print to.printQuality- quality of the print job, draft, quality etc.
-
PrintHelperImpl
public PrintHelperImpl(Container container, PageTree pageTree, float userRotation, DocAttributeSet docAttributeSet, PrintRequestAttributeSet printRequestAttributeSet)
Creates a newPrintHelperinstance using the specified doc and print attribute sets. This constructor offers the most flexibility as it allows the attributes sets to be pre configured. This method should only be used by advanced users.- Parameters:
container- parent container uses to center print dialog.pageTree- document page tree.userRotation- rotation of viewdocAttributeSet- MediaSizeName constant of paper size to print to.printRequestAttributeSet- quality of the print job, draft, quality etc.
-
-
Method Detail
-
showPrintSetupDialog
public void showPrintSetupDialog()
Description copied from class:PrintHelperUtility for showing print dialog for the current printService. If no print service is assigned the first print service is used to create the print dialog.- Specified by:
showPrintSetupDialogin classPrintHelper
-
getUserRotation
public float getUserRotation()
Users rotation specified for the print job.- Returns:
- float value representing rotation, 0 is 0 degrees.
-
print
public int print(Graphics printGraphics, PageFormat pageFormat, int pageIndex)
Prints the page at the specified index into the specified java.awt.Graphics context in the specified format.- Specified by:
printin interfacePrintable- Specified by:
printin classPrintHelper- Parameters:
printGraphics- paper graphics context.pageFormat- print attributes translated from PrintServicepageIndex- page to print, zero based.- Returns:
- A status code of Printable.NO_SUCH_PAGE or Printable.PAGE_EXISTS
-
print
public void print() throws PrintExceptionDescription copied from class:PrintHelperPrint a range of pages from the document as specified by #setupPrintService.- Specified by:
printin classPrintHelper- Throws:
PrintException- if a default printer could not be found or some other printing related error.
-
cancelablePrint
public CancelablePrintJob cancelablePrint() throws PrintException
- Specified by:
cancelablePrintin classPrintHelper- Throws:
PrintException
-
print
public void print(PrintJobWatcher printJobWatcher) throws PrintException
- Specified by:
printin classPrintHelper- Throws:
PrintException
-
getSetupDialog
protected PrintService getSetupDialog()
Description copied from class:PrintHelperUtility for creating a print setup dialog.- Specified by:
getSetupDialogin classPrintHelper- Returns:
- print service selected by the user, or null if the user cancelled the dialog.
-
-