Java Code Examples for java.awt.print.PageFormat#clone()

The following examples show how to use java.awt.print.PageFormat#clone() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RasterPrinterJob.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The passed in PageFormat is cloned and altered to be usable on
 * the PrinterJob's current printer.
 */
public PageFormat validatePage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    Paper newPaper = new Paper();
    validatePaper(newPage.getPaper(), newPaper);
    newPage.setPaper(newPaper);

    return newPage;
}
 
Example 2
Source File: RasterPrinterJob.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The passed in PageFormat is cloned and altered to be usable on
 * the PrinterJob's current printer.
 */
public PageFormat validatePage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    Paper newPaper = new Paper();
    validatePaper(newPage.getPaper(), newPaper);
    newPage.setPaper(newPaper);

    return newPage;
}
 
Example 3
Source File: RasterPrinterJob.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The passed in PageFormat is cloned and altered to be usable on
 * the PrinterJob's current printer.
 */
public PageFormat validatePage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    Paper newPaper = new Paper();
    validatePaper(newPage.getPaper(), newPaper);
    newPage.setPaper(newPaper);

    return newPage;
}
 
Example 4
Source File: RasterPrinterJob.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The passed in PageFormat is cloned and altered to be usable on
 * the PrinterJob's current printer.
 */
public PageFormat validatePage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    Paper newPaper = new Paper();
    validatePaper(newPage.getPaper(), newPaper);
    newPage.setPaper(newPaper);

    return newPage;
}
 
Example 5
Source File: SimplePageDefinition.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Creates a new SimplePageDefinition object.
 *
 * @param format
 *          the pageformat used as base.
 * @param x
 *          the number of physical pages in a row.
 * @param y
 *          the number of physical pages in a column.
 */
public SimplePageDefinition( final PageFormat format, final int x, final int y ) {
  if ( format == null ) {
    throw new NullPointerException( "Format must not be null" );
  }
  if ( x < 1 ) {
    throw new IllegalArgumentException( "PageCount must be greater or equal to 1" );
  }
  if ( y < 1 ) {
    throw new IllegalArgumentException( "PageCount must be greater or equal to 1" );
  }
  this.format = (PageFormat) format.clone();
  this.pageCountHorizontal = x;
  this.pageCountVertical = y;
  this.pagePositions = new Rectangle2D[pageCountHorizontal * pageCountVertical];

  final float width = (float) format.getImageableWidth();
  final float height = (float) format.getImageableHeight();
  float pageStartY = 0;
  for ( int vert = 0; vert < pageCountVertical; vert++ ) {
    float pageStartX = 0;
    for ( int hor = 0; hor < pageCountHorizontal; hor++ ) {
      final Rectangle2D rect = new Rectangle2D.Float( pageStartX, pageStartY, width, height );
      pagePositions[vert * pageCountHorizontal + hor] = rect;
      pageStartX += width;
    }
    pageStartY += height;
  }
}
 
Example 6
Source File: RasterPrinterJob.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The passed in PageFormat is cloned and altered to be usable on
 * the PrinterJob's current printer.
 */
public PageFormat validatePage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    Paper newPaper = new Paper();
    validatePaper(newPage.getPaper(), newPaper);
    newPage.setPaper(newPaper);

    return newPage;
}
 
Example 7
Source File: RasterPrinterJob.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The passed in PageFormat is cloned and altered to be usable on
 * the PrinterJob's current printer.
 */
public PageFormat validatePage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    Paper newPaper = new Paper();
    validatePaper(newPage.getPaper(), newPaper);
    newPage.setPaper(newPaper);

    return newPage;
}
 
Example 8
Source File: RasterPrinterJob.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * The passed in PageFormat is cloned and altered to be usable on
 * the PrinterJob's current printer.
 */
public PageFormat validatePage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    Paper newPaper = new Paper();
    validatePaper(newPage.getPaper(), newPaper);
    newPage.setPaper(newPaper);

    return newPage;
}
 
Example 9
Source File: WPrinterJob.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Display a dialog to the user allowing the modification of a
 * PageFormat instance.
 * The <code>page</code> argument is used to initialize controls
 * in the page setup dialog.
 * If the user cancels the dialog, then the method returns the
 * original <code>page</code> object unmodified.
 * If the user okays the dialog then the method returns a new
 * PageFormat object with the indicated changes.
 * In either case the original <code>page</code> object will
 * not be modified.
 * @param     page    the default PageFormat presented to the user
 *                    for modification
 * @return    the original <code>page</code> object if the dialog
 *            is cancelled, or a new PageFormat object containing
 *            the format indicated by the user if the dialog is
 *            acknowledged
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 * returns true.
 * @see java.awt.GraphicsEnvironment#isHeadless
 * @since     JDK1.2
 */
