File: pdfdecomp.ml

package info (click to toggle)
camlpdf 2.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,272 kB
  • sloc: ml: 20,816; ansic: 9,525; makefile: 100; sh: 23
file content (15 lines) | stat: -rw-r--r-- 544 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(* pdfdecomp a.pdf b.pdf decompresses all streams in a.pdf writing the result
to b.pdf. *)
match Array.to_list Sys.argv with
| [_; in_file; out_file] ->
    begin try
      let pdf = Pdfread.pdf_of_file None None in_file in
        Pdf.iter_stream (Pdfcodec.decode_pdfstream_until_unknown pdf) pdf;
        Pdfwrite.pdf_to_file pdf out_file
    with
      err ->
        Printf.printf "Failed to decompress file.\n%s\n\n" (Printexc.to_string err);
        exit 1
    end
| _ ->
    print_string "Syntax: pdfdecomp <input> <output>\n\n"; exit 1