简体   繁体   English

如何在打印机上打印 JFace TreeViewer

[英]How to print a JFace TreeViewer on to the printer

I am developing a plugin in Eclipse, that shows the results in a scrolledComposite.我正在 Eclipse 中开发一个插件,它以滚动复合显示结果。 The composite contains a JFace TreeViewer.该组合包含一个 JFace TreeViewer。 I want to print this TreeViewer to the printer.我想将此 TreeViewer 打印到打印机。 I found import org.eclipse.swt.printing.Printer;我发现 import org.eclipse.swt.printing.Printer; to print to the printer.打印到打印机。

But when i am printing using following snippet但是当我使用以下代码段打印时

GC gc= new GC(printer);
Control abc[] = Composite.getChildren();
abc[0].print(gc);

The tree that i want to print contains the workspace, project explorer.我要打印的树包含工作区、项目资源管理器。 The print output is showing only the icons.打印 output 仅显示图标。 it is not displaying the names of classes, methods.它不显示类、方法的名称。

i cant post screenshot till my reputation is above 10.check it here在我的声誉超过 10 之前,我无法发布屏幕截图。请在此处查看

Please let me know if i am not clear..如果我不清楚,请告诉我..

Thanks in advance提前致谢

Ramesh Emandi拉梅什·埃曼迪

        Tree myWidget = treeViewer.getTree();
    Point size = myWidget.getSize();
    Image image = new Image(display, size.x, size.y);
    GC gc = new GC(myWidget);
    gc.copyArea(image, 0, 0);
    gc.dispose();

    // Get the ImageData and create a new printer Image from it
    ImageData imageData = image.getImageData();
    Image printImage = new Image(printer, imageData);

http://www.eclipse.org/swt/faq.php#noprintimage

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM