我的问题:我在 Eclipse RCP 应用程序中有一个 ViewerComposite,它显示集成到其中的 Jasper Report (*.jrxml)。此 ViewerComposite 中显示的报告可以导出为 PDF、RTF、XML、jrxml、HTML、CSV 等。一切都很好,除了我无法使用 GUI 中 ViewerComposite 顶部提供的打印选项打印此报告。如何通过使用报告查看器的打印选项使用默认打印机打印报告。
Rem:我可以使用 Oracle JDeveloper 项目中的 jasper 报告查看器组合的打印选项打印 jasper 报告,而无需添加更多代码(默认情况下)。
最佳答案
我在 Eclipse RCP 应用程序中制作 Jasper Reports 的最佳方法如下:
详细代码如下:
//generate the jaspser print document
JasperPrint jprint = generateReport(id, nepFromDate, nepToDate);
//initialize JRViewer object
JRViewer jasperviewer = new JRViewer(jprint);
//add the SWT_AWT compposite for SWING contents of GUI
final Composite swtAwtComposite = new Composite(comTBReport, SWT.EMBEDDED);
swtAwtComposite.setBounds(10, 0, 767, 600);
Frame frame = SWT_AWT.new_Frame(swtAwtComposite);
Panel panel = new Panel();
frame.add(panel);
panel.setLayout(new BorderLayout(0, 0));
JRootPane rootPane = new JRootPane();
rootPane.setSize(767, 600);
panel.add(rootPane);
//Define a container yourself
Container c = rootPane.getContentPane();
//Add the JRViewer object onto the container to render in GUI
c.add(jasperviewer);
关于eclipse - 如何使用其打印选项在 Eclipse RCP 中打印 jasper 报告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8487451/