如何在打印机上打印 JFace TreeViewer

发布于 2024-11-10 12:13:31 字数 490 浏览 4 评论 0原文

我正在 Eclipse 中开发一个插件,它在滚动复合中显示结果。该组合包含一个 JFace TreeViewer。我想将这个 TreeViewer 打印到打印机上。我发现 import org.eclipse.swt.printing.Printer;打印到打印机。

但是当我使用以下代码片段打印时,

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

我想要打印的树包含工作区、项目资源管理器。 打印输出仅显示图标。它不显示类、方法的名称。

在我的声誉高于 10 之前,我无法发布屏幕截图。请在此处查看

如果我不清楚,请告诉我。

提前感谢

Ramesh Emandi

I am developing a plugin in Eclipse, that shows the results in a scrolledComposite. The composite contains a JFace TreeViewer. I want to print this TreeViewer to the printer. I found 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. it is not displaying the names of classes, methods.

i cant post screenshot till my reputation is above 10.check it here

Please let me know if i am not clear..

Thanks in advance

Ramesh Emandi

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风尘浪孓 2024-11-17 12:13:31
        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
        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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文