打印——Java 2D Oracle官方教程翻译(双语对照)

本文翻译自Oracle官方教程
<<Previous • Trail • Next>>

Printing

All of the Swing and Java 2D graphics, including composited graphics and images, can be rendered to a printer by using the Java 2D Printing API. This API also provides document composition features that enable you to perform such operations as changing the order in which pages are printed.

所有Swing和Java 2D图像(无论是否经过加工合成)都可以用Java 2D Printing API渲染到打印机上。这个API还提供了排版功能,使你能够执行诸如改变打印页面顺序之类的操作。


Rendering to a printer is like rendering to a screen. The printing system controls when pages are rendered, just like the drawing system controls when a component is painted on the screen.

渲染到打印机与渲染到屏幕类似。打印系统控制着页面何时被渲染,就像绘制系统控制着组件何时被显示到屏幕上。


The Java 2D Printing API is based on a callback model in which the printing system, not the application, controls when pages are printed. The application provides the printing system with information about the document to be printed, and the printing system determines when each page needs to be imaged.

Java 2D Printing API基于一个 回调 模型,在这个模型中由打印系统(而不是应用程序)控制着何时打印页面。应用程序向打印系统提供文档信息,打印系统确定每一页何时需要成像。


The following two features are important to support printing:

下面两个功能对支持打印很重要:

  • Job control – Initiating and managing the print job including displaying the standard print and setup dialog boxes
  • 作业控制 – 启动和管理打印作业,包括显示标准的打印和设置对话框。
  • Pagination – Rendering each page when the printing system requests it
  • 分页 – 当打印系统请求时渲染每个页面

When pages need to be imaged, the printing system calls the application’s print method with an appropriate Graphics context. To use Java 2D API features when you print, you cast the Graphics object to a Graphics2D class, just like you do when you are rendering to the screen.

当需要对页面进行成像时,打印系统会用适当的Graphics环境访问应用程序的print方法。

To use Java 2D API features when you print, you cast the Graphics object to a Graphics2D class, just like you do when you are rendering to the screen.

要在打印时使用Java 2D API功能,需要将Graphics对象的类型转换为Graphics2D,就和在屏幕上渲染时所做的一样。


<<Previous • Trail • Next>>

发布了9 篇原创文章 · 获赞 0 · 访问量 641

猜你喜欢

转载自blog.csdn.net/realcfuture/article/details/104002612