简体   繁体   中英

How to print a JFace TreeViewer on to the printer

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

        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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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