File: pdfgraphics.mli

package info (click to toggle)
camlpdf 0.5-1
  • links: PTS, VCS
  • area: non-free
  • in suites: squeeze, wheezy
  • size: 1,516 kB
  • ctags: 2,689
  • sloc: ml: 18,229; ansic: 139; makefile: 139
file content (169 lines) | stat: -rw-r--r-- 5,159 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
(** Structured Graphics - Incomplete and unsupported. *)
open Utility

(** Point. *)
type fpoint = float * float

(** Winding rule. *)
type winding_rule = EvenOdd | NonZero

(** A segment (a straight line or bezier curve) *)
type segment =
  | Straight of fpoint * fpoint
  | Bezier of fpoint * fpoint * fpoint * fpoint

(** Each segment list may be marked as a hole or not. *)
type hole = Hole | Not_hole

(* A [subpath] is either closed or open. *)
type closure = Closed | Open

(** A [subpath] is the pair of a hole and a list of segments. *)
type subpath = hole * closure * segment list

(** A path is made from a number of subpaths. *)
type path = winding_rule * subpath list

val string_of_path : path -> string

(** Colour values *)
type tiling = Tiling

type function_shading =
  {funshading_domain : float * float * float * float;
   funshading_matrix : Transform.transform_matrix;
   funshading_function : Pdffun.pdf_fun}

type radial_shading =
  {radialshading_coords : float * float * float * float * float * float;
   radialshading_domain : float * float;
   radialshading_function : Pdffun.pdf_fun list;
   radialshading_extend : bool * bool}

type axial_shading =
  {axialshading_coords : float * float * float * float;
   axialshading_domain : float * float;
   axialshading_function : Pdffun.pdf_fun 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 : Transform.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 transparency_attributes =
  {fill_transparency : float;
   line_transparency : float}

(** Path attributes. *)
type path_attributes =
  {path_transform : Transform.transform_matrix;
   path_fill : (Pdf.pdfobject * colvals) option;
   path_line : (Pdf.pdfobject * 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 : Transform.transform_matrix}

type textblock =
  text_attributes * Pdfpages.operator

type image_attributes =
  {image_transform : Transform.transform_matrix;
   image_transparency : float;
   image_softmask : softmask option} (* The /ca value *)

and softmask_subtype =
  Alpha | Luminosity

and transparency_group =
  {tr_group_colourspace : Pdf.pdfobject option;
   isolated : bool;
   knockout : bool;
   tr_graphic : graphic}

and softmask =
  {softmask_subtype : softmask_subtype;
   transparency_group : transparency_group;
   softmask_bbox : float * float * float * float;
   backdrop : float list option;
   softmask_transfer : Pdffun.pdf_fun option}

and fontname = string * Pdf.pdfobject

(** For now, just support for reading paths out. Eventually a tree-structure for
an op stream. *)
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 * bytestream * Transform.transform_matrix
  | Clip of path * graphic_elt list
  | Shading of path option * shading * Transform.transform_matrix

and graphic =
  {elements : graphic_elt list; (* Page content *)
   fonts : fontname list; (* Fonts *)
   resources : Pdf.pdfobject} (* Anything else in /Resources *)

(** Bounding box xmin, xmax, ymin, yman of a graphic *)
val bbox_of_graphic : graphic -> float * float * float * float

(** Make a graphic from operations. *)
val graphic_of_page : Pdf.pdfdoc -> Pdfdoc.page -> graphic

(** Make a graphic from a simple string. *)
val graphic_of_ops : Pdfpages.operator list -> graphic

(** Flatten a graphic to a list of operations and replace the operations in a
page by them, returning the new page. *)
val page_of_graphic : Pdf.pdfdoc -> (float * float * float * float) -> graphic -> Pdfdoc.page

(** Debug string of a [graphic] *)
val string_of_graphic : graphic -> string

(** Operations from a simple graphic (i.e no need for resources etc.) *)
val ops_of_simple_graphic : graphic -> Pdfpages.operator list

(** Pdfdoc.content entry from a simple graphic (i.e no need for resources etc.) *)
val streams_of_simple_graphic : graphic -> Pdf.pdfobject list

(** Transform a graphic by a matrixn*)
val transform_graphic : Transform.transform_matrix -> graphic -> graphic