Java Code Examples for java.awt.print.Printable#PAGE_EXISTS
The following examples show how to use
java.awt.print.Printable#PAGE_EXISTS .
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: WrongPaperForBookPrintingTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException { if (pageIndex == 0) { g.setColor(Color.RED); g.drawRect((int) pf.getImageableX(), (int) pf.getImageableY(), (int) pf.getImageableWidth() - 1, (int) pf.getImageableHeight() - 1); return Printable.PAGE_EXISTS; } else { return Printable.NO_SUCH_PAGE; } }
Example 2
Source File: PSPrinterJob.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public int print(Graphics g, PageFormat pf, int pgIndex) { if (pgIndex > 0) { return Printable.NO_SUCH_PAGE; } else { // "aware" client code can detect that its been passed a // PrinterGraphics and could theoretically print // differently. I think this is more likely useful than // a problem. applet.printAll(g); return Printable.PAGE_EXISTS; } }
Example 3
Source File: bug8023392.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { if (pageIndex >= 1) { return Printable.NO_SUCH_PAGE; } this.paint(graphics); return Printable.PAGE_EXISTS; }
Example 4
Source File: PrintLatinCJKTest.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException { if (pageIndex > 0) { return Printable.NO_SUCH_PAGE; } g.translate((int) pf.getImageableX(), (int) pf.getImageableY()); g.setFont(new Font("Dialog", Font.PLAIN, 36)); g.drawString("\u4e00\u4e01\u4e02\u4e03\u4e04English", 20, 100); return Printable.PAGE_EXISTS; }
Example 5
Source File: PSPrinterJob.java From hottub with GNU General Public License v2.0 | 5 votes |
public int print(Graphics g, PageFormat pf, int pgIndex) { if (pgIndex > 0) { return Printable.NO_SUCH_PAGE; } else { // "aware" client code can detect that its been passed a // PrinterGraphics and could theoretically print // differently. I think this is more likely useful than // a problem. applet.printAll(g); return Printable.PAGE_EXISTS; } }
Example 6
Source File: PSPrinterJob.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public int print(Graphics g, PageFormat pf, int pgIndex) { if (pgIndex > 0) { return Printable.NO_SUCH_PAGE; } else { // "aware" client code can detect that its been passed a // PrinterGraphics and could theoretically print // differently. I think this is more likely useful than // a problem. applet.printAll(g); return Printable.PAGE_EXISTS; } }
Example 7
Source File: PSPrinterJob.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public int print(Graphics g, PageFormat pf, int pgIndex) { if (pgIndex > 0) { return Printable.NO_SUCH_PAGE; } else { // "aware" client code can detect that its been passed a // PrinterGraphics and could theoretically print // differently. I think this is more likely useful than // a problem. applet.printAll(g); return Printable.PAGE_EXISTS; } }
Example 8
Source File: TestTextPosInPrint.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Override public int print(Graphics pg, PageFormat pf, int pageNum) throws PrinterException { if (pageNum > 0){ return Printable.NO_SUCH_PAGE; } Graphics2D g2 = (Graphics2D) pg; g2.translate(pf.getImageableX(), pf.getImageableY()); panel.paint(g2); return Printable.PAGE_EXISTS; }
Example 9
Source File: ImagePrinter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public int print(Graphics g, PageFormat pf, int index) { if (index > 0 || image == null) { return Printable.NO_SUCH_PAGE; } ((Graphics2D)g).translate(pf.getImageableX(), pf.getImageableY()); int w = image.getWidth(null); int h = image.getHeight(null); int iw = (int)pf.getImageableWidth(); int ih = (int)pf.getImageableHeight(); // ensure image will fit int dw = w; int dh = h; if (dw > iw) { dh = (int)(dh * ( (float) iw / (float) dw)) ; dw = iw; } if (dh > ih) { dw = (int)(dw * ( (float) ih / (float) dh)) ; dh = ih; } // centre on page int dx = (iw - dw) / 2; int dy = (ih - dh) / 2; g.drawImage(image, dx, dy, dx+dw, dy+dh, 0, 0, w, h, null); return Printable.PAGE_EXISTS; }
Example 10
Source File: bug8023392.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { if (pageIndex >= 1) { return Printable.NO_SUCH_PAGE; } this.paint(graphics); return Printable.PAGE_EXISTS; }
Example 11
Source File: WrongPaperPrintingTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Override public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException { if (pageIndex == 0) { g.setColor(Color.RED); g.drawRect((int)pf.getImageableX(), (int)pf.getImageableY(), (int)pf.getImageableWidth(), (int)pf.getImageableHeight()); return Printable.PAGE_EXISTS; } else { return Printable.NO_SUCH_PAGE; } }
Example 12
Source File: PrintLatinCJKTest.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException { if (pageIndex > 0) { return Printable.NO_SUCH_PAGE; } g.translate((int) pf.getImageableX(), (int) pf.getImageableY()); g.setFont(new Font("Dialog", Font.PLAIN, 36)); g.drawString("\u4e00\u4e01\u4e02\u4e03\u4e04English", 20, 100); return Printable.PAGE_EXISTS; }
Example 13
Source File: ImagePrinter.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public int print(Graphics g, PageFormat pf, int index) { if (index > 0 || image == null) { return Printable.NO_SUCH_PAGE; } ((Graphics2D)g).translate(pf.getImageableX(), pf.getImageableY()); int w = image.getWidth(null); int h = image.getHeight(null); int iw = (int)pf.getImageableWidth(); int ih = (int)pf.getImageableHeight(); // ensure image will fit int dw = w; int dh = h; if (dw > iw) { dh = (int)(dh * ( (float) iw / (float) dw)) ; dw = iw; } if (dh > ih) { dw = (int)(dw * ( (float) ih / (float) dh)) ; dh = ih; } // centre on page int dx = (iw - dw) / 2; int dy = (ih - dh) / 2; g.drawImage(image, dx, dy, dx+dw, dy+dh, 0, 0, w, h, null); return Printable.PAGE_EXISTS; }
Example 14
Source File: TestTextPosInPrint.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override public int print(Graphics pg, PageFormat pf, int pageNum) throws PrinterException { if (pageNum > 0){ return Printable.NO_SUCH_PAGE; } Graphics2D g2 = (Graphics2D) pg; g2.translate(pf.getImageableX(), pf.getImageableY()); panel.paint(g2); return Printable.PAGE_EXISTS; }
Example 15
Source File: bug8023392.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { if (pageIndex >= 1) { return Printable.NO_SUCH_PAGE; } this.paint(graphics); return Printable.PAGE_EXISTS; }
Example 16
Source File: PrintLatinCJKTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException { if (pageIndex > 0) { return Printable.NO_SUCH_PAGE; } g.translate((int) pf.getImageableX(), (int) pf.getImageableY()); g.setFont(new Font("Dialog", Font.PLAIN, 36)); g.drawString("\u4e00\u4e01\u4e02\u4e03\u4e04English", 20, 100); return Printable.PAGE_EXISTS; }
Example 17
Source File: WrongPaperPrintingTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException { if (pageIndex == 0) { g.setColor(Color.RED); g.drawRect((int)pf.getImageableX(), (int)pf.getImageableY(), (int)pf.getImageableWidth(), (int)pf.getImageableHeight()); return Printable.PAGE_EXISTS; } else { return Printable.NO_SUCH_PAGE; } }
Example 18
Source File: ImagePrinter.java From Bytecoder with Apache License 2.0 | 5 votes |
public int print(Graphics g, PageFormat pf, int index) { if (index > 0 || image == null) { return Printable.NO_SUCH_PAGE; } ((Graphics2D)g).translate(pf.getImageableX(), pf.getImageableY()); int w = image.getWidth(null); int h = image.getHeight(null); int iw = (int)pf.getImageableWidth(); int ih = (int)pf.getImageableHeight(); // ensure image will fit int dw = w; int dh = h; if (dw > iw) { dh = (int)(dh * ( (float) iw / (float) dw)) ; dw = iw; } if (dh > ih) { dw = (int)(dw * ( (float) ih / (float) dh)) ; dh = ih; } // centre on page int dx = (iw - dw) / 2; int dy = (ih - dh) / 2; g.drawImage(image, dx, dy, dx+dw, dy+dh, 0, 0, w, h, null); return Printable.PAGE_EXISTS; }
Example 19
Source File: PSPrinterJob.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public int print(Graphics g, PageFormat pf, int pgIndex) { if (pgIndex > 0) { return Printable.NO_SUCH_PAGE; } else { // "aware" client code can detect that its been passed a // PrinterGraphics and could theoretically print // differently. I think this is more likely useful than // a problem. applet.printAll(g); return Printable.PAGE_EXISTS; } }
Example 20
Source File: TestSaveFileWithoutPrinter.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
@Override public int print(Graphics g, PageFormat pf, int pageIndex) throws PrinterException { if (pageIndex == 0) { return Printable.PAGE_EXISTS; } else { return Printable.NO_SUCH_PAGE; } }