e682. 获得打印页的尺寸

Note that (0, 0) of the Graphics object is at the top-left of the actual page, which is outside the printable area.

    public int print(Graphics g, PageFormat pf, int pageIndex) {
        // The area of the printable area.
        double ix = pf.getImageableX();
        double iy = pf.getImageableY();
        double iw = pf.getImageableWidth();
        double ih = pf.getImageableHeight();
    
        // The area of the actual page.
        double x = 0;
        double y = 0;
        double w = pf.getWidth();
        double h = pf.getHeight();
        return Printable.NO_SUCH_PAGE;
    }

 

Related Examples
posted @ 2018-09-02 21:56  borter  阅读(267)  评论(0编辑  收藏  举报