public int getNumberOfPages() { Paper paper = PAGE_FORMAT.getPaper(); numPages = (int) Math.ceil(getSize().getHeight() / paper.getImageableHeight()); return numPages; }
public int print(Graphics graphics, PageFormat pageFormat, int page) throws PrinterException { if (page < numPages) { Paper paper = pageFormat.getPaper();
static private PageFormat getMinimumMarginPageFormat(PrinterJob printJob) { PageFormat pf0 = printJob.defaultPage(); PageFormat pf1 = (PageFormat) pf0.clone(); Paper p = pf0.getPaper(); p.setImageableArea(0, 0,pf0.getWidth(), pf0.getHeight()); pf1.setPaper(p); PageFormat pf2 = printJob.validatePage(pf1); return pf2; }
public int getNumberOfPages() { Paper paper = PAGE_FORMAT.getPaper(); numPages = (int) Math.ceil(getSize().getHeight() / paper.getImageableHeight()); return numPages; }
@Override public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException { if (pageIndex < pages.size()) { pageFormat.getPaper().setImageableArea(0, 0, pageWidth, pageHeight); PagePanel p = pages.get(pageIndex); p.isPrinting = true; p.paint(g); p.isPrinting = false; return PAGE_EXISTS; } return NO_SUCH_PAGE; }
public int getNumberOfPages() { Paper paper = PAGE_FORMAT.getPaper(); numPages = (int) Math.ceil(getSize().getHeight() / paper.getImageableHeight()); return numPages; }
public int getNumberOfPages() { StyledDocument doc = (StyledDocument)getDocument(); Paper paper = PAGE_FORMAT.getPaper(); numPages = (int)Math.ceil(getSize().getHeight() / paper.getImageableHeight()); return numPages; }
public int getNumberOfPages() { StyledDocument doc = (StyledDocument)getDocument(); Paper paper = PAGE_FORMAT.getPaper(); numPages = (int)Math.ceil(getSize().getHeight() / paper.getImageableHeight()); return numPages; }
public int getNumberOfPages() { StyledDocument doc = (StyledDocument)getDocument(); Paper paper = PAGE_FORMAT.getPaper(); numPages = (int)Math.ceil(getSize().getHeight() / paper.getImageableHeight()); return numPages; }
public void setPageMargins( final PageFormat pageFormat, final Insets pageMargins ) { final Paper paper = pageFormat.getPaper(); setBorders( paper, pageMargins.top, pageMargins.left, pageMargins.bottom, pageMargins.right ); pageFormat.setPaper( paper ); } }
public void pageDialog() { this.pageFormat = getPrinterJob().pageDialog(getPageFormat()); Paper paper = pageFormat.getPaper(); StringBuilder sb = new StringBuilder(); NumberFormat format = DecimalFormat.getInstance(Locale.US); double paperWidth = paper.getWidth(); sb.append(format.format(paperWidth)).append(' '); double paperHeight = paper.getHeight(); sb.append(format.format(paperHeight)).append(' '); double imageableX = paper.getImageableX(); sb.append(format.format(imageableX)).append(' '); double imageableY = paper.getImageableY(); sb.append(format.format(imageableY)).append(' '); double imageableWidth = paper.getImageableWidth(); sb.append(format.format(imageableWidth)).append(' '); double imageableHeight = paper.getImageableHeight(); sb.append(format.format(imageableHeight)).append(' '); int pageFormatOrientation = pageFormat.getOrientation(); sb.append(format.format(pageFormatOrientation)).append(' '); ResourceController.getResourceController().setProperty("pageSettings", sb.toString()); }
/** * @param pf <code>PageFormat</code> that describes the size and * orientation of a page to be printed */ public static void setPageFormat(PageFormat pf) { getPreferences().putInt(PROP_PAGE_ORIENTATION, pf.getOrientation()); getPreferences().putDouble(PROP_PAGE_WIDTH, pf.getPaper().getWidth()); getPreferences().putDouble(PROP_PAGE_HEIGHT, pf.getPaper().getHeight()); getPreferences().putDouble(PROP_PAGE_IMAGEABLEAREA_WIDTH, pf.getPaper().getImageableWidth()); getPreferences().putDouble(PROP_PAGE_IMAGEABLEAREA_HEIGHT, pf.getPaper().getImageableHeight()); getPreferences().putDouble(PROP_PAGE_IMAGEABLEAREA_X, pf.getPaper().getImageableX()); getPreferences().putDouble(PROP_PAGE_IMAGEABLEAREA_Y, pf.getPaper().getImageableY()); }
/** Patch for a bug in the PageFormat class * @param pf PageFormat * @return imageable y coordination for this page format */ private float getImageableYPatch(PageFormat pf) { if (pf.getOrientation() == PageFormat.LANDSCAPE) { double ret = pf.getPaper().getWidth() - (pf.getImageableY() + pf.getImageableHeight()); return (float) Math.round(ret); } else { return (float) pf.getImageableY(); } }
/** Patch for a bug in the PageFormat class * @param pf PageFormat * @return imageable x coordination for this page format */ private float getImageableXPatch(PageFormat pf) { if (pf.getOrientation() == PageFormat.LANDSCAPE) { double ret = pf.getPaper().getHeight() - (pf.getImageableX() + pf.getImageableWidth()); return (float) Math.round(ret); } else { return (float) pf.getImageableX(); } }
/** Patch for a bug in the PageFormat class * @param pf PageFormat * @return imageable x coordination for this page format */ private float getImageableXPatch(PageFormat pf) { if (pf.getOrientation() == PageFormat.LANDSCAPE) { double ret = pf.getPaper().getHeight() - (pf.getImageableX() + pf.getImageableWidth()); return (float) Math.round(ret); } else { return (float) pf.getImageableX(); } }
/** Patch for a bug in the PageFormat class * @param pf PageFormat * @return imageable x coordination for this page format */ private float getImageableXPatch(PageFormat pf) { if (pf.getOrientation() == PageFormat.LANDSCAPE) { double ret = pf.getPaper().getHeight() - (pf.getImageableX() + pf.getImageableWidth()); return (float) Math.round(ret); } else { return (float) pf.getImageableX(); } }
/** Patch for a bug in the PageFormat class * @param pf PageFormat * @return imageable y coordination for this page format */ private float getImageableYPatch(PageFormat pf) { if (pf.getOrientation() == PageFormat.LANDSCAPE) { double ret = pf.getPaper().getWidth() - (pf.getImageableY() + pf.getImageableHeight()); return (float) Math.round(ret); } else { return (float) pf.getImageableY(); } }
/** Patch for a bug in the PageFormat class * @param pf PageFormat * @return imageable y coordination for this page format */ private float getImageableYPatch(PageFormat pf) { if (pf.getOrientation() == PageFormat.LANDSCAPE) { double ret = pf.getPaper().getWidth() - (pf.getImageableY() + pf.getImageableHeight()); return (float) Math.round(ret); } else { return (float) pf.getImageableY(); } }
public DefaultPrinter(WaveView ecgview, PageFormat pageFormat) { this.ecgview = ecgview; Paper paper = pageFormat.getPaper(); double margin = 18; paper.setImageableArea(margin, margin, paper.getWidth() - margin * 2, paper.getHeight() - margin * 2); pageFormat.setPaper(paper); setLayout(null); removeAll(); int pageWidth = (int) pageFormat.getWidth(); int pageHeight = (int) pageFormat.getHeight(); this.setPreferredSize(new Dimension(pageWidth, pageHeight)); }
PrinterJob job = PrinterJob.getPrinterJob(); PageFormat pf = job.defaultPage(); Paper paper = pf.getPaper(); double margin = 20.; paper.setImageableArea(margin, paper.getImageableY(), paper.getWidth() - 2* margin, paper.getImageableHeight()); pf.setPaper(paper); job.setPrintable(table.getPrintable(JTable.PrintMode.FIT_WIDTH, null, null), job.validatePage(pf)); job.print();