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. )