| 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 // The page object constants. |
| 23 #define FPDF_PAGEOBJ_TEXT 1 |
| 24 #define FPDF_PAGEOBJ_PATH 2 |
| 25 #define FPDF_PAGEOBJ_IMAGE 3 |
| 26 #define FPDF_PAGEOBJ_SHADING 4 |
| 27 #define FPDF_PAGEOBJ_FORM 5 |
| 28 |
| 26 #ifdef __cplusplus | 29 #ifdef __cplusplus |
| 27 extern "C" { | 30 extern "C" { |
| 28 #endif | 31 #endif // __cplusplus |
| 29 | 32 |
| 30 ////////////////////////////////////////////////////////////////////// | 33 // Create a new PDF document. |
| 31 // | 34 // |
| 32 // Document functions | 35 // Returns a handle to a new document, or 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(); | 36 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_CreateNewDocument(); |
| 43 | 37 |
| 44 ////////////////////////////////////////////////////////////////////// | 38 // Create a new PDF page. |
| 45 // | 39 // |
| 46 // Page functions | 40 // document - handle to document. |
| 41 // page_index - the index of the page to create. |
| 42 // width - the page width. |
| 43 // height - the page height. |
| 47 // | 44 // |
| 48 ////////////////////////////////////////////////////////////////////// | 45 // Returns the handle to the new page. |
| 49 | 46 // |
| 50 // Function: FPDFPage_New | 47 // 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, | 48 DLLEXPORT FPDF_PAGE STDCALL FPDFPage_New(FPDF_DOCUMENT document, |
| 63 int page_index, | 49 int page_index, |
| 64 double width, | 50 double width, |
| 65 double height); | 51 double height); |
| 66 | 52 |
| 67 // Function: FPDFPage_Delete | 53 // Delete the page at |page_index|. |
| 68 // Delete a PDF page. | 54 // |
| 69 // Parameters: | 55 // document - handle to document. |
| 70 // document - Handle to document. Returned by FPDF_LoadDocument | 56 // 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); | 57 DLLEXPORT void STDCALL FPDFPage_Delete(FPDF_DOCUMENT document, int page_index); |
| 76 | 58 |
| 77 // Function: FPDFPage_GetRotation | 59 // Get the rotation of |page|. |
| 78 // Get the page rotation. One of following values will be returned: | 60 // |
| 79 // 0(0), 1(90), 2(180), 3(270). | 61 // page - handle to a page |
| 80 // Parameters: | 62 // |
| 81 // page - Handle to a page. Returned by FPDFPage_New or | 63 // Returns one of the following indicating the page rotation: |
| 82 // FPDF_LoadPage. | 64 // 0 - No rotation. |
| 83 // Return value: | 65 // 1 - Rotated 90 degrees clockwise. |
| 84 // The PDF page rotation. | 66 // 2 - Rotated 180 degrees clockwise. |
| 85 // Comment: | 67 // 3 - Rotated 270 degrees clockwise. |
| 86 // The PDF page rotation is rotated clockwise. | |
| 87 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page); | 68 DLLEXPORT int STDCALL FPDFPage_GetRotation(FPDF_PAGE page); |
| 88 | 69 |
| 89 // Function: FPDFPage_SetRotation | 70 // 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 // | 71 // |
| 72 // page - handle to a page. |
| 73 // rotate - the rotation value, one of: |
| 74 // 0 - No rotation. |
| 75 // 1 - Rotated 90 degrees clockwise. |
| 76 // 2 - Rotated 180 degrees clockwise. |
| 77 // 3 - Rotated 270 degrees clockwise. |
| 101 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate); | 78 DLLEXPORT void STDCALL FPDFPage_SetRotation(FPDF_PAGE page, int rotate); |
| 102 | 79 |
| 103 // Function: FPDFPage_InsertObject | 80 // Insert |page_obj| into |page|. |
| 104 // Insert an object to the page. The page object is automatically | 81 // |
| 105 // freed. | 82 // page - handle to a page |
| 106 // Parameters: | 83 // page_obj - handle to a page object. The |page_obj| will be automatically |
| 107 // page - Handle to a page. Returned by FPDFPage_New or | 84 // 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, | 85 DLLEXPORT void STDCALL FPDFPage_InsertObject(FPDF_PAGE page, |
| 115 FPDF_PAGEOBJECT page_obj); | 86 FPDF_PAGEOBJECT page_obj); |
| 116 | 87 |
| 117 // Function: FPDFPage_CountObject | 88 // Get number of page objects inside |page|. |
| 118 // Get number of page objects inside the page. | 89 // |
| 119 // Parameters: | 90 // page - handle to a page. |
| 120 // page - Handle to a page. Returned by FPDFPage_New or | 91 // |
| 121 // FPDF_LoadPage. | 92 // 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); | 93 DLLEXPORT int STDCALL FPDFPage_CountObject(FPDF_PAGE page); |
| 125 | 94 |
| 126 // Function: FPDFPage_GetObject | 95 // Get object in |page| at |index|. |
| 127 // Get page object by index. | 96 // |
| 128 // Parameters: | 97 // page - handle to a page. |
| 129 // page - Handle to a page. Returned by FPDFPage_New or | 98 // index - the index of a page object. |
| 130 // FPDF_LoadPage. | 99 // |
| 131 // index - The index of a page object. | 100 // Returns the handle to the page object, or 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); | 101 DLLEXPORT FPDF_PAGEOBJECT STDCALL FPDFPage_GetObject(FPDF_PAGE page, int index); |
| 135 | 102 |
| 136 // Function: FPDFPage_HasTransparency | 103 // Checks if |page| contains transparency. |
| 137 // Check that whether the content of specified PDF page contains | 104 // |
| 138 // transparency. | 105 // page - handle to a page. |
| 139 // Parameters: | 106 // |
| 140 // page - Handle to a page. Returned by FPDFPage_New or | 107 // 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); | 108 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_HasTransparency(FPDF_PAGE page); |
| 146 | 109 |
| 147 // Function: FPDFPage_GenerateContent | 110 // Generate the content of |page|. |
| 148 // Generate PDF Page content. | 111 // |
| 149 // Parameters: | 112 // page - handle to a page. |
| 150 // page - Handle to a page. Returned by FPDFPage_New or | 113 // |
| 151 // FPDF_LoadPage. | 114 // Returns TRUE on success. |
| 152 // Return value: | 115 // |
| 153 // True if successful, false otherwise. | 116 // Before you save the page to a file, or reload the page, you must call |
| 154 // Comment: | 117 // |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); | 118 DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GenerateContent(FPDF_PAGE page); |
| 159 | 119 |
| 160 ////////////////////////////////////////////////////////////////////// | 120 // Checks if |pageObject| contains transparency. |
| 161 // | 121 // |
| 162 // Page Object functions | 122 // pageObject - handle to a page object. |
| 163 // | 123 // |
| 164 ////////////////////////////////////////////////////////////////////// | 124 // 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 | 125 DLLEXPORT FPDF_BOOL STDCALL |
| 175 FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject); | 126 FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT pageObject); |
| 176 | 127 |
| 177 // Function: FPDFPageObj_Transform | 128 // Transform |pageObject| by the given matrix. |
| 178 // Transform (scale, rotate, shear, move) page object. | 129 // |
| 179 // Parameters: | 130 // page_object - handle to a page object. |
| 180 // page_object - Handle to a page object. Returned by | 131 // a - matrix value. |
| 181 // FPDFPageObj_NewImageObj. | 132 // b - matrix value. |
| 182 // a - The coefficient "a" of the matrix. | 133 // c - matrix value. |
| 183 // b - The coefficient "b" of the matrix. | 134 // d - matrix value. |
| 184 // c - The coefficient "c" of the matrix. | 135 // e - matrix value. |
| 185 // d - The coefficient "d" of the matrix. | 136 // f - matrix value. |
| 186 // e - The coefficient "e" of the matrix. | 137 // |
| 187 // f - The coefficient "f" of the matrix. | 138 // The matrix is composed as: |
| 188 // Return value: | 139 // |a c e| |
| 189 // None. | 140 // |b d f| |
| 141 // and can be used to scale, rotate, shear and translate the |page_object|. |
| 190 DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, | 142 DLLEXPORT void STDCALL FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, |
| 191 double a, | 143 double a, |
| 192 double b, | 144 double b, |
| 193 double c, | 145 double c, |
| 194 double d, | 146 double d, |
| 195 double e, | 147 double e, |
| 196 double f); | 148 double f); |
| 197 | 149 |
| 198 // Function: FPDFPage_TransformAnnots | 150 // Transform all annotations in |page|. |
| 199 // Transform (scale, rotate, shear, move) all annots in a page. | 151 // |
| 200 // Parameters: | 152 // page - handle to a page. |
| 201 // page - Handle to a page. | 153 // a - matrix value. |
| 202 // a - The coefficient "a" of the matrix. | 154 // b - matrix value. |
| 203 // b - The coefficient "b" of the matrix. | 155 // c - matrix value. |
| 204 // c - The coefficient "c" of the matrix. | 156 // d - matrix value. |
| 205 // d - The coefficient "d" of the matrix. | 157 // e - matrix value. |
| 206 // e - The coefficient "e" of the matrix. | 158 // f - matrix value. |
| 207 // f - The coefficient "f" of the matrix. | 159 // |
| 208 // Return value: | 160 // The matrix is composed as: |
| 209 // None. | 161 // |a c e| |
| 162 // |b d f| |
| 163 // and can be used to scale, rotate, shear and translate the |page| annotations. |
| 210 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, | 164 DLLEXPORT void STDCALL FPDFPage_TransformAnnots(FPDF_PAGE page, |
| 211 double a, | 165 double a, |
| 212 double b, | 166 double b, |
| 213 double c, | 167 double c, |
| 214 double d, | 168 double d, |
| 215 double e, | 169 double e, |
| 216 double f); | 170 double f); |
| 217 | 171 |
| 218 // The page object constants. | 172 // 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 // | 173 // |
| 227 // Image functions | 174 // document - handle to a document. |
| 228 // | 175 // |
| 229 ////////////////////////////////////////////////////////////////////// | 176 // 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 | 177 DLLEXPORT FPDF_PAGEOBJECT STDCALL |
| 239 FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document); | 178 FPDFPageObj_NewImgeObj(FPDF_DOCUMENT document); |
| 240 | 179 |
| 241 // Function: FPDFImageObj_LoadJpegFile | 180 // 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 | 181 // |
| 243 // object. | 182 // pages - pointer to the start of all loaded pages, may be NULL. |
| 244 // Parameters: | 183 // nCount - number of |pages|, may be 0. |
| 245 // pages - Pointers to the start of all loaded pages, could | 184 // image_object - handle to an image object. |
| 246 // be NULL. | 185 // fileAccess - file access handler which specifies the JPEG image file. |
| 247 // nCount - Number of pages, could be 0. | 186 // |
| 248 // image_object - Handle of image object returned by | 187 // Returns TRUE on success. |
| 249 // FPDFPageObj_NewImgeObj. | 188 // |
| 250 // fileAccess - The custom file access handler, which specifies | 189 // The image object might already have an associated image, which is shared and |
| 251 // the JPEG image file. | 190 // cached by the loaded pages. In that case, we need to clear the cached image |
| 252 // Return Value: | 191 // for all the loaded pages. Pass |pages| and page count (|nCount|) to this API |
| 253 // TRUE if successful, FALSE otherwise. | 192 // to clear the image cache. If the image is not previously shared, or NULL is a |
| 254 // Note: | 193 // 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 | 194 DLLEXPORT FPDF_BOOL STDCALL |
| 260 FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, | 195 FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, |
| 261 int nCount, | 196 int nCount, |
| 262 FPDF_PAGEOBJECT image_object, | 197 FPDF_PAGEOBJECT image_object, |
| 263 FPDF_FILEACCESS* fileAccess); | 198 FPDF_FILEACCESS* fileAccess); |
| 264 | 199 |
| 265 // Function: FPDFImageObj_SetMatrix | 200 // Set the transform matrix of |image_object|. |
| 266 // Set the matrix of an image object. | 201 // |
| 267 // Parameters: | 202 // image_object - handle to an image object. |
| 268 // image_object - Handle of image object returned by | 203 // a - matrix value. |
| 269 // FPDFPageObj_NewImgeObj. | 204 // b - matrix value. |
| 270 // a - The coefficient "a" of the matrix. | 205 // c - matrix value. |
| 271 // b - The coefficient "b" of the matrix. | 206 // d - matrix value. |
| 272 // c - The coefficient "c" of the matrix. | 207 // e - matrix value. |
| 273 // d - The coefficient "d" of the matrix. | 208 // f - matrix value. |
| 274 // e - The coefficient "e" of the matrix. | 209 // |
| 275 // f - The coefficient "f" of the matrix. | 210 // The matrix is composed as: |
| 276 // Return value: | 211 // |a c e| |
| 277 // TRUE if successful, FALSE otherwise. | 212 // |b d f| |
| 213 // and can be used to scale, rotate, shear and translate the |page| annotations. |
| 214 // |
| 215 // Returns TRUE on success. |
| 278 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object, | 216 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object, |
| 279 double a, | 217 double a, |
| 280 double b, | 218 double b, |
| 281 double c, | 219 double c, |
| 282 double d, | 220 double d, |
| 283 double e, | 221 double e, |
| 284 double f); | 222 double f); |
| 285 | 223 |
| 286 // Function: FPDFImageObj_SetBitmap | 224 // Set |bitmap| to |image_object|. |
| 287 // Set the bitmap to an image object. | 225 // |
| 288 // Parameters: | 226 // pages - pointer to the start of all loaded pages, may be NULL. |
| 289 // pages - Pointer's to the start of all loaded pages. | 227 // nCount - number of |pages|, may be 0. |
| 290 // nCount - Number of pages. | 228 // image_object - handle to an image object. |
| 291 // image_object - Handle of image object returned by | 229 // bitmap - handle of the bitmap. |
| 292 // FPDFPageObj_NewImgeObj. | 230 // |
| 293 // bitmap - The handle of the bitmap which you want to set | 231 // Returns TRUE on success. |
| 294 // it to the image object. | |
| 295 // Return value: | |
| 296 // TRUE if successful, FALSE otherwise. | |
| 297 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages, | 232 DLLEXPORT FPDF_BOOL STDCALL FPDFImageObj_SetBitmap(FPDF_PAGE* pages, |
| 298 int nCount, | 233 int nCount, |
| 299 FPDF_PAGEOBJECT image_object, | 234 FPDF_PAGEOBJECT image_object, |
| 300 FPDF_BITMAP bitmap); | 235 FPDF_BITMAP bitmap); |
| 301 | 236 |
| 302 #ifdef __cplusplus | 237 #ifdef __cplusplus |
| 303 } | 238 } // extern "C" |
| 304 #endif | 239 #endif // __cplusplus |
| 305 | 240 |
| 306 #endif // PUBLIC_FPDF_EDIT_H_ | 241 #endif // PUBLIC_FPDF_EDIT_H_ |
| OLD | NEW |