簡體   English   中英

如何在打印機上打印 JFace TreeViewer

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

我正在 Eclipse 中開發一個插件,它以滾動復合顯示結果。 該組合包含一個 JFace TreeViewer。 我想將此 TreeViewer 打印到打印機。 我發現 import org.eclipse.swt.printing.Printer; 打印到打印機。

但是當我使用以下代碼段打印時

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

我要打印的樹包含工作區、項目資源管理器。 打印 output 僅顯示圖標。 它不顯示類、方法的名稱。

在我的聲譽超過 10 之前,我無法發布屏幕截圖。請在此處查看

如果我不清楚,請告訴我..

提前致謝

拉梅什·埃曼迪

        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