How to eliminate 'print -dmeta' crash?

2 ビュー (過去 30 日間)
K E
K E 2016 年 6 月 28 日
コメント済み: K E 2016 年 7 月 8 日
Is there a way to either (a) prevent 'print -dmeta' from crashing Matlab, or (b) to preserve a figure window's aspect ratio when using 'print -dbitmap'?
Background: I am having trouble with clipboard copying within wordreport. I can choose either 'print -dmeta' or 'print -dbitmap' to copy Matlab figures to the clipboard then paste them into Word. However (a) -dmeta causes Matlab to crash (error below), and (b) -dbitmap loses the figure window's aspect ratio. For (a) I have the recommended Java version installed (Version 8 Update 91), and for (b) "Match figure screen size" is checked in Preferences > MATLAB > Figure Copy Template > Copy Options. I am using Windows 7 and R2015b. Any workarounds appreciated.
Error using print (line 212)
There was a problem while generating the output: Java exception occurred:
com.mathworks.hg.util.OutputHelperProcessingException: Problem while processing in an OutputHelper. Clipboard
copy failed.
at com.mathworks.hg.util.HGVectorOutputHelper.close(HGVectorOutputHelper.java:259)
Caused by: java.io.IOException: Clipboard copy failed.
at com.mathworks.hg.uij.ExportClipboardHelper.copyToClipboard(ExportClipboardHelper.java:121)
at com.mathworks.hg.util.HGVectorOutputHelper.close(HGVectorOutputHelper.java:257)
Error in wordreport/AddFigure_c (line 524)
print -dmeta
108 ex.throwAsCaller();

採用された回答

Prasad Mendu
Prasad Mendu 2016 年 7 月 7 日
編集済み: Prasad Mendu 2016 年 7 月 7 日
This error "Error using print" when printing in '-dmeta' format using MATLAB R2015b could be because of a bug present in it which is addressed in MATLAB R2016a. If it is not possible for you to upgrade the MATLAB, you can refer to the information given below.
I have found a piece of code on the File Exchange that is able to copy the figure to the clipboard which can be used as a possible workaround. There is a small issue in that the area copied includes the title bar of the figure window, but you can also interactively select an area to copy to the clipboard, or crop the images in post-processing.
The File Exchange submission can be found at the following link:
After one small change, however, I had no problems with this file. I had to change one line in order to make this submission work: I changed line 765 from:
cb = getDefaultToolkit.getSystemClipboard;
to:
cb = java.awt.Toolkit.getDefaultToolkit.getSystemClipboard;
After doing this, I called the function with:
>> screencapture('handle', gcf, 'target', 'clipboard')
in order to copy the entire figure (including window title bar) to the clipboard, and
>> screencapture('target', 'clipboard')
in order to interactively select a section of the figure to copy.
  1 件のコメント
K E
K E 2016 年 7 月 8 日
Great, I will first try updating to R2016b and seeing if that eliminates the issue.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by