zoukankan      html  css  js  c++  java
  • e684. 以多种格式打印

    A Book object is used when printing pages with different page formats. This example prints the first page in landscape and five more pages in portrait.

        public class PrintBook {
            public static void main(String[] args) {
                PrinterJob pjob = PrinterJob.getPrinterJob();
                Book book = new Book();
        
                // First part.
                PageFormat landscape = pjob.defaultPage();
                landscape.setOrientation(PageFormat.LANDSCAPE);
                book.append(new Printable1(), landscape);
        
                // Second part.
                PageFormat portrait = pjob.defaultPage();
                portrait.setOrientation(PageFormat.PORTRAIT);
                book.append(new Printable2(), portrait, 5);
        
                pjob.setPageable(book);
                try {
                    pjob.print();
                } catch (PrinterException e) {
                }
            }
            static class Printable1 implements Printable {
                public int print(Graphics g, PageFormat pf, int pageIndex) {
                    drawGraphics(g, pf);
                    return Printable.PAGE_EXISTS;
                }
            }
            static class Printable2 implements Printable {
                public int print(Graphics g, PageFormat pf, int pageIndex) {
                    drawGraphics(g, pf);
                    return Printable.PAGE_EXISTS;
                }
            }
        }
    
    Related Examples
  • 相关阅读:
    穷举 迭代 while
    for 循环
    switch case
    if else 语句
    数据类型
    语句的输入、输出
    控件——DataGridview
    mysql-bin.000001文件的来源及处理方法
    /var/log目录下的20个Linux日志文件功能详解
    CountDownLatch
  • 原文地址:https://www.cnblogs.com/borter/p/9575608.html
Copyright © 2011-2022 走看看