camlpdf

Read, write and modify PDF files
Library camlpdf
Module Pdfgraphics
type fpoint = float * float
type winding_rule =
| EvenOdd
| NonZero
type segment =
| Straight of fpoint * fpoint
| Bezier of fpoint * fpoint * fpoint * fpoint
type hole =
| Hole
| Not_hole
type closure =
| Closed
| Open
type subpath = hole * closure * segment list
type path = winding_rule * subpath list
type tiling =
| Tiling
type function_shading = {
funshading_domain : float * float * float * float;
funshading_matrix : Pdftransform.transform_matrix;
funshading_function : Pdffun.t;
}
type radial_shading = {
radialshading_coords : float * float * float * float * float * float;
radialshading_domain : float * float;
radialshading_function : Pdffun.t list;
radialshading_extend : bool * bool;
}
type axial_shading = {
axialshading_coords : float * float * float * float;
axialshading_domain : float * float;
axialshading_function : Pdffun.t list;
axialshading_extend : bool * bool;
}
type shading_kind =
| FunctionShading of function_shading
| AxialShading of axial_shading
| RadialShading of radial_shading
| FreeFormGouraudShading
| LatticeFormGouraudShading
| CoonsPatchMesh
| TensorProductPatchMesh
type shading = {
shading_colourspace : Pdf.pdfobject;
shading_background : Pdf.pdfobject option;
shading_bbox : Pdf.pdfobject option;
shading_antialias : bool;
shading_matrix : Pdftransform.transform_matrix;
shading_extgstate : Pdf.pdfobject;
shading : shading_kind;
}
type pattern =
| ColouredTilingPattern of tiling
| UncolouredTilingPattern of tiling
| ShadingPattern of shading
type colvals =
| Floats of float list
| Named of string * float list
| Pattern of pattern
type objectclass =
| PathObject
| TextObject
| ClippingPathObject
| PageDescriptionLevel
| ShadingObject
| InlineImageObject
| ExternalObject
val string_of_objectclass : objectclass -> string
type transparency_attributes = {
fill_transparency : float;
line_transparency : float;
}
type path_attributes = {
path_transform : Pdftransform.transform_matrix;
path_fill : (Pdfspace.t * colvals) option;
path_line : (Pdfspace.t * colvals) option;
path_linewidth : float;
path_joinstyle : int;
path_capstyle : int;
path_dash : float list * float;
path_mitrelimit : float;
path_transparency : transparency_attributes;
path_intent : string;
}
type text_attributes = {
textmode : int;
}
type textblock_attributes = {
textblock_transform : Pdftransform.transform_matrix;
}
type textblock = text_attributes * Pdfops.t
type softmask_subtype =
| Alpha
| Luminosity
type transparency_group = {
tr_group_colourspace : Pdf.pdfobject option;
isolated : bool;
knockout : bool;
tr_graphic : t;
}
and softmask = {
softmask_subtype : softmask_subtype;
transparency_group : transparency_group;
softmask_bbox : float * float * float * float;
backdrop : float list option;
softmask_transfer : Pdffun.t option;
}
and image_attributes = {
image_transform : Pdftransform.transform_matrix;
image_transparency : float;
image_softmask : softmask option;
}
and fontname = string * Pdf.pdfobject
and graphic_elt =
| Path of path * path_attributes
| Text of textblock list * textblock_attributes
| MCPoint of string
| MCPointProperties of string * Pdf.pdfobject
| MCSection of string * graphic_elt list
| MCSectionProperties of string * Pdf.pdfobject * graphic_elt list
| Image of image_attributes * int
| GraphicInlineImage of Pdf.pdfobject * Pdfio.bytes * Pdftransform.transform_matrix
| Clip of path * graphic_elt list
| Shading of path option * shading * Pdftransform.transform_matrix
and t = {
elements : graphic_elt list;
fonts : fontname list;
resources : Pdf.pdfobject;
}
val bbox_of_segment : segment -> float * float * float * float
val bbox_of_path : ('a * ('b * 'c * segment list) list) -> float * float * float * float
val bbox_of_graphic_inner : (float * float * float * float) -> graphic_elt list -> float * float * float * float
val bbox_of_graphic : t -> float * float * float * float
val string_of_segment : segment -> string
val string_of_subpath : (hole * closure * segment list) -> string
val string_of_path : (winding_rule * (hole * closure * segment list) list) -> string
val string_of_textblock : ('a * Pdfops.t) -> string
val string_of_font : (string * Pdf.pdfobject) -> string
val string_of_colvals : colvals -> string
val string_of_attributes : path_attributes -> string
val string_of_graphic_elt : graphic_elt -> string
val string_of_graphic : t -> string
type state = {
mutable objectclass : objectclass;
mutable clip : path option;
mutable intent : string;
mutable fill : colvals;
mutable linewidth : float;
mutable line : colvals;
mutable mitrelimit : float;
mutable joinstyle : int;
mutable capstyle : int;
mutable colourspace_stroke : Pdfspace.t;
mutable colourspace_nonstroke : Pdfspace.t;
mutable dash : float list * float;
mutable flatness : int;
mutable transform : Pdftransform.transform_matrix;
mutable extra_transform : Pdftransform.transform_matrix;
mutable text_transform : Pdftransform.transform_matrix;
mutable text_line_transform : Pdftransform.transform_matrix;
mutable opacity_stroke : float;
mutable opacity_nonstroke : float;
mutable character_spacing : float;
mutable word_spacing : float;
mutable scale : float;
mutable leading : float;
mutable font_and_size : (string * float) option;
mutable font_render : int;
mutable font_rise : float;
mutable blendmode : int;
mutable softmask : softmask option;
mutable in_xobject : int;
mutable opdo_matrix : Pdftransform.transform_matrix;
}
val default_state : unit -> state
val state : state ref
val string_of_state : state -> string
val path_attributes_fill_and_stroke : unit -> path_attributes
val path_attributes_fill : unit -> path_attributes
val path_attributes_stroke : unit -> path_attributes
val textstate : unit -> text_attributes
val nonzero : winding_rule
val initial_colour : Pdf.t -> 'a -> Pdf.pdfobject -> colvals
type partial =
| NoPartial
| PartialText of textblock list
| PartialPath of fpoint * fpoint * segment list * subpath list
val read_transparency_group : Pdf.t -> Pdf.pdfobject -> transparency_group * float * float * float * float
val read_soft_mask : Pdf.t -> Pdf.pdfobject -> softmask option
val update_graphics_state_from_dict : Pdf.t -> Pdf.pdfobject -> Pdf.pdfobject -> unit
val statestack : state list ref
val copystate : unit -> state
val push_statestack : unit -> unit
val pop_statestack : unit -> unit
val read_tiling_pattern : Pdf.pdfobject -> pattern
val read_function_shading : Pdf.t -> Pdf.pdfobject -> shading_kind
val read_radial_shading : Pdf.t -> Pdf.pdfobject -> shading_kind
val read_axial_shading : Pdf.t -> Pdf.pdfobject -> shading_kind
val read_shading_pattern : Pdf.t -> Pdf.pdfobject -> pattern
val read_pattern : Pdf.t -> Pdfpage.t -> string -> pattern
val process_op : Pdf.t -> Pdfpage.t -> (partial * graphic_elt list) -> Pdfops.t -> partial * graphic_elt list
val getuntil_matching_emc : int -> Pdfops.t list -> Pdfops.t list -> Pdfops.t list * Pdfops.t list
val getuntil_matching_Q : int -> Pdfops.t list -> Pdfops.t list -> Pdfops.t list * Pdfops.t list
val process_ops : Pdf.t -> Pdfpage.t -> (partial * graphic_elt list) -> Pdfops.t list -> partial * graphic_elt list
val fonts_of_page : Pdf.t -> Pdfpage.t -> fontname list
val read_form_xobject : Pdf.t -> Pdfpage.t -> Pdf.pdfobject -> graphic_elt list
val graphic_of_page : Pdf.t -> Pdfpage.t -> t
val graphic_of_ops : Pdfops.t list -> t
val int_of_shading_kind : shading_kind -> int
val entries_of_shading : Pdf.t -> shading -> (string * Pdf.pdfobject) list
val shading_object_of_shading : Pdf.t -> shading -> Pdf.pdfobject
val pattern_object_of_pattern : int -> Pdftransform.transform_matrix -> Pdf.t -> pattern -> Pdf.pdfobject
val ops_of_segs : segment list -> closure -> Pdfops.t list
val protect : Pdfops.t list -> Pdfops.t list
val attribute_ops_of_path : ('a * path_attributes) -> Pdfops.t list
val transform_ops_of_path : ('a * path_attributes) -> Pdfops.t list
val stroke_ops_of_path : ((winding_rule * 'a) * path_attributes) -> Pdfops.t
val path_ops_of_path : ('a * ('b * closure * segment list) list) -> Pdfops.t list
val ops_of_path : Pdf.t -> Pdfpage.t -> ((winding_rule * ('a * closure * segment list) list) * path_attributes) -> Pdfops.t list * Pdf.pdfobject
val ops_of_textstate : 'a -> 'b list
val ops_of_textpiece : ('a * 'b) -> 'c list
val ops_of_text : Pdftransform.transform_matrix -> ('a * Pdfops.t) list -> Pdfops.t list
val extreme_of_4 : ( 'a -> 'a -> int ) -> 'b -> 'c -> 'd -> 'e -> 'f
val min_of_4 : float -> float -> float -> float -> float
val max_of_4 : float -> float -> float -> float -> float
val transform_bbox : Pdftransform.transform_matrix -> float -> float -> float -> float -> float * float * float * float
val pdfobject_of_transparency_group : (float * float * float * float) -> Pdf.t -> transparency_group -> int
val pdfobject_of_softmask : Pdf.t -> softmask -> int
val ops_of_image : Pdf.t -> Pdfpage.t -> (image_attributes * int) -> Pdfops.t list * Pdf.pdfobject
val ops_of_shading : Pdf.t -> Pdfpage.t -> path option -> shading -> Pdftransform.transform_matrix -> Pdfops.t list * Pdf.pdfobject
val ops_of_graphic_acc : Pdf.t -> Pdfpage.t -> Pdfops.t list list -> graphic_elt list -> Pdfops.t list * Pdfpage.t
val image_numbers_of_elts : int list -> graphic_elt list -> int list
val make_xobjects : Pdf.t -> graphic_elt list -> (string * Pdf.pdfobject) list
val make_resources : Pdf.t -> t -> Pdfpage.t -> Pdf.pdfobject
val page_of_graphic : Pdf.t -> (float * float * float * float) -> t -> Pdfpage.t
val ops_of_simple_graphic : t -> Pdfops.t list
val streams_of_simple_graphic : t -> Pdf.pdfobject list
val transform_segment : Pdftransform.transform_matrix -> segment -> segment
val transform_subpath : Pdftransform.transform_matrix -> ('a * 'b * segment list) -> 'c * 'd * segment list
val transform_path : Pdftransform.transform_matrix -> ('a * ('b * 'c * segment list) list) -> 'd * ('b * 'c * segment list) list
val transform_graphic : Pdftransform.transform_matrix -> t -> t