Skip to content

Commit

Permalink
added error handler when output file is already open
Browse files Browse the repository at this point in the history
  • Loading branch information
AldoCorbelliniUNIPR committed Oct 31, 2024
1 parent 8dadb41 commit d030a8a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions toolbox/utilities/pdfprotect.m
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,18 @@
pythoncode = which('pdfprotect.m');
[pythoncode1]=fileparts(pythoncode);
pythoncode2=[pythoncode1 filesep 'private' filesep 'pdf_encryption_wm_creation.py'];
% compose the string
str=[ pythonpath '\python ' pythoncode2 sp inputfile sp ...
watermark sp outputfile sp print sp edit sp passedit sp passopen];
% check if output file is already open
[fstatus, errmsg]=fopen(outputfile,"w");
if fstatus<0
disp('The output file is already open, please close it.')
disp(errmsg)
return
else
fclose(fstatus);
% compose the string
str=[ pythonpath '\python ' pythoncode2 sp inputfile sp ...
watermark sp outputfile sp print sp edit sp passedit sp passopen];
end
else
% linux: TODO!
disp('Sorry, Linux version is not available at the moment....')
Expand Down

0 comments on commit d030a8a

Please sign in to comment.