Better handling of linearization errors

This commit is contained in:
John Whitington 2014-11-13 15:42:53 +00:00
parent 79b769b7ad
commit e502cff0cc
1 changed files with 4 additions and 2 deletions

View File

@ -1989,12 +1989,14 @@ let really_write_pdf ?(encryption = None) ?(is_decompress=false) mk_id pdf outna
in in
let best_password = if args.owner <> "" then args.owner else args.user in let best_password = if args.owner <> "" then args.owner else args.user in
let code = Cpdf.call_cpdflin cpdflin outname' outname best_password in let code = Cpdf.call_cpdflin cpdflin outname' outname best_password in
begin try Sys.remove outname' with _ -> () end;
if code > 0 then if code > 0 then
begin begin
begin try Sys.remove outname with _ -> () end; begin try Sys.remove outname with _ -> () end;
raise (Pdf.PDFError "linearizer failed") Sys.rename outname' outname;
soft_error "Linearizer failed with above error. File written without linearization."
end end
else
begin try Sys.remove outname' with _ -> () end;
end; end;
if args.squeeze then if args.squeeze then
let s = filesize outname in let s = filesize outname in