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.
我正在Eclipse中开发一个插件,它在scrolledComposite中显示结果。该组合包含一个JFace TreeViewer。我想将这个TreeViewer打印到打印机。我找到了import org.eclipse.swt.printing.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
我不能发布截图直到我的声誉超过10.检查它在这里
Please let me know if i am not clear..
如果我不清楚,请告诉我..
Thanks in advance
提前致谢
Ramesh Emandi
1 个解决方案
#1
0
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
#1
0
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