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 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