使用Eclipse RCP程序进行打印 [英] Printing with an Eclipse RCP program

查看:180
本文介绍了使用Eclipse RCP程序进行打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种很好的标准方式,在我的RCP程序中生成输出并打印出来。这应该在Windows,Mac OS和Linux上使用标准打印对话框工作。



我知道Birt项目,但是我找不到任何提示如何在RCP程序中实现它,以及如何调用标准打印对话框以及如何将Birt生成的报告传递给打印机。



欢迎所有提示。 p>

解决方案

我相信Birt 项目用于使用IText 。 (现在 ITextPDF



另一个解决方案是<将href =http://dev.eclipse.org/newslists/news.eclipse.platform.rcp/msg11948.html =nofollow noreferrer>将Apache Fop集成到您的RCP项目中。 (请参阅 Apache FOP )。

为了正常工作, it建议不实现渲染器
,但实现一个 IFDocumentHandler / IFPainter pair,as一个新的中间格式的一部分(如果已经集成到Fop,我不知道):




  • 创建一个新的Java项目,决定一个
    包名,并准备两个实现 IFDocumentHandler
    (文档级别)和 IFPainter (页面级)。

    这些接口位于包 org.apache.fop.render.intermediate 的包中。

  • 要注册新的实现,您需要定义一个MIME类型(另见
    MimeConstants.java )并创建一个扩展 AbstractIFDocumentHandlerMaker 的类,用作工厂类。

  • 然后在其中创建一个名为 META-INF / services / org.apache.fop.render.intermediate.IFDocumentHandler 的文本文件写出制造商类的完全限定类名称。

  • 我可能需要添加的东西(目前缺少的)是 setIFDocumentHandlerOverride()方法> FOUserAgent ,因此您可以在 SWT 窗口中设置输出。正常的API针对生成文件进行了优化。






bug 23618 (七年后修复)包含制作打印机作业的一个小例子, SWT常见问题有一些有趣的元素在打印机(与显示,DPI和修剪)。这个 SWT片段也很清楚。 >
但是,这些示例都不通过命令调用,即使您可以一旦你有一个处理程序(即你写的任何类,可以打开打印对话框)设置就可以轻松地定义一个



注意:当您打电话给打印对话框时,只有最新的Eclipse Helios 3.6版本(即 2010年1月下旬的3.6M5 )能够记住所有文本编辑器的用户选择的选项,直到工作台关闭(即: / p>


  • 所选打印机

  • 打印到文件

  • :这些是公主r具体选项,如纸张大小,页面顺序方向等)


I am looking for a good, standard way to generate "output" in my RCP programm and print it. This should work as it works on Windows, Mac OS and Linux with the standard print dialog.

I am aware of the Birt project, but I could not find any hints about how to implement it within a RCP programm and how to invoke the standard print dialog and how to pass the Birt generated report to the printer.

Happy for all hints.

解决方案

I believe the Birt project used to use IText. (now ITextPDF)

The other solution is to integrate Apache Fop in your RCP project. (see Apache FOP).
For that to work, it is advised to not implement a renderer but implement a IFDocumentHandler/IFPainter pair, as part of a new intermediate format (if that has been integrated to Fop, which I am not sure):

  • create a new Java project, decide on a package name and prepare two classes implementing IFDocumentHandler (document-level) and IFPainter (page-level).
    These interfaces are found in the package org.apache.fop.render.intermediate.
  • To register the new implementation, you need to define a MIME type (see also MimeConstants.java) and create a class extending AbstractIFDocumentHandlerMaker which serves as a factory class.
  • Then create a text file called META-INF/services/org.apache.fop.render.intermediate.IFDocumentHandler in which you write the fully qualified class name of that "maker" class.
  • One thing I may have to add (that is currently- missing) is a setIFDocumentHandlerOverride() method in FOUserAgent, so you can set up the output in an SWT window. The normal API is optimized for generating files.

The bug 23618 (fixed seven years later!) contains a small example of making a Printer Job, and the SWT FAQ has some interesting elements on Printer (vs. Display, DPI and Trim). This SWT snippet is quite clear too.
However, none of those examples are called through commands, even though you can define one easily) once you have a Handler (i.e. any class you wrote, able to open the print dialog) set up.

Note: be aware, when you are calling the Print Dialog Box, that only the very latest releases of Eclipse Helios 3.6 (namely the 3.6M5 of late January 2010) is able to remember the user selected options for all textual editors until the workbench is shutdown (that is:

  • Selected printer
  • Print to file
  • Printer preferences: These are printer specific options like paper size, page order orientation etc. )

这篇关于使用Eclipse RCP程序进行打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