From e502cff0cc89609dd610bcc8d8c763d8dccf387f Mon Sep 17 00:00:00 2001 From: John Whitington Date: Thu, 13 Nov 2014 15:42:53 +0000 Subject: [PATCH] Better handling of linearization errors --- cpdfcommand.ml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 461d175..f7227d7 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -1989,12 +1989,14 @@ let really_write_pdf ?(encryption = None) ?(is_decompress=false) mk_id pdf outna 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 - begin try Sys.remove outname' with _ -> () end; if code > 0 then begin 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 + else + begin try Sys.remove outname' with _ -> () end; end; if args.squeeze then let s = filesize outname in