File: pdfcodec.mli

package info (click to toggle)
camlpdf 2.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,236 kB
  • sloc: ml: 20,559; ansic: 9,205; makefile: 100; sh: 18
file content (86 lines) | stat: -rw-r--r-- 2,714 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
(** Encoding and Decoding PDF Streams *)

(**
{b Currently supported:}
- Decoders: ASCIIHexDecode, ASCII85Decode, FlateDecode, LZWDecode, RunLengthDecode, CCITTFaxDecode.
- Encoders: ASCIIHexDecode, ASCII85Decode, FlateDecode, RunLengthDecode, CCITTFaxDecode.
- Decode predictors: PNG (all), TIFF (8-bit only).
*)

(** {2 Types} *)

(** Supported encodings. *)
type encoding =
  | ASCIIHex
  | ASCII85
  | RunLength
  | Flate

(** Predictors. *)
type predictor =
    TIFF2
  | PNGNone
  | PNGSub
  | PNGUp
  | PNGAverage
  | PNGPaeth
  | PNGOptimum

(** There was bad data. *)
exception Couldn'tDecodeStream of string

(** CamlPDF doesn't support this encoding or its predictor. *)
exception DecodeNotSupported of string

(** {2 Encoding} *)

(** Encode a PDF stream with an encoding. The only predictor supported is PNGUp. *)
val encode_pdfstream : Pdf.t -> encoding -> ?only_if_smaller:bool -> ?predictor:predictor -> ?predictor_columns:int -> Pdf.pdfobject -> unit

(** {2 Decoding} *)

(** Given a document and stream, decode. The pdf document is updated
with the decoded stream. May raise either of the exceptions above. *)
val decode_pdfstream : Pdf.t -> Pdf.pdfobject -> unit

(** Given a document and stream decode just one stage. May raise either of the
exceptions above. *)
val decode_pdfstream_onestage : Pdf.t -> Pdf.pdfobject -> unit

(** Given a document and stream decode until there's an unknown decoder. May
raise [Couldn'tDecodeStream]. *)
val decode_pdfstream_until_unknown : Pdf.t -> Pdf.pdfobject -> unit

(** Given a [Pdfio.input] with pointer at the first byte and an inline image
stream dictionary, decode the first decoder and its predictor. Return the data,
or [None] if this decoder isn't supported but the data pointer has been left in
the right place. The exceptions above can both be raised, in the case of bad
data or a completely unknown encoding. *)
val decode_from_input : Pdfio.input -> Pdf.pdfobject -> Pdfio.bytes option

(** {2 Low level functionality} *)

(** Setting this changes globally the FlateDecode compression level. Default 6. *)
val flate_level : int ref

(** Encode data in FlateDecode. *)
val encode_flate : Pdfio.bytes -> Pdfio.bytes

(** Decode data in FlateDecode. *)
val decode_flate : Pdfio.bytes -> Pdfio.bytes

(** Encode data in CCITTDecode Group 3. *)
val encode_ccitt : int -> Pdfio.bytes -> Pdfio.bytes

(** Encode data in CCITTDecode Group 4. *)
val encode_ccittg4 : int -> Pdfio.bytes -> Pdfio.bytes

(** Setting this boolean prints some debug information. *)
val debug : bool ref

(**/**)

(* Inter-module recursion. *)
val string_of_pdf : (Pdf.pdfobject -> string) ref

val encode_predictor : int -> int -> int -> int -> Pdfio.bytes -> Pdfio.bytes