Is it possible to programmatically set the style sheet while printing in MATLAB 7.9 (R2009b)?
조회 수: 3 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2015년 6월 25일
편집: MathWorks Support Team
2019년 9월 4일
I would like to print figures directly from code and would like to use a pre-saved style sheet. When printing manually I can choose any pre-saved style sheet from print preview, I would like to do the same programmatically.
채택된 답변
MathWorks Support Team
2019년 9월 4일
편집: MathWorks Support Team
2019년 9월 4일
The ability to programmatically set the style sheet while printing is not available in MATLAB 7.9 (R2009b).
The following workaround shows how to save a print style sheet to a MAT file and then retrieve it for use when printing:
First, create a desired print style sheet:
1. create any figure and go to "Print Preview..." from the "File" menu.
2. specify your desired settings
3. close the print preview window (but not the figure window)
Now type the following into the MATLAB command window:
>> template = getprinttemplate(gcf)
Now save the variable 'template' into a MAT file called 'myprinttemplate':
>> save('myprinttemplate','template')
As written above, this will save the file to the current directory. You may want to move the file somewhere else though (such as a folder on the desktop)
Now that you have the desired print template saved, use the following code to print a figure:
>> load('myprinttemplate.mat') %loads the variable 'template'
>> setprinttemplate(gcf,template) %sets the print template for the current figure to be one you just loaded
>> print(gcf)%print the figure
Note two things in the code above:
1. The full path should be specified to LOAD if 'myprinttemplate' is not in the current directory
2. 'gcf' could be replaced by a handle to whatever figure you want to print
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!