Calling out to linearizer
This commit is contained in:
parent
f6329ae1d1
commit
ab460c0161
|
@ -28,14 +28,15 @@ let find_cpdflin provided =
|
||||||
with
|
with
|
||||||
_ -> None
|
_ -> None
|
||||||
|
|
||||||
let _ =
|
(* Call cpdflin, given the (temp) input name, the output name, and the location
|
||||||
let cpdflin =
|
of the cpdflin binary. Returns the exit code. *)
|
||||||
(match find_cpdflin None with
|
let call_cpdflin cpdflin temp output best_password =
|
||||||
None -> "none"
|
let command =
|
||||||
| Some x -> x)
|
cpdflin ^ " " ^ Filename.quote temp ^
|
||||||
|
" \"" ^ best_password ^ "\" " ^ Filename.quote output
|
||||||
in
|
in
|
||||||
print_endline cpdflin;
|
print_endline command;
|
||||||
Sys.command cpdflin
|
Sys.command command
|
||||||
|
|
||||||
(* Wrap up the file reading functions to exit with code 1 when an encryption
|
(* Wrap up the file reading functions to exit with code 1 when an encryption
|
||||||
problem occurs. This happens when object streams are in an encrypted document
|
problem occurs. This happens when object streams are in an encrypted document
|
||||||
|
@ -1811,10 +1812,28 @@ let write_pdf mk_id pdf =
|
||||||
let pdf = Cpdf.recompress_pdf <| nobble pdf in
|
let pdf = Cpdf.recompress_pdf <| nobble pdf in
|
||||||
if args.squeeze then Cpdf.squeeze pdf;
|
if args.squeeze then Cpdf.squeeze pdf;
|
||||||
Pdf.remove_unreferenced pdf;
|
Pdf.remove_unreferenced pdf;
|
||||||
Pdfwrite.pdf_to_file_options
|
let outname' =
|
||||||
~preserve_objstm:args.preserve_objstm
|
if args.linearize
|
||||||
~generate_objstm:args.create_objstm
|
then Filename.temp_file "cpdflin" ".pdf"
|
||||||
false (*FIXLIN args.linearize*) None mk_id pdf outname
|
else outname
|
||||||
|
in
|
||||||
|
Pdfwrite.pdf_to_file_options
|
||||||
|
~preserve_objstm:args.preserve_objstm
|
||||||
|
~generate_objstm:args.create_objstm
|
||||||
|
false None mk_id pdf outname';
|
||||||
|
let cpdflin =
|
||||||
|
match find_cpdflin None with
|
||||||
|
Some x -> x
|
||||||
|
| None -> raise (Pdf.PDFError "Could not find cpdflin")
|
||||||
|
in
|
||||||
|
if args.linearize then
|
||||||
|
let code = call_cpdflin cpdflin outname' outname "" 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")
|
||||||
|
end
|
||||||
| Stdout ->
|
| Stdout ->
|
||||||
let pdf = Cpdf.recompress_pdf <| nobble pdf in
|
let pdf = Cpdf.recompress_pdf <| nobble pdf in
|
||||||
if args.squeeze then Cpdf.squeeze pdf;
|
if args.squeeze then Cpdf.squeeze pdf;
|
||||||
|
|
Loading…
Reference in New Issue