OLD | NEW |
---|---|
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef PUBLIC_FPDF_EDIT_H_ | 7 #ifndef PUBLIC_FPDF_EDIT_H_ |
8 #define PUBLIC_FPDF_EDIT_H_ | 8 #define PUBLIC_FPDF_EDIT_H_ |
9 | 9 |
10 #include <stdint.h> | 10 #include <stdint.h> |
11 | 11 |
12 #include "fpdfview.h" | 12 #include "fpdfview.h" |
13 | 13 |
14 // Define all types used in the SDK. Note they can be simply regarded as opaque | |
15 // pointers | |
16 // or long integer numbers. | |
17 | |
18 #define FPDF_ARGB(a, r, g, b) \ | 14 #define FPDF_ARGB(a, r, g, b) \ |
19 ((uint32_t)(((uint32_t)(b)&0xff) | (((uint32_t)(g)&0xff) << 8) | \ | 15 ((uint32_t)(((uint32_t)(b)&0xff) | (((uint32_t)(g)&0xff) << 8) | \ |
20 (((uint32_t)(r)&0xff) << 16) | (((uint32_t)(a)&0xff) << 24))) | 16 (((uint32_t)(r)&0xff) << 16) | (((uint32_t)(a)&0xff) << 24))) |
21 #define FPDF_GetBValue(argb) ((uint8_t)(argb)) | 17 #define FPDF_GetBValue(argb) ((uint8_t)(argb)) |
22 #define FPDF_GetGValue(argb) ((uint8_t)(((uint16_t)(argb)) >> 8)) | 18 #define FPDF_GetGValue(argb) ((uint8_t)(((uint16_t)(argb)) >> 8)) |
23 #define FPDF_GetRValue(argb) ((uint8_t)((argb) >> 16)) | 19 #define FPDF_GetRValue(argb) ((uint8_t)((argb) >> 16)) |
24 #define FPDF_GetAValue(argb) ((uint8_t)((argb) >> 24)) | 20 #define FPDF_GetAValue(argb) ((uint8_t)((argb) >> 24)) |
25 | 21 |
22 // TODO(dsinclair): What are these for? | |
Tom Sepez
2016/03/24 18:32:15
Nah, let's not check in this TODO
dsinclair
2016/03/25 02:06:09
Done.
| |
23 // The page object constants. | |
24 #define FPDF_PAGEOBJ_TEXT 1 | |
25 #define FPDF_PAGEOBJ_PATH 2 | |
26 #define FPDF_PAGEOBJ_IMAGE 3 | |
27 #define FPDF_PAGEOBJ_SHADING 4 | |
28 #define FPDF_PAGEOBJ_FORM 5 | |
29 | |
26 #ifdef __cplusplus | 30 #ifdef __cplusplus |
27 extern "C" { | 31 extern "C" { |
28 #endif | 32 #endif // __cplusplus |
29 | 33 |
30 ////////////////////////////////////////////////////////////////////// | 34 // Create a new PDF document. |
31 // | 35 // |
32 // Document functions | 36 // Returns a handle to a new document, NULL on failure. |
33 // | |
34 ////////////////////////////////////////////////////////////////////// | |
35 | |
36 // Function: FPDF_CreateNewDocument | |
37 // Create a new PDF document. | |
38 // Parameters: | |
39 // None. | |
40 // Return value: | |
41 // A handle to a document. If failed, NULL is returned. | |
42 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument(); | 37 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument(); |
43 | 38 |
44 ////////////////////////////////////////////////////////////////////// | 39 // Create a new PDF page. |
45 // | 40 // |
46 // Page functions | 41 // document - handle to document. |
42 // page_index - the index of the page to create. | |
43 // width - the page width. | |
44 // height - the page height. | |
47 // | 45 // |
48 ////////////////////////////////////////////////////////////////////// | 46 // Returns the handle to the new page. |
49 | 47 // |
50 // Function: FPDFPage_New | 48 // The page should be deleted with |FPDFPage_Delete| when finished. |
51 // Construct an empty page. | |
52 // Parameters: | |
53 // document - Handle to document. Returned by FPDF_LoadDocument | |
54 // and FPDF_CreateNewDocument. | |
55 // page_index - The index of a page. | |
56 // width - The page width. | |
57 // height - The page height. | |
58 // Return value: | |
59 // The handle to the page. | |
60 // Comments: | |
61 // Loaded page can be deleted by FPDFPage_Delete. | |
62 DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, | 49 DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, |
63 int page_index, | 50 int page_index, |
64 double width, | 51 double width, |
65 double height); | 52 double height); |
66 | 53 |
67 // Function: FPDFPage_Delete | 54 // Delete the page at |page_index|. |
68 // Delete a PDF page. | 55 // |
69 // Parameters: | 56 // document - handle to document. |
70 // document - Handle to document. Returned by FPDF_LoadDocument | 57 // page_index - the index of the page to delete. |
71 // and FPDF_CreateNewDocument. | |
72 // page_index - The index of a page. | |
73 // Return value: | |
74 // None. | |
75 DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index); | 58 DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index); |
76 | 59 |
77 // Function: FPDFPage_GetRotation | 60 // Get the rotation of |page|. |
78 // Get the page rotation. One of following values will be returned: | 61 // |
79 // 0(0), 1(90), 2(180), 3(270). | 62 // page - handle to a page |
80 // Parameters: | 63 // |
81 // page - Handle to a page. Returned by FPDFPage_New or | 64 // Returns one of the following indicating the page rotation: |
82 // FPDF_LoadPage. | 65 // 0 - No rotation. |
83 // Return value: | 66 // 1 - Rotated 90 degrees clockwise. |
84 // The PDF page rotation. | 67 // 2 - Rotated 180 degrees clockwise. |
85 // Comment: | 68 // 3 - Rotated 270 degrees clockwise. |
86 // The PDF page rotation is rotated clockwise. | |
87 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page); | 69 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page); |
88 | 70 |
89 // Function: FPDFPage_SetRotation | 71 // Set rotation for |page|. |
90 // Set page rotation. One of following values will be set: 0(0), 1(90), | |
91 // 2(180), 3(270). | |
92 // Parameters: | |
93 // page - Handle to a page. Returned by FPDFPage_New or | |
94 // FPDF_LoadPage. | |
95 // rotate - The value of the PDF page rotation. | |
96 // Return value: | |
97 // None. | |
98 // Comment: | |
99 // The PDF page rotation is rotated clockwise. | |
100 // | 72 // |
73 // page - handle to a page. | |
74 // rotate - the rotation value, one of: | |
75 // 0 - No rotation. | |
76 // 1 - Rotated 90 degrees clockwise. | |
77 // 2 - Rotated 180 degrees clockwise. | |
78 // 3 - Rotated 270 degrees clockwise. | |
101 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate); | 79 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate); |
102 | 80 |
103 // Function: FPDFPage_InsertObject | 81 // Insert |page_obj| into |page|. |
104 // Insert an object to the page. The page object is automatically | 82 // |
105 // freed. | 83 // page - handle to a page |
106 // Parameters: | 84 // page_obj - handle to a page object. The |page_obj| will be automatically |
107 // page - Handle to a page. Returned by FPDFPage_New or | 85 // freed. |
108 // FPDF_LoadPage. | |
109 // page_obj - Handle to a page object. Returned by | |
110 // FPDFPageObj_NewTextObj,FPDFPageObj_NewTextObjEx and | |
111 // FPDFPageObj_NewPathObj. | |
112 // Return value: | |
113 // None. | |
114 DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, | 86 DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, |
115 FPDF_PAGEOBJECT page_obj); | 87 FPDF_PAGEOBJECT page_obj); |
116 | 88 |
117 // Function: FPDFPage_CountObject | 89 // Get number of page objects inside |page|. |
118 // Get number of page objects inside the page. | 90 // |
119 // Parameters: | 91 // page - handle to a page. |
120 // page - Handle to a page. Returned by FPDFPage_New or | 92 // |
121 // FPDF_LoadPage. | 93 // Returns the number of objects in |page|. |
122 // Return value: | |
123 // The number of the page object. | |
124 DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page); | 94 DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page); |
125 | 95 |
126 // Function: FPDFPage_GetObject | 96 // Get object in |page| at |index|. |
127 // Get page object by index. | 97 // |
128 // Parameters: | 98 // page - handle to a page. |
129 // page - Handle to a page. Returned by FPDFPage_New or | 99 // index - the index of a page object. |
130 // FPDF_LoadPage. | 100 // |
131 // index - The index of a page object. | 101 // Returns the handle to the page object, NULL on failed. |
132 // Return value: | |
133 // The handle of the page object. Null for failed. | |
134 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, int index); | 102 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, int index); |
135 | 103 |
136 // Function: FPDFPage_HasTransparency | 104 // Checks if |page| contains transparency. |
137 // Check that whether the content of specified PDF page contains | 105 // |
138 // transparency. | 106 // page - handle to a page. |
139 // Parameters: | 107 // |
140 // page - Handle to a page. Returned by FPDFPage_New or | 108 // Returns TRUE if |page| contains transparency. |
141 // FPDF_LoadPage. | |
142 // Return value: | |
143 // TRUE means that the PDF page does contains transparency. | |
144 // Otherwise, returns FALSE. | |
145 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page); | 109 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page); |
146 | 110 |
147 // Function: FPDFPage_GenerateContent | 111 // Generate the content of |page|. |
148 // Generate PDF Page content. | 112 // |
149 // Parameters: | 113 // page - handle to a page. |
150 // page - Handle to a page. Returned by FPDFPage_New or | 114 // |
151 // FPDF_LoadPage. | 115 // Returns TRUE on success. |
152 // Return value: | 116 // |
153 // True if successful, false otherwise. | 117 // Before you save the page to a file, or reload the page, you must call |
154 // Comment: | 118 // |FPDFPage_GenerateContent| or any changes to |page| will be lost. |
155 // Before you save the page to a file, or reload the page, you must | |
156 // call the FPDFPage_GenerateContent function. | |
157 // Or the changed information will be lost. | |
158 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page); | 119 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page); |
159 | 120 |
160 ////////////////////////////////////////////////////////////////////// | 121 // Checks if |pageObject| contains transparency. |
161 // | 122 // |
162 // Page Object functions | 123 // pageObject - handle to a page object. |
163 // | 124 // |
164 ////////////////////////////////////////////////////////////////////// | 125 // Returns TRUE if |pageObject| contains transparency. |
165 | |
166 // Function: FPDFPageObj_HasTransparency | |
167 // Check that whether the specified PDF page object contains | |
168 // transparency. | |
169 // Parameters: | |
170 // pageObject - Handle to a page object. | |
171 // Return value: | |
172 // TRUE means that the PDF page object does contains transparency. | |
173 // Otherwise, returns FALSE. | |
174 DLLEXPORT FPDF_BOOL STDCALL | 126 DLLEXPORT FPDF_BOOL STDCALL |
175 FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject); | 127 FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject); |
176 | 128 |
177 // Function: FPDFPageObj_Transform | 129 // Transform |pageObject| by the given matrix. |
178 // Transform (scale, rotate, shear, move) page object. | 130 // |
179 // Parameters: | 131 // page_object - handle to a page object. |
180 // page_object - Handle to a page object. Returned by | 132 // a - matrix value. |
181 // FPDFPageObj_NewImageObj. | 133 // b - matrix value. |
182 // a - The coefficient "a" of the matrix. | 134 // c - matrix value. |
183 // b - The coefficient "b" of the matrix. | 135 // d - matrix value. |
184 // c - The coefficient "c" of the matrix. | 136 // e - matrix value. |
185 // d - The coefficient "d" of the matrix. | 137 // f - matrix value. |
186 // e - The coefficient "e" of the matrix. | 138 // |
187 // f - The coefficient "f" of the matrix. | 139 // The matrix is composed as: |
188 // Return value: | 140 // |a c e| |
189 // None. | 141 // |b d f| |
142 // and can be used to scale, rotate, shear and translate the |page_object|. | |
190 DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, | 143 DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, |
191 double a, | 144 double a, |
192 double b, | 145 double b, |
193 double c, | 146 double c, |
194 double d, | 147 double d, |
195 double e, | 148 double e, |
196 double f); | 149 double f); |
197 | 150 |
198 // Function: FPDFPage_TransformAnnots | 151 // Transform all annotations in |page|. |
199 // Transform (scale, rotate, shear, move) all annots in a page. | 152 // |
200 // Parameters: | 153 // page - handle to a page. |
201 // page - Handle to a page. | 154 // a - matrix value. |
202 // a - The coefficient "a" of the matrix. | 155 // b - matrix value. |
203 // b - The coefficient "b" of the matrix. | 156 // c - matrix value. |
204 // c - The coefficient "c" of the matrix. | 157 // d - matrix value. |
205 // d - The coefficient "d" of the matrix. | 158 // e - matrix value. |
206 // e - The coefficient "e" of the matrix. | 159 // f - matrix value. |
207 // f - The coefficient "f" of the matrix. | 160 // |
208 // Return value: | 161 // The matrix is composed as: |
209 // None. | 162 // |a c e| |
163 // |b d f| | |
164 // and can be used to scale, rotate, shear and translate the |page| annotations. | |
210 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, | 165 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, |
211 double a, | 166 double a, |
212 double b, | 167 double b, |
213 double c, | 168 double c, |
214 double d, | 169 double d, |
215 double e, | 170 double e, |
216 double f); | 171 double f); |
217 | 172 |
218 // The page object constants. | 173 // Create a new image object. |
219 #define FPDF_PAGEOBJ_TEXT 1 | |
220 #define FPDF_PAGEOBJ_PATH 2 | |
221 #define FPDF_PAGEOBJ_IMAGE 3 | |
222 #define FPDF_PAGEOBJ_SHADING 4 | |
223 #define FPDF_PAGEOBJ_FORM 5 | |
224 | |
225 ////////////////////////////////////////////////////////////////////// | |
226 // | 174 // |
227 // Image functions | 175 // document - handle to a document. |
228 // | 176 // |
229 ////////////////////////////////////////////////////////////////////// | 177 // Returns a handle to a new image object. |
230 | |
231 // Function: FPDFPageObj_NewImgeObj | |
232 // Create a new Image Object. | |
233 // Parameters: | |
234 // document - Handle to document. Returned by | |
235 // FPDF_LoadDocument or FPDF_CreateNewDocument function. | |
236 // Return Value: | |
237 // Handle of image object. | |
238 DLLEXPORT FPDF_PAGEOBJECT STDCALL | 178 DLLEXPORT FPDF_PAGEOBJECT STDCALL |
239 FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document); | 179 FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document); |
240 | 180 |
241 // Function: FPDFImageObj_LoadJpegFile | 181 // Load an image from a JPEG image file and then set it into |image_object|. |
242 // Load Image from a JPEG image file and then set it to an image | 182 // |
243 // object. | 183 // pages - pointer to the start of all loaded pages, may be NULL. |
244 // Parameters: | 184 // nCount - number of |pages|, may be 0. |
245 // pages - Pointers to the start of all loaded pages, could | 185 // image_object - handle to an image object. |
246 // be NULL. | 186 // fileAccess - file access handler which specifies the JPEG image file. |
247 // nCount - Number of pages, could be 0. | 187 // |
248 // image_object - Handle of image object returned by | 188 // Returns TRUE on success. |
Tom Sepez
2016/03/24 18:32:15
nit: false otherwise just to be pedantic. Several
dsinclair
2016/03/25 02:06:09
Acknowledged.
| |
249 // FPDFPageObj_NewImgeObj. | 189 // |
250 // fileAccess - The custom file access handler, which specifies | 190 // The image object might already have an associated image, which is shared and |
251 // the JPEG image file. | 191 // cached by the loaded pages. In that case, we need to clear the cached image |
252 // Return Value: | 192 // for all the loaded pages. Pass |pages| and page count (|nCount|) to this API |
253 // TRUE if successful, FALSE otherwise. | 193 // to clear the image cache. If the image is not previously shared, NULL is a |
254 // Note: | 194 // valid |pages| value. |
255 // The image object might already has an associated image, which is | |
256 // shared and cached by the loaded pages, In this case, we need to | |
257 // clear the cache of image for all the loaded pages. | |
258 // Pass pages and count to this API to clear the image cache. | |
259 DLLEXPORT FPDF_BOOL STDCALL | 195 DLLEXPORT FPDF_BOOL STDCALL |
260 FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, | 196 FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, |
261 int nCount, | 197 int nCount, |
262 FPDF_PAGEOBJECT image_object, | 198 FPDF_PAGEOBJECT image_object, |
263 FPDF_FILEACCESS* fileAccess); | 199 FPDF_FILEACCESS* fileAccess); |
264 | 200 |
265 // Function: FPDFImageObj_SetMatrix | 201 // Set the transform matrix of |image_object|. |
266 // Set the matrix of an image object. | 202 // |
267 // Parameters: | 203 // image_object - handle to an image object. |
268 // image_object - Handle of image object returned by | 204 // a - matrix value. |
269 // FPDFPageObj_NewImgeObj. | 205 // b - matrix value. |
270 // a - The coefficient "a" of the matrix. | 206 // c - matrix value. |
271 // b - The coefficient "b" of the matrix. | 207 // d - matrix value. |
272 // c - The coefficient "c" of the matrix. | 208 // e - matrix value. |
273 // d - The coefficient "d" of the matrix. | 209 // f - matrix value. |
274 // e - The coefficient "e" of the matrix. | 210 // |
275 // f - The coefficient "f" of the matrix. | 211 // The matrix is composed as: |
276 // Return value: | 212 // |a c e| |
277 // TRUE if successful, FALSE otherwise. | 213 // |b d f| |
214 // and can be used to scale, rotate, shear and translate the |page| annotations. | |
215 // | |
216 // Returns TRUE on success. | |
278 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object, | 217 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object, |
279 double a, | 218 double a, |
280 double b, | 219 double b, |
281 double c, | 220 double c, |
282 double d, | 221 double d, |
283 double e, | 222 double e, |
284 double f); | 223 double f); |
285 | 224 |
286 // Function: FPDFImageObj_SetBitmap | 225 // Set |bitmap| to |image_object|. |
287 // Set the bitmap to an image object. | 226 // |
288 // Parameters: | 227 // pages - pointer to the start of all loaded pages, may be NULL. |
289 // pages - Pointer's to the start of all loaded pages. | 228 // nCount - number of |pages|, may be 0. |
290 // nCount - Number of pages. | 229 // image_object - handle to an image object. |
291 // image_object - Handle of image object returned by | 230 // bitmap - handle of the bitmap. |
292 // FPDFPageObj_NewImgeObj. | 231 // |
293 // bitmap - The handle of the bitmap which you want to set | 232 // Returns TRUE on success. |
294 // it to the image object. | 233 // |
295 // Return value: | 234 // TODO(dsinclair): Does this have the same cache clearing requirements as |
Tom Sepez
2016/03/24 18:32:15
nit: let's not commit this todo either.
dsinclair
2016/03/25 02:06:09
Done.
| |
296 // TRUE if successful, FALSE otherwise. | 235 // FPDFImageObj_LoadJpegFile. |
297 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages, | 236 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages, |
298 int nCount, | 237 int nCount, |
299 FPDF_PAGEOBJECT image_object, | 238 FPDF_PAGEOBJECT image_object, |
300 FPDF_BITMAP bitmap); | 239 FPDF_BITMAP bitmap); |
301 | 240 |
302 #ifdef __cplusplus | 241 #ifdef __cplusplus |
303 } | 242 } // extern "C" |
304 #endif | 243 #endif // __cplusplus |
305 | 244 |
306 #endif // PUBLIC_FPDF_EDIT_H_ | 245 #endif // PUBLIC_FPDF_EDIT_H_ |
OLD | NEW |