How to eliminate 'print -dmeta' crash?
5 views (last 30 days)
Show older comments
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();
0 Comments
Accepted Answer
Prasad Mendu
on 7 Jul 2016
Edited: Prasad Mendu
on 7 Jul 2016
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.
More Answers (0)
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!