e681. 基本的打印程序
程序 基本 打印
2023-09-14 09:12:00 时间
Note that (0, 0) of the Graphics
object is at the top-left of the actual page, outside the printable area. In this example, the Graphics
object is translated so that (0, 0) becomes the top-left corner of the printable area.
import java.awt.*; import java.awt.print.*; public class BasicPrint extends JComponent implements Printable { public int print(Graphics g, PageFormat pf, int pageIndex) { if (pageIndex > 0) { return Printable.NO_SUCH_PAGE; } Graphics2D g2d = (Graphics2D)g; g2d.translate(pf.getImageableX(), pf.getImageableY()); drawGraphics(g2d, pf); return Printable.PAGE_EXISTS; } public static void main(String[] args) { PrinterJob pjob = PrinterJob.getPrinterJob(); PageFormat pf = pjob.defaultPage(); pjob.setPrintable(new BasicPrint(), pf); try { pjob.print(); } catch (PrinterException e) { } } }
Related Examples |
相关文章
- 微信小程序开发工具基本介绍入门级(备忘)
- 【说站】人人互助校园跑腿小程序源码
- 【愚公系列】2022年10月 微信小程序-优购电商项目-⼩程序事件的绑定
- 小程序技术生态,工业互联网平台生态打造利器
- PyQt5编程基础 2.1 GUI程序的基本框架
- SQL Server 2012无法连接到WMI提供程序(Cannot connect to WMI provider)解决方案
- Java执行外部程序并返回结果详解编程语言
- Linux C:程序打包技术实战(linuxc给程序打包)
- 构建C程序,在Linux环境中腾飞(clinux环境)
- 时间处理Java程序解决Redis过期时间问题(redisjava过期)
- 失效时间设置Java程序设置Redis过期时间的实现方法(redisjava过期)
- Linux下如何调试PHP程序(linux调试php)
- 用C#编写一个停放在任务栏上的图标程序
- 解决JSP开发中Web程序显示中文三种方法