How to eliminate 'print -dmeta' crash?

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by