How can I programatically set the page header for printing a figure in MATLAB 7.0 (R14)?

4 views (last 30 days)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
1. Create a figure by executing the following command:
plot(1:10)
2. The page header of the current figure can be set by executing the following commands:
hs = getappdata(gcf,'PrintHeaderHeaderSpec');
if isempty(hs)
hs = struct('dateformat','none',...
'string','',...
'fontname','Times',...
'fontsize',12,... % in points
'fontweight','normal',...
'fontangle','normal',...
'margin',72); % in points
end
currentPage = 1;
totalPages = 10;
hs.string = ['Header: Page ' num2str(currentPage) ' of ' num2str(totalPages)];
setappdata(gcf,'PrintHeaderHeaderSpec',hs);
3. The header will be visible when the figure is printed or previewed by selecting "File -> Print Preview".

More Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!