• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef PUBLIC_FPDF_TRANSFORMPAGE_H_
8 #define PUBLIC_FPDF_TRANSFORMPAGE_H_
9 
10 // NOLINTNEXTLINE(build/include)
11 #include "fpdfview.h"
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 // Set "MediaBox" entry to the page dictionary.
18 //
19 // page   - Handle to a page.
20 // left   - The left of the rectangle.
21 // bottom - The bottom of the rectangle.
22 // right  - The right of the rectangle.
23 // top    - The top of the rectangle.
24 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetMediaBox(FPDF_PAGE page,
25                                                     float left,
26                                                     float bottom,
27                                                     float right,
28                                                     float top);
29 
30 // Set "CropBox" entry to the page dictionary.
31 //
32 // page   - Handle to a page.
33 // left   - The left of the rectangle.
34 // bottom - The bottom of the rectangle.
35 // right  - The right of the rectangle.
36 // top    - The top of the rectangle.
37 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetCropBox(FPDF_PAGE page,
38                                                    float left,
39                                                    float bottom,
40                                                    float right,
41                                                    float top);
42 
43 // Set "BleedBox" entry to the page dictionary.
44 //
45 // page   - Handle to a page.
46 // left   - The left of the rectangle.
47 // bottom - The bottom of the rectangle.
48 // right  - The right of the rectangle.
49 // top    - The top of the rectangle.
50 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetBleedBox(FPDF_PAGE page,
51                                                     float left,
52                                                     float bottom,
53                                                     float right,
54                                                     float top);
55 
56 // Set "TrimBox" entry to the page dictionary.
57 //
58 // page   - Handle to a page.
59 // left   - The left of the rectangle.
60 // bottom - The bottom of the rectangle.
61 // right  - The right of the rectangle.
62 // top    - The top of the rectangle.
63 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetTrimBox(FPDF_PAGE page,
64                                                    float left,
65                                                    float bottom,
66                                                    float right,
67                                                    float top);
68 
69 // Set "ArtBox" entry to the page dictionary.
70 //
71 // page   - Handle to a page.
72 // left   - The left of the rectangle.
73 // bottom - The bottom of the rectangle.
74 // right  - The right of the rectangle.
75 // top    - The top of the rectangle.
76 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetArtBox(FPDF_PAGE page,
77                                                   float left,
78                                                   float bottom,
79                                                   float right,
80                                                   float top);
81 
82 // Get "MediaBox" entry from the page dictionary.
83 //
84 // page   - Handle to a page.
85 // left   - Pointer to a float value receiving the left of the rectangle.
86 // bottom - Pointer to a float value receiving the bottom of the rectangle.
87 // right  - Pointer to a float value receiving the right of the rectangle.
88 // top    - Pointer to a float value receiving the top of the rectangle.
89 //
90 // On success, return true and write to the out parameters. Otherwise return
91 // false and leave the out parameters unmodified.
92 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetMediaBox(FPDF_PAGE page,
93                                                          float* left,
94                                                          float* bottom,
95                                                          float* right,
96                                                          float* top);
97 
98 // Get "CropBox" entry from the page dictionary.
99 //
100 // page   - Handle to a page.
101 // left   - Pointer to a float value receiving the left of the rectangle.
102 // bottom - Pointer to a float value receiving the bottom of the rectangle.
103 // right  - Pointer to a float value receiving the right of the rectangle.
104 // top    - Pointer to a float value receiving the top of the rectangle.
105 //
106 // On success, return true and write to the out parameters. Otherwise return
107 // false and leave the out parameters unmodified.
108 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetCropBox(FPDF_PAGE page,
109                                                         float* left,
110                                                         float* bottom,
111                                                         float* right,
112                                                         float* top);
113 
114 // Get "BleedBox" entry from the page dictionary.
115 //
116 // page   - Handle to a page.
117 // left   - Pointer to a float value receiving the left of the rectangle.
118 // bottom - Pointer to a float value receiving the bottom of the rectangle.
119 // right  - Pointer to a float value receiving the right of the rectangle.
120 // top    - Pointer to a float value receiving the top of the rectangle.
121 //
122 // On success, return true and write to the out parameters. Otherwise return
123 // false and leave the out parameters unmodified.
124 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetBleedBox(FPDF_PAGE page,
125                                                          float* left,
126                                                          float* bottom,
127                                                          float* right,
128                                                          float* top);
129 
130 // Get "TrimBox" entry from the page dictionary.
131 //
132 // page   - Handle to a page.
133 // left   - Pointer to a float value receiving the left of the rectangle.
134 // bottom - Pointer to a float value receiving the bottom of the rectangle.
135 // right  - Pointer to a float value receiving the right of the rectangle.
136 // top    - Pointer to a float value receiving the top of the rectangle.
137 //
138 // On success, return true and write to the out parameters. Otherwise return
139 // false and leave the out parameters unmodified.
140 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetTrimBox(FPDF_PAGE page,
141                                                         float* left,
142                                                         float* bottom,
143                                                         float* right,
144                                                         float* top);
145 
146 // Get "ArtBox" entry from the page dictionary.
147 //
148 // page   - Handle to a page.
149 // left   - Pointer to a float value receiving the left of the rectangle.
150 // bottom - Pointer to a float value receiving the bottom of the rectangle.
151 // right  - Pointer to a float value receiving the right of the rectangle.
152 // top    - Pointer to a float value receiving the top of the rectangle.
153 //
154 // On success, return true and write to the out parameters. Otherwise return
155 // false and leave the out parameters unmodified.
156 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GetArtBox(FPDF_PAGE page,
157                                                        float* left,
158                                                        float* bottom,
159                                                        float* right,
160                                                        float* top);
161 
162 // Apply transforms to |page|.
163 //
164 // If |matrix| is provided it will be applied to transform the page.
165 // If |clipRect| is provided it will be used to clip the resulting page.
166 // If neither |matrix| or |clipRect| are provided this method returns |false|.
167 // Returns |true| if transforms are applied.
168 //
169 // This function will transform the whole page, and would take effect to all the
170 // objects in the page.
171 //
172 // page        - Page handle.
173 // matrix      - Transform matrix.
174 // clipRect    - Clipping rectangle.
175 FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
176 FPDFPage_TransFormWithClip(FPDF_PAGE page,
177                            const FS_MATRIX* matrix,
178                            const FS_RECTF* clipRect);
179 
180 // Transform (scale, rotate, shear, move) the clip path of page object.
181 // page_object - Handle to a page object. Returned by
182 // FPDFPageObj_NewImageObj().
183 //
184 // a  - The coefficient "a" of the matrix.
185 // b  - The coefficient "b" of the matrix.
186 // c  - The coefficient "c" of the matrix.
187 // d  - The coefficient "d" of the matrix.
188 // e  - The coefficient "e" of the matrix.
189 // f  - The coefficient "f" of the matrix.
190 FPDF_EXPORT void FPDF_CALLCONV
191 FPDFPageObj_TransformClipPath(FPDF_PAGEOBJECT page_object,
192                               double a,
193                               double b,
194                               double c,
195                               double d,
196                               double e,
197                               double f);
198 
199 // Experimental API.
200 // Get the clip path of the page object.
201 //
202 //   page object - Handle to a page object. Returned by e.g.
203 //                 FPDFPage_GetObject().
204 //
205 // Returns the handle to the clip path, or NULL on failure. The caller does not
206 // take ownership of the returned FPDF_CLIPPATH. Instead, it remains valid until
207 // FPDF_ClosePage() is called for the page containing |page_object|.
208 FPDF_EXPORT FPDF_CLIPPATH FPDF_CALLCONV
209 FPDFPageObj_GetClipPath(FPDF_PAGEOBJECT page_object);
210 
211 // Experimental API.
212 // Get number of paths inside |clip_path|.
213 //
214 //   clip_path - handle to a clip_path.
215 //
216 // Returns the number of objects in |clip_path| or -1 on failure.
217 FPDF_EXPORT int FPDF_CALLCONV FPDFClipPath_CountPaths(FPDF_CLIPPATH clip_path);
218 
219 // Experimental API.
220 // Get number of segments inside one path of |clip_path|.
221 //
222 //   clip_path  - handle to a clip_path.
223 //   path_index - index into the array of paths of the clip path.
224 //
225 // Returns the number of segments or -1 on failure.
226 FPDF_EXPORT int FPDF_CALLCONV
227 FPDFClipPath_CountPathSegments(FPDF_CLIPPATH clip_path, int path_index);
228 
229 // Experimental API.
230 // Get segment in one specific path of |clip_path| at index.
231 //
232 //   clip_path     - handle to a clip_path.
233 //   path_index    - the index of a path.
234 //   segment_index - the index of a segment.
235 //
236 // Returns the handle to the segment, or NULL on failure. The caller does not
237 // take ownership of the returned FPDF_PATHSEGMENT. Instead, it remains valid
238 // until FPDF_ClosePage() is called for the page containing |clip_path|.
239 FPDF_EXPORT FPDF_PATHSEGMENT FPDF_CALLCONV
240 FPDFClipPath_GetPathSegment(FPDF_CLIPPATH clip_path,
241                             int path_index,
242                             int segment_index);
243 
244 // Create a new clip path, with a rectangle inserted.
245 //
246 // Caller takes ownership of the returned FPDF_CLIPPATH. It should be freed with
247 // FPDF_DestroyClipPath().
248 //
249 // left   - The left of the clip box.
250 // bottom - The bottom of the clip box.
251 // right  - The right of the clip box.
252 // top    - The top of the clip box.
253 FPDF_EXPORT FPDF_CLIPPATH FPDF_CALLCONV FPDF_CreateClipPath(float left,
254                                                             float bottom,
255                                                             float right,
256                                                             float top);
257 
258 // Destroy the clip path.
259 //
260 // clipPath - A handle to the clip path. It will be invalid after this call.
261 FPDF_EXPORT void FPDF_CALLCONV FPDF_DestroyClipPath(FPDF_CLIPPATH clipPath);
262 
263 // Clip the page content, the page content that outside the clipping region
264 // become invisible.
265 //
266 // A clip path will be inserted before the page content stream or content array.
267 // In this way, the page content will be clipped by this clip path.
268 //
269 // page        - A page handle.
270 // clipPath    - A handle to the clip path. (Does not take ownership.)
271 FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertClipPath(FPDF_PAGE page,
272                                                        FPDF_CLIPPATH clipPath);
273 
274 #ifdef __cplusplus
275 }
276 #endif
277 
278 #endif  // PUBLIC_FPDF_TRANSFORMPAGE_H_
279