Documentation

The Java™ Tutorials
Hide TOC
Printing打印
Trail: 2D Graphics

Lesson: Printing课程:打印

Since the Java 2D API enables you to draw on any surface, a natural extension of that is the ability to print Java 2D graphics. 由于Java2D API使您能够在任何曲面上绘制,因此它的一个自然扩展是打印Java2D图形的能力。A printer can be considered a graphics device just like a display.打印机可以像显示器一样被视为图形设备。

The Java 2D printing API is not limited to printing graphics. Java 2D打印API不限于打印图形。It enables you to print the content of an application's user interface as well. 它还允许您打印应用程序用户界面的内容。Content can be printed by sending raw data to the printer under the formatting control of the Java 2D printing API, or by using the Java 2D Graphics API.可以通过在Java 2D打印API的格式控制下向打印机发送原始数据或使用Java 2D图形API来打印内容。

In this lesson you will explore the printer and job control functions of the Java 2D printing API which are complements to the rendering elements. 在本课程中,您将探索Java 2D打印API的打印机和作业控制功能,这些功能是对渲染元素的补充。You will learn how to look up printers configured on the system or network and discover information about these printers such as the paper sizes it supports, and selecting these attributes for printing, and user dialogs.您将学习如何查找在系统或网络上配置的打印机,以及如何查找有关这些打印机的信息,例如打印机支持的纸张尺寸,以及如何选择这些属性进行打印,以及如何使用用户对话框。

The main classes and interfaces involved in printing are represented in the java.awt.print and javax.print packages (the last package allows you to get access to the printing services).打印中涉及的主要类和接口在java.awt.printjavax.print包中表示(最后一个包允许您访问打印服务)。

The basic printing operations are represented in the following sections:以下各节介绍了基本打印操作:


Previous page: Previous Lesson
Next page: A Basic Printing Program