e684. 以多种格式打印

Posted borter

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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

以上是关于e684. 以多种格式打印的主要内容,如果未能解决你的问题,请参考以下文章

一台漂亮的打印机“统治他们”

argparse 代码片段只打印部分日志

c 中打印格式%g

7.多关联双亲染色体片段代换系(CSSL)群体的代谢组分析

解析以多种格式传递的数据......如何从中获取我需要的数据

HTML代码片段