from
Remove Space in MATLAB Exported Postscript File
by Jorgen Johansson
Remove blank space in MATLAB exported postscript file.
|
| fixeps(filename)
|
function fixeps(filename)
fid = fopen(filename,'r+');
k=0;
while k <2 % 2 locations to replace.
tline = fgetl(fid); % get one line text
stridx=strfind(tline,'Box:');
if isempty(stridx)==0
len=length(tline) % the original line length
bb=sscanf(tline(stridx+4:end),'%i'); % read the numbers
bbstr=sprintf('%g %g %g %g',bb); % write bb numbers to string
tline=tline(1:stridx+3) % keep the "%%(page)boundingbox" string (with starting '%%')
spaces(1:len-length(tline)-length(bbstr)-1)=' '; % add trailing spaces as to overwrite old line completely
tline=[tline ' ' bbstr spaces]; % concate numbers and blank spaces to "%%(page)boundingbox"
fseek(fid,-len-2,'cof'); % before using fprintf search to correct position
count = fprintf(fid,'%s',tline)
fseek(fid,2,'cof'); % seek to beginning of line (for windows text file) on
% for linux: change '2' to '1' I think
k=k+1;
end
end
fclose(fid);
|
|
Contact us at files@mathworks.com