-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickprint.m
More file actions
43 lines (35 loc) · 1.05 KB
/
quickprint.m
File metadata and controls
43 lines (35 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
% function quickprint(filename, outdir)
%
% Saves the current figure as PDF file.
function quickprint(filename, outdir, width, margin)
opt filename char tempname;
opt outdir char '';
opt width double [];
opt margin double 5;
%adaptPaper(width, margin);
%% new code
fig = gcf;
fig.Units = 'centimeters';
fig.PaperUnits = 'centimeters';
fig.PaperPosition = fig.Position;
fig.PaperSize = fig.Position(3:4);
%% end new code
%dualax update;
printok = false;
filename = fullfile(outdir, filename);
while ~printok
try
print(gcf, '-dpdf', sprintf('-r%d', 300), filename);
printok = true;
catch
printok = false;
numeral_pos = regexp(filename, '\d*$');
if ~isempty(numeral_pos)
numeral = str2num(filename(numeral_pos:end)) + 1;
filename = [filename(1:numeral_pos-1) num2str(numeral)];
else
filename = [filename '1'];
end
end
end
end