Utilities.actionsGlobalContext().lookup(EditorCookie.class);
if (editorCookie != null) {
for (final JEditorPane pane : editorCookie.getOpenedPanes()) {
if (pane != null && pane.isShowing()) {
try {
RTFConverter converter = new SwapCurrentProfileRTFConverter();
String formattedText = converter.convertContentToRTF(pane);
setRtfContest(new ByteArrayInputStream(formattedText.getBytes()));
return;
} catch (final Throwable e) {
org.openide.ErrorManager.getDefault().notify(e);
}