public interface Printable
Printable接口由当前页面画家的print方法实现,该方法由打印系统调用以呈现页面。
构建Pageable时,实现此接口的PageFormat实例和实例用于描述每个页面。
调用实现Printable的实例来打印页面的图形。
A Printable(..)可以设置在PrinterJob 。 当客户端随后通过调用PrinterJob.print(..)启动打印
被传送到打印系统,直到所有页面都被打印出来。 它通过调用Printable.print(..)直到打印文档中的所有页面。 在使用Printable界面时,只要打印系统要求,打印就可以对页面的内容进行成像。
Printable.print(..)的Printable.print(..)包括PageFormat页面的可打印区域的PageFormat,用于计算适合页面的内容所需的区域,以及指定所请求页面的基于零的打印流索引的页面索引。
为正确打印行为,应遵守以下几点:
Printable.print(..) ,页面索引单调增加,尽管如上所述, Printable应该期望多次调用页面索引,并且页面索引可能会被跳过,当页面范围由客户端指定时,或者由用户通过打印对话框。 Printable必须检查并兑现提供的PageFormat参数以及页面索引。 要绘制的页面的格式由提供的PageFormat指定。 因此,页面的大小,方向和可成像区域已经确定,渲染必须在该可成像区域内。 这是纠正打印行为的关键,它意味着客户端有责任跟踪指定页面上所属的内容。 Printable从客户端提供的Pageable获得时,客户端可以为每个页面索引提供不同的PageFormats。 分页符的计算必须说明这一点。 Pageable , PageFormat , PrinterJob
| Modifier and Type | Field and Description |
|---|---|
static int |
NO_SUCH_PAGE
从
print返回,表示
pageIndex太大,请求的页面不存在。
|
static int |
PAGE_EXISTS
从
print(Graphics, PageFormat, int)返回,表示请求的页面被呈现。
|
static final int PAGE_EXISTS
print(Graphics, PageFormat, int)返回,表示请求的页面被呈现。
static final int NO_SUCH_PAGE
print返回,表示
pageIndex太大,请求的页面不存在。
int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
Graphics上下文中。
A PrinterJob调用Printable接口以请求将页面呈现到由graphics的上下文中。
要绘制的页面的格式由pageFormat 。
请求页面的零基索引由pageIndex 。
如果请求的页面不存在,则此方法返回NO_SUCH_PAGE;
否则返回PAGE_EXISTS。
Graphics类或子类实现PrinterGraphics接口提供附加信息。
如果Printable对象中止打印作业,那么它会抛出一个PrinterException 。
graphics - 绘制页面的上下文
pageFormat - 正在绘制页面的大小和方向
pageIndex - 要绘制的页面的零
pageIndex引
pageIndex指定不存在的页面,
pageIndex NO_SUCH_PAGE。
PrinterException - 打印作业终止时抛出。
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.