@Override
public PageFormat pageDialog(PageFormat page) throws HeadlessException {
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    if (!(getPrintService() instanceof Win32PrintService)) {
        return super.pageDialog(page);
    }

    PageFormat pageClone = (PageFormat) page.clone();
    boolean result = false;

    /*
     * Fix for 4507585: show the native modal dialog the same way printDialog() does so
     * that it won't block event dispatching when called on EventDispatchThread.
     */
    WPageDialog dialog = new WPageDialog((Frame)null, this,
                                 pageClone, null);
    dialog.setRetVal(false);
    dialog.setVisible(true);
    result = dialog.getRetVal();
    dialog.dispose();

    // myService => current PrintService
    if (result && (myService != null)) {
        // It's possible that current printer is changed through
        // the "Printer..." button so we query again from native.
        String printerName = getNativePrintService();
        if (!myService.getName().equals(printerName)) {
            // native printer is different !
            // we update the current PrintService
            try {
                setPrintService(PrintServiceLookupProvider.
                                getWin32PrintLUS().
                                getPrintServiceByName(printerName));
            } catch (PrinterException e) {
            }
        }
        // Update attributes, this will preserve the page settings.
        //  - same code as in RasterPrinterJob.java
        updatePageAttributes(myService, pageClone);

        return pageClone;
    } else {
        return page;
    }
}
 
Example 10
Source File: RasterPrinterJob.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The passed in PageFormat will be copied and altered to describe
 * the default page size and orientation of the PrinterJob's
 * current printer.
 * Platform subclasses which can access the actual default paper size
 * for a printer may override this method.
 */
public PageFormat defaultPage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    newPage.setOrientation(PageFormat.PORTRAIT);
    Paper newPaper = new Paper();
    double ptsPerInch = 72.0;
    double w, h;
    Media media = null;

    PrintService service = getPrintService();
    if (service != null) {
        MediaSize size;
        media =
            (Media)service.getDefaultAttributeValue(Media.class);

        if (media instanceof MediaSizeName &&
           ((size = MediaSize.getMediaSizeForName((MediaSizeName)media)) !=
            null)) {
            w =  size.getX(MediaSize.INCH) * ptsPerInch;
            h =  size.getY(MediaSize.INCH) * ptsPerInch;
            newPaper.setSize(w, h);
            newPaper.setImageableArea(ptsPerInch, ptsPerInch,
                                      w - 2.0*ptsPerInch,
                                      h - 2.0*ptsPerInch);
            newPage.setPaper(newPaper);
            return newPage;

        }
    }

    /* Default to A4 paper outside North America.
     */
    String defaultCountry = Locale.getDefault().getCountry();
    if (!Locale.getDefault().equals(Locale.ENGLISH) && // ie "C"
        defaultCountry != null &&
        !defaultCountry.equals(Locale.US.getCountry()) &&
        !defaultCountry.equals(Locale.CANADA.getCountry())) {

        double mmPerInch = 25.4;
        w = Math.rint((210.0*ptsPerInch)/mmPerInch);
        h = Math.rint((297.0*ptsPerInch)/mmPerInch);
        newPaper.setSize(w, h);
        newPaper.setImageableArea(ptsPerInch, ptsPerInch,
                                  w - 2.0*ptsPerInch,
                                  h - 2.0*ptsPerInch);
    }

    newPage.setPaper(newPaper);

    return newPage;
}
 
Example 11
Source File: RasterPrinterJob.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The passed in PageFormat will be copied and altered to describe
 * the default page size and orientation of the PrinterJob's
 * current printer.
 * Platform subclasses which can access the actual default paper size
 * for a printer may override this method.
 */
public PageFormat defaultPage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    newPage.setOrientation(PageFormat.PORTRAIT);
    Paper newPaper = new Paper();
    double ptsPerInch = 72.0;
    double w, h;
    Media media = null;

    PrintService service = getPrintService();
    if (service != null) {
        MediaSize size;
        media =
            (Media)service.getDefaultAttributeValue(Media.class);

        if (media instanceof MediaSizeName &&
           ((size = MediaSize.getMediaSizeForName((MediaSizeName)media)) !=
            null)) {
            w =  size.getX(MediaSize.INCH) * ptsPerInch;
            h =  size.getY(MediaSize.INCH) * ptsPerInch;
            newPaper.setSize(w, h);
            newPaper.setImageableArea(ptsPerInch, ptsPerInch,
                                      w - 2.0*ptsPerInch,
                                      h - 2.0*ptsPerInch);
            newPage.setPaper(newPaper);
            return newPage;

        }
    }

    /* Default to A4 paper outside North America.
     */
    String defaultCountry = Locale.getDefault().getCountry();
    if (!Locale.getDefault().equals(Locale.ENGLISH) && // ie "C"
        defaultCountry != null &&
        !defaultCountry.equals(Locale.US.getCountry()) &&
        !defaultCountry.equals(Locale.CANADA.getCountry())) {

        double mmPerInch = 25.4;
        w = Math.rint((210.0*ptsPerInch)/mmPerInch);
        h = Math.rint((297.0*ptsPerInch)/mmPerInch);
        newPaper.setSize(w, h);
        newPaper.setImageableArea(ptsPerInch, ptsPerInch,
                                  w - 2.0*ptsPerInch,
                                  h - 2.0*ptsPerInch);
    }

    newPage.setPaper(newPaper);

    return newPage;
}
 
Example 12
Source File: WPrinterJob.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Display a dialog to the user allowing the modification of a
 * PageFormat instance.
 * The <code>page</code> argument is used to initialize controls
 * in the page setup dialog.
 * If the user cancels the dialog, then the method returns the
 * original <code>page</code> object unmodified.
 * If the user okays the dialog then the method returns a new
 * PageFormat object with the indicated changes.
 * In either case the original <code>page</code> object will
 * not be modified.
 * @param     page    the default PageFormat presented to the user
 *                    for modification
 * @return    the original <code>page</code> object if the dialog
 *            is cancelled, or a new PageFormat object containing
 *            the format indicated by the user if the dialog is
 *            acknowledged
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 * returns true.
 * @see java.awt.GraphicsEnvironment#isHeadless
 * @since     JDK1.2
 */
public PageFormat pageDialog(PageFormat page) throws HeadlessException {
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    if (!(getPrintService() instanceof Win32PrintService)) {
        return super.pageDialog(page);
    }

    PageFormat pageClone = (PageFormat) page.clone();
    boolean result = false;

    /*
     * Fix for 4507585: show the native modal dialog the same way printDialog() does so
     * that it won't block event dispatching when called on EventDispatchThread.
     */
    WPageDialog dialog = new WPageDialog((Frame)null, this,
                                 pageClone, null);
    dialog.setRetVal(false);
    dialog.setVisible(true);
    result = dialog.getRetVal();
    dialog.dispose();

    // myService => current PrintService
    if (result && (myService != null)) {
        // It's possible that current printer is changed through
        // the "Printer..." button so we query again from native.
        String printerName = getNativePrintService();
        if (!myService.getName().equals(printerName)) {
            // native printer is different !
            // we update the current PrintService
            try {
                setPrintService(Win32PrintServiceLookup.
                                getWin32PrintLUS().
                                getPrintServiceByName(printerName));
            } catch (PrinterException e) {
            }
        }
        // Update attributes, this will preserve the page settings.
        //  - same code as in RasterPrinterJob.java
        updatePageAttributes(myService, pageClone);

        return pageClone;
    } else {
        return page;
    }
}
 
Example 13
Source File: WPrinterJob.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Display a dialog to the user allowing the modification of a
 * PageFormat instance.
 * The <code>page</code> argument is used to initialize controls
 * in the page setup dialog.
 * If the user cancels the dialog, then the method returns the
 * original <code>page</code> object unmodified.
 * If the user okays the dialog then the method returns a new
 * PageFormat object with the indicated changes.
 * In either case the original <code>page</code> object will
 * not be modified.
 * @param     page    the default PageFormat presented to the user
 *                    for modification
 * @return    the original <code>page</code> object if the dialog
 *            is cancelled, or a new PageFormat object containing
 *            the format indicated by the user if the dialog is
 *            acknowledged
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 * returns true.
 * @see java.awt.GraphicsEnvironment#isHeadless
 * @since     JDK1.2
 */
@Override
public PageFormat pageDialog(PageFormat page) throws HeadlessException {
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    if (!(getPrintService() instanceof Win32PrintService)) {
        return super.pageDialog(page);
    }

    PageFormat pageClone = (PageFormat) page.clone();
    boolean result = false;

    /*
     * Fix for 4507585: show the native modal dialog the same way printDialog() does so
     * that it won't block event dispatching when called on EventDispatchThread.
     */
    WPageDialog dialog = new WPageDialog((Frame)null, this,
                                 pageClone, null);
    dialog.setRetVal(false);
    dialog.setVisible(true);
    result = dialog.getRetVal();
    dialog.dispose();

    // myService => current PrintService
    if (result && (myService != null)) {
        // It's possible that current printer is changed through
        // the "Printer..." button so we query again from native.
        String printerName = getNativePrintService();
        if (!myService.getName().equals(printerName)) {
            // native printer is different !
            // we update the current PrintService
            try {
                setPrintService(Win32PrintServiceLookup.
                                getWin32PrintLUS().
                                getPrintServiceByName(printerName));
            } catch (PrinterException e) {
            }
        }
        // Update attributes, this will preserve the page settings.
        //  - same code as in RasterPrinterJob.java
        updatePageAttributes(myService, pageClone);

        return pageClone;
    } else {
        return page;
    }
}
 
Example 14
Source File: WPrinterJob.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Display a dialog to the user allowing the modification of a
 * PageFormat instance.
 * The <code>page</code> argument is used to initialize controls
 * in the page setup dialog.
 * If the user cancels the dialog, then the method returns the
 * original <code>page</code> object unmodified.
 * If the user okays the dialog then the method returns a new
 * PageFormat object with the indicated changes.
 * In either case the original <code>page</code> object will
 * not be modified.
 * @param     page    the default PageFormat presented to the user
 *                    for modification
 * @return    the original <code>page</code> object if the dialog
 *            is cancelled, or a new PageFormat object containing
 *            the format indicated by the user if the dialog is
 *            acknowledged
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 * returns true.
 * @see java.awt.GraphicsEnvironment#isHeadless
 * @since     JDK1.2
 */
@Override
public PageFormat pageDialog(PageFormat page) throws HeadlessException {
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    if (!(getPrintService() instanceof Win32PrintService)) {
        return super.pageDialog(page);
    }

    PageFormat pageClone = (PageFormat) page.clone();
    boolean result = false;

    /*
     * Fix for 4507585: show the native modal dialog the same way printDialog() does so
     * that it won't block event dispatching when called on EventDispatchThread.
     */
    WPageDialog dialog = new WPageDialog((Frame)null, this,
                                 pageClone, null);
    dialog.setRetVal(false);
    dialog.setVisible(true);
    result = dialog.getRetVal();
    dialog.dispose();

    // myService => current PrintService
    if (result && (myService != null)) {
        // It's possible that current printer is changed through
        // the "Printer..." button so we query again from native.
        String printerName = getNativePrintService();
        if (!myService.getName().equals(printerName)) {
            // native printer is different !
            // we update the current PrintService
            try {
                setPrintService(Win32PrintServiceLookup.
                                getWin32PrintLUS().
                                getPrintServiceByName(printerName));
            } catch (PrinterException e) {
            }
        }
        // Update attributes, this will preserve the page settings.
        //  - same code as in RasterPrinterJob.java
        updatePageAttributes(myService, pageClone);

        return pageClone;
    } else {
        return page;
    }
}
 
Example 15
Source File: RasterPrinterJob.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * The passed in PageFormat will be copied and altered to describe
 * the default page size and orientation of the PrinterJob's
 * current printer.
 * Platform subclasses which can access the actual default paper size
 * for a printer may override this method.
 */
public PageFormat defaultPage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    newPage.setOrientation(PageFormat.PORTRAIT);
    Paper newPaper = new Paper();
    double ptsPerInch = 72.0;
    double w, h;
    Media media = null;

    PrintService service = getPrintService();
    if (service != null) {
        MediaSize size;
        media =
            (Media)service.getDefaultAttributeValue(Media.class);

        if (media instanceof MediaSizeName &&
           ((size = MediaSize.getMediaSizeForName((MediaSizeName)media)) !=
            null)) {
            w =  size.getX(MediaSize.INCH) * ptsPerInch;
            h =  size.getY(MediaSize.INCH) * ptsPerInch;
            newPaper.setSize(w, h);
            newPaper.setImageableArea(ptsPerInch, ptsPerInch,
                                      w - 2.0*ptsPerInch,
                                      h - 2.0*ptsPerInch);
            newPage.setPaper(newPaper);
            return newPage;

        }
    }

    /* Default to A4 paper outside North America.
     */
    String defaultCountry = Locale.getDefault().getCountry();
    if (!Locale.getDefault().equals(Locale.ENGLISH) && // ie "C"
        defaultCountry != null &&
        !defaultCountry.equals(Locale.US.getCountry()) &&
        !defaultCountry.equals(Locale.CANADA.getCountry())) {

        double mmPerInch = 25.4;
        w = Math.rint((210.0*ptsPerInch)/mmPerInch);
        h = Math.rint((297.0*ptsPerInch)/mmPerInch);
        newPaper.setSize(w, h);
        newPaper.setImageableArea(ptsPerInch, ptsPerInch,
                                  w - 2.0*ptsPerInch,
                                  h - 2.0*ptsPerInch);
    }

    newPage.setPaper(newPaper);

    return newPage;
}
 
Example 16
Source File: WPrinterJob.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Display a dialog to the user allowing the modification of a
 * PageFormat instance.
 * The <code>page</code> argument is used to initialize controls
 * in the page setup dialog.
 * If the user cancels the dialog, then the method returns the
 * original <code>page</code> object unmodified.
 * If the user okays the dialog then the method returns a new
 * PageFormat object with the indicated changes.
 * In either case the original <code>page</code> object will
 * not be modified.
 * @param     page    the default PageFormat presented to the user
 *                    for modification
 * @return    the original <code>page</code> object if the dialog
 *            is cancelled, or a new PageFormat object containing
 *            the format indicated by the user if the dialog is
 *            acknowledged
 * @exception HeadlessException if GraphicsEnvironment.isHeadless()
 * returns true.
 * @see java.awt.GraphicsEnvironment#isHeadless
 * @since     JDK1.2
 */
@Override
public PageFormat pageDialog(PageFormat page) throws HeadlessException {
    if (GraphicsEnvironment.isHeadless()) {
        throw new HeadlessException();
    }

    if (!(getPrintService() instanceof Win32PrintService)) {
        return super.pageDialog(page);
    }

    PageFormat pageClone = (PageFormat) page.clone();
    boolean result = false;

    /*
     * Fix for 4507585: show the native modal dialog the same way printDialog() does so
     * that it won't block event dispatching when called on EventDispatchThread.
     */
    WPageDialog dialog = new WPageDialog((Frame)null, this,
                                 pageClone, null);
    dialog.setRetVal(false);
    dialog.setVisible(true);
    result = dialog.getRetVal();
    dialog.dispose();

    // myService => current PrintService
    if (result && (myService != null)) {
        // It's possible that current printer is changed through
        // the "Printer..." button so we query again from native.
        String printerName = getNativePrintService();
        if (!myService.getName().equals(printerName)) {
            // native printer is different !
            // we update the current PrintService
            try {
                setPrintService(Win32PrintServiceLookup.
                                getWin32PrintLUS().
                                getPrintServiceByName(printerName));
            } catch (PrinterException e) {
            }
        }
        // Update attributes, this will preserve the page settings.
        //  - same code as in RasterPrinterJob.java
        updatePageAttributes(myService, pageClone);

        return pageClone;
    } else {
        return page;
    }
}
 
Example 17
Source File: PDFPrinterJob.java    From jpexs-decompiler with GNU General Public License v3.0 4 votes vote down vote up
@Override
public PageFormat pageDialog(PageFormat page) throws HeadlessException {
	// No page dialog is supported.
	return (PageFormat) page.clone();
}
 
Example 18
Source File: WPrinterJob.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * The passed in PageFormat will be copied and altered to describe
 * the default page size and orientation of the PrinterJob's
 * current printer.
 * Note: PageFormat.getPaper() returns a clone and getDefaultPage()
 * gets that clone so it won't overwrite the original paper.
 */
@Override
public PageFormat defaultPage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    getDefaultPage(newPage);
    return newPage;
}
 
Example 19
Source File: WPrinterJob.java    From TencentKona-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * The passed in PageFormat will be copied and altered to describe
 * the default page size and orientation of the PrinterJob's
 * current printer.
 * Note: PageFormat.getPaper() returns a clone and getDefaultPage()
 * gets that clone so it won't overwrite the original paper.
 */
@Override
public PageFormat defaultPage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    getDefaultPage(newPage);
    return newPage;
}
 
Example 20
Source File: WPrinterJob.java    From dragonwell8_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * The passed in PageFormat will be copied and altered to describe
 * the default page size and orientation of the PrinterJob's
 * current printer.
 * Note: PageFormat.getPaper() returns a clone and getDefaultPage()
 * gets that clone so it won't overwrite the original paper.
 */
@Override
public PageFormat defaultPage(PageFormat page) {
    PageFormat newPage = (PageFormat)page.clone();
    getDefaultPage(newPage);
    return newPage;
}