function printpdf(handle, filename)
%PRINTPDF Print figure to PDF format
%   PRINTPDF(FNAME)
%
% See also: PRINT

if nargin < 2
    filename = handle;
    handle = gcf;
end

[path, name] = fileparts(filename);
print(handle, '-depsc', '_temp.eps');
system('epstopdf _temp.eps');
delete _temp.eps;
movefile('_temp.pdf', sprintf('%s.pdf', fullfile(path, name)));
end
