John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 7 | #ifndef PUBLIC_FPDF_EDIT_H_ |
| 8 | #define PUBLIC_FPDF_EDIT_H_ |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | |
Tom Sepez | bfa9a82 | 2015-06-09 13:24:12 -0700 | [diff] [blame] | 10 | #include <stdint.h> |
| 11 | |
Dan Sinclair | 85c8e7f | 2016-11-21 13:50:32 -0500 | [diff] [blame] | 12 | // NOLINTNEXTLINE(build/include) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 13 | #include "fpdfview.h" |
| 14 | |
dan sinclair | 61b2fc7 | 2016-03-23 19:21:44 -0400 | [diff] [blame] | 15 | #define FPDF_ARGB(a, r, g, b) \ |
| 16 | ((uint32_t)(((uint32_t)(b)&0xff) | (((uint32_t)(g)&0xff) << 8) | \ |
| 17 | (((uint32_t)(r)&0xff) << 16) | (((uint32_t)(a)&0xff) << 24))) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 18 | #define FPDF_GetBValue(argb) ((uint8_t)(argb)) |
| 19 | #define FPDF_GetGValue(argb) ((uint8_t)(((uint16_t)(argb)) >> 8)) |
| 20 | #define FPDF_GetRValue(argb) ((uint8_t)((argb) >> 16)) |
| 21 | #define FPDF_GetAValue(argb) ((uint8_t)((argb) >> 24)) |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 22 | |
Jane Liu | ca89829 | 2017-08-16 11:25:35 -0400 | [diff] [blame] | 23 | // Refer to PDF Reference version 1.7 table 4.12 for all color space families. |
| 24 | #define FPDF_COLORSPACE_UNKNOWN 0 |
| 25 | #define FPDF_COLORSPACE_DEVICEGRAY 1 |
| 26 | #define FPDF_COLORSPACE_DEVICERGB 2 |
| 27 | #define FPDF_COLORSPACE_DEVICECMYK 3 |
| 28 | #define FPDF_COLORSPACE_CALGRAY 4 |
| 29 | #define FPDF_COLORSPACE_CALRGB 5 |
| 30 | #define FPDF_COLORSPACE_LAB 6 |
| 31 | #define FPDF_COLORSPACE_ICCBASED 7 |
| 32 | #define FPDF_COLORSPACE_SEPARATION 8 |
| 33 | #define FPDF_COLORSPACE_DEVICEN 9 |
| 34 | #define FPDF_COLORSPACE_INDEXED 10 |
| 35 | #define FPDF_COLORSPACE_PATTERN 11 |
| 36 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 37 | // The page object constants. |
Miklos Vajna | 1423319 | 2017-04-03 16:02:39 +0200 | [diff] [blame] | 38 | #define FPDF_PAGEOBJ_UNKNOWN 0 |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 39 | #define FPDF_PAGEOBJ_TEXT 1 |
| 40 | #define FPDF_PAGEOBJ_PATH 2 |
| 41 | #define FPDF_PAGEOBJ_IMAGE 3 |
| 42 | #define FPDF_PAGEOBJ_SHADING 4 |
| 43 | #define FPDF_PAGEOBJ_FORM 5 |
| 44 | |
Miklos Vajna | 36eed87 | 2017-09-20 22:52:43 +0200 | [diff] [blame] | 45 | // The path segment constants. |
| 46 | #define FPDF_SEGMENT_UNKNOWN -1 |
| 47 | #define FPDF_SEGMENT_LINETO 0 |
| 48 | #define FPDF_SEGMENT_BEZIERTO 1 |
| 49 | #define FPDF_SEGMENT_MOVETO 2 |
| 50 | |
Nicolas Pena | 55e026b | 2017-02-07 14:59:23 -0500 | [diff] [blame] | 51 | #define FPDF_FILLMODE_ALTERNATE 1 |
| 52 | #define FPDF_FILLMODE_WINDING 2 |
| 53 | |
Nicolas Pena | d03ca42 | 2017-03-06 13:54:33 -0500 | [diff] [blame] | 54 | #define FPDF_FONT_TYPE1 1 |
| 55 | #define FPDF_FONT_TRUETYPE 2 |
| 56 | |
wileyrya | 5be0b29 | 2017-05-31 19:13:37 -0500 | [diff] [blame] | 57 | #define FPDF_LINECAP_BUTT 0 |
| 58 | #define FPDF_LINECAP_ROUND 1 |
| 59 | #define FPDF_LINECAP_PROJECTING_SQUARE 2 |
| 60 | |
| 61 | #define FPDF_LINEJOIN_MITER 0 |
| 62 | #define FPDF_LINEJOIN_ROUND 1 |
| 63 | #define FPDF_LINEJOIN_BEVEL 2 |
| 64 | |
rbpotter | e8468c4 | 2017-07-11 10:04:29 -0700 | [diff] [blame] | 65 | #define FPDF_PRINTMODE_EMF 0 |
| 66 | #define FPDF_PRINTMODE_TEXTONLY 1 |
| 67 | #define FPDF_PRINTMODE_POSTSCRIPT2 2 |
| 68 | #define FPDF_PRINTMODE_POSTSCRIPT3 3 |
| 69 | |
Jane Liu | ca89829 | 2017-08-16 11:25:35 -0400 | [diff] [blame] | 70 | typedef struct FPDF_IMAGEOBJ_METADATA { |
| 71 | // The image width in pixels. |
| 72 | unsigned int width; |
| 73 | // The image height in pixels. |
| 74 | unsigned int height; |
| 75 | // The image's horizontal pixel-per-inch. |
| 76 | float horizontal_dpi; |
| 77 | // The image's vertical pixel-per-inch. |
| 78 | float vertical_dpi; |
| 79 | // The number of bits used to represent each pixel. |
| 80 | unsigned int bits_per_pixel; |
| 81 | // The image's colorspace. See above for the list of FPDF_COLORSPACE_*. |
| 82 | int colorspace; |
Julian Lunger | ecd063e | 2017-12-27 10:18:50 -0500 | [diff] [blame] | 83 | // The image's marked content ID. Useful for pairing with associated alt-text. |
| 84 | // A value of -1 indicates no ID. |
| 85 | int marked_content_id; |
Jane Liu | ca89829 | 2017-08-16 11:25:35 -0400 | [diff] [blame] | 86 | } FPDF_IMAGEOBJ_METADATA; |
| 87 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 88 | #ifdef __cplusplus |
| 89 | extern "C" { |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 90 | #endif // __cplusplus |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 91 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 92 | // Create a new PDF document. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 93 | // |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 94 | // Returns a handle to a new document, or NULL on failure. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 95 | FPDF_EXPORT FPDF_DOCUMENT FPDF_CALLCONV FPDF_CreateNewDocument(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 96 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 97 | // Create a new PDF page. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 98 | // |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 99 | // document - handle to document. |
Lei Zhang | 3f3f513 | 2018-01-31 14:53:02 +0000 | [diff] [blame] | 100 | // page_index - suggested 0-based index of the page to create. If it is larger |
| 101 | // than document's current last index(L), the created page index |
| 102 | // is the next available index -- L+1. |
| 103 | // width - the page width in points. |
| 104 | // height - the page height in points. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 105 | // |
Lei Zhang | 3f3f513 | 2018-01-31 14:53:02 +0000 | [diff] [blame] | 106 | // Returns the handle to the new page or NULL on failure. |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 107 | // |
Lei Zhang | 3f3f513 | 2018-01-31 14:53:02 +0000 | [diff] [blame] | 108 | // The page should be closed with FPDF_ClosePage() when finished as |
weili | 9b777de | 2016-08-19 16:19:46 -0700 | [diff] [blame] | 109 | // with any other page in the document. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 110 | FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDFPage_New(FPDF_DOCUMENT document, |
| 111 | int page_index, |
| 112 | double width, |
| 113 | double height); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 114 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 115 | // Delete the page at |page_index|. |
| 116 | // |
| 117 | // document - handle to document. |
| 118 | // page_index - the index of the page to delete. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 119 | FPDF_EXPORT void FPDF_CALLCONV FPDFPage_Delete(FPDF_DOCUMENT document, |
| 120 | int page_index); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 121 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 122 | // Get the rotation of |page|. |
| 123 | // |
| 124 | // page - handle to a page |
| 125 | // |
| 126 | // Returns one of the following indicating the page rotation: |
| 127 | // 0 - No rotation. |
| 128 | // 1 - Rotated 90 degrees clockwise. |
| 129 | // 2 - Rotated 180 degrees clockwise. |
| 130 | // 3 - Rotated 270 degrees clockwise. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 131 | FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetRotation(FPDF_PAGE page); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 132 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 133 | // Set rotation for |page|. |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 134 | // |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 135 | // page - handle to a page. |
| 136 | // rotate - the rotation value, one of: |
| 137 | // 0 - No rotation. |
| 138 | // 1 - Rotated 90 degrees clockwise. |
| 139 | // 2 - Rotated 180 degrees clockwise. |
| 140 | // 3 - Rotated 270 degrees clockwise. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 141 | FPDF_EXPORT void FPDF_CALLCONV FPDFPage_SetRotation(FPDF_PAGE page, int rotate); |
Bo Xu | 394010d | 2014-06-12 13:41:50 -0700 | [diff] [blame] | 142 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 143 | // Insert |page_obj| into |page|. |
| 144 | // |
| 145 | // page - handle to a page |
| 146 | // page_obj - handle to a page object. The |page_obj| will be automatically |
| 147 | // freed. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 148 | FPDF_EXPORT void FPDF_CALLCONV FPDFPage_InsertObject(FPDF_PAGE page, |
| 149 | FPDF_PAGEOBJECT page_obj); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 150 | |
Henrique Nakashima | 35841fa | 2018-03-15 15:25:16 +0000 | [diff] [blame] | 151 | // Experimental API. |
| 152 | // Remove |page_obj| from |page|. |
| 153 | // |
| 154 | // page - handle to a page |
| 155 | // page_obj - handle to a page object to be removed. |
| 156 | // |
| 157 | // Returns TRUE on success. |
| 158 | // |
| 159 | // Ownership is transferred to the caller. Call FPDFPageObj_Destroy() to free |
| 160 | // it. |
| 161 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 162 | FPDFPage_RemoveObject(FPDF_PAGE page, FPDF_PAGEOBJECT page_obj); |
| 163 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 164 | // Get number of page objects inside |page|. |
| 165 | // |
| 166 | // page - handle to a page. |
| 167 | // |
| 168 | // Returns the number of objects in |page|. |
Miklos Vajna | 9262761 | 2017-09-25 12:59:29 +0200 | [diff] [blame] | 169 | // |
| 170 | // DEPRECATED. Please use FPDFPage_CountObjects. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 171 | FPDF_EXPORT int FPDF_CALLCONV FPDFPage_CountObject(FPDF_PAGE page); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 172 | |
Miklos Vajna | 9262761 | 2017-09-25 12:59:29 +0200 | [diff] [blame] | 173 | // Get number of page objects inside |page|. |
| 174 | // |
| 175 | // page - handle to a page. |
| 176 | // |
| 177 | // Returns the number of objects in |page|. |
| 178 | FPDF_EXPORT int FPDF_CALLCONV FPDFPage_CountObjects(FPDF_PAGE page); |
| 179 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 180 | // Get object in |page| at |index|. |
| 181 | // |
| 182 | // page - handle to a page. |
| 183 | // index - the index of a page object. |
| 184 | // |
| 185 | // Returns the handle to the page object, or NULL on failed. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 186 | FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPage_GetObject(FPDF_PAGE page, |
| 187 | int index); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 188 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 189 | // Checks if |page| contains transparency. |
| 190 | // |
| 191 | // page - handle to a page. |
| 192 | // |
| 193 | // Returns TRUE if |page| contains transparency. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 194 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_HasTransparency(FPDF_PAGE page); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 195 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 196 | // Generate the content of |page|. |
| 197 | // |
| 198 | // page - handle to a page. |
| 199 | // |
| 200 | // Returns TRUE on success. |
| 201 | // |
| 202 | // Before you save the page to a file, or reload the page, you must call |
| 203 | // |FPDFPage_GenerateContent| or any changes to |page| will be lost. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 204 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_GenerateContent(FPDF_PAGE page); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 205 | |
Jane Liu | 2e5f0ae | 2017-08-08 15:23:27 -0400 | [diff] [blame] | 206 | // Destroy |page_obj| by releasing its resources. |page_obj| must have been |
| 207 | // created by FPDFPageObj_CreateNew{Path|Rect}() or |
| 208 | // FPDFPageObj_New{Text|Image}Obj(). This function must be called on |
| 209 | // newly-created objects if they are not added to a page through |
| 210 | // FPDFPage_InsertObject() or to an annotation through FPDFAnnot_AppendObject(). |
| 211 | // |
| 212 | // page_obj - handle to a page object. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 213 | FPDF_EXPORT void FPDF_CALLCONV FPDFPageObj_Destroy(FPDF_PAGEOBJECT page_obj); |
Jane Liu | 2e5f0ae | 2017-08-08 15:23:27 -0400 | [diff] [blame] | 214 | |
Nicolas Pena | 603a31d | 2017-06-14 11:41:18 -0400 | [diff] [blame] | 215 | // Checks if |page_object| contains transparency. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 216 | // |
Nicolas Pena | 603a31d | 2017-06-14 11:41:18 -0400 | [diff] [blame] | 217 | // page_object - handle to a page object. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 218 | // |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 219 | // Returns TRUE if |pageObject| contains transparency. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 220 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
Nicolas Pena | 603a31d | 2017-06-14 11:41:18 -0400 | [diff] [blame] | 221 | FPDFPageObj_HasTransparency(FPDF_PAGEOBJECT page_object); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 222 | |
Nicolas Pena | 603a31d | 2017-06-14 11:41:18 -0400 | [diff] [blame] | 223 | // Get type of |page_object|. |
Miklos Vajna | 1423319 | 2017-04-03 16:02:39 +0200 | [diff] [blame] | 224 | // |
Nicolas Pena | 603a31d | 2017-06-14 11:41:18 -0400 | [diff] [blame] | 225 | // page_object - handle to a page object. |
Miklos Vajna | 1423319 | 2017-04-03 16:02:39 +0200 | [diff] [blame] | 226 | // |
| 227 | // Returns one of the FPDF_PAGEOBJ_* values on success, FPDF_PAGEOBJ_UNKNOWN on |
| 228 | // error. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 229 | FPDF_EXPORT int FPDF_CALLCONV FPDFPageObj_GetType(FPDF_PAGEOBJECT page_object); |
Miklos Vajna | 1423319 | 2017-04-03 16:02:39 +0200 | [diff] [blame] | 230 | |
Nicolas Pena | 603a31d | 2017-06-14 11:41:18 -0400 | [diff] [blame] | 231 | // Transform |page_object| by the given matrix. |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 232 | // |
| 233 | // page_object - handle to a page object. |
| 234 | // a - matrix value. |
| 235 | // b - matrix value. |
| 236 | // c - matrix value. |
| 237 | // d - matrix value. |
| 238 | // e - matrix value. |
| 239 | // f - matrix value. |
| 240 | // |
| 241 | // The matrix is composed as: |
| 242 | // |a c e| |
| 243 | // |b d f| |
| 244 | // and can be used to scale, rotate, shear and translate the |page_object|. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 245 | FPDF_EXPORT void FPDF_CALLCONV |
| 246 | FPDFPageObj_Transform(FPDF_PAGEOBJECT page_object, |
| 247 | double a, |
| 248 | double b, |
| 249 | double c, |
| 250 | double d, |
| 251 | double e, |
| 252 | double f); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 253 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 254 | // Transform all annotations in |page|. |
| 255 | // |
| 256 | // page - handle to a page. |
| 257 | // a - matrix value. |
| 258 | // b - matrix value. |
| 259 | // c - matrix value. |
| 260 | // d - matrix value. |
| 261 | // e - matrix value. |
| 262 | // f - matrix value. |
| 263 | // |
| 264 | // The matrix is composed as: |
| 265 | // |a c e| |
| 266 | // |b d f| |
| 267 | // and can be used to scale, rotate, shear and translate the |page| annotations. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 268 | FPDF_EXPORT void FPDF_CALLCONV FPDFPage_TransformAnnots(FPDF_PAGE page, |
| 269 | double a, |
| 270 | double b, |
| 271 | double c, |
| 272 | double d, |
| 273 | double e, |
| 274 | double f); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 275 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 276 | // Create a new image object. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 277 | // |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 278 | // document - handle to a document. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 279 | // |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 280 | // Returns a handle to a new image object. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 281 | FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV |
Lei Zhang | cbd8957 | 2017-03-15 17:35:47 -0700 | [diff] [blame] | 282 | FPDFPageObj_NewImageObj(FPDF_DOCUMENT document); |
| 283 | |
Henrique Nakashima | c90adc5 | 2018-03-27 16:26:44 +0000 | [diff] [blame] | 284 | // Get number of content marks in |page_object|. |
| 285 | // |
| 286 | // page_object - handle to a page object. |
| 287 | // |
| 288 | // Returns the number of content marks in |page_object|, or -1 in case of |
| 289 | // failure. |
| 290 | FPDF_EXPORT int FPDF_CALLCONV |
| 291 | FPDFPageObj_CountMarks(FPDF_PAGEOBJECT page_object); |
| 292 | |
| 293 | // Get content mark in |page_object| at |index|. |
| 294 | // |
| 295 | // page_object - handle to a page object. |
| 296 | // index - the index of a page object. |
| 297 | // |
| 298 | // Returns the handle to the content mark, or NULL on failure. The handle is |
| 299 | // still owned by the library, and it should not be freed directly. It becomes |
| 300 | // invalid if the page object is destroyed, either directly or indirectly by |
| 301 | // unloading the page. |
| 302 | FPDF_EXPORT FPDF_PAGEOBJECTMARK FPDF_CALLCONV |
| 303 | FPDFPageObj_GetMark(FPDF_PAGEOBJECT page_object, unsigned long index); |
| 304 | |
| 305 | // Get name of a content mark. |buffer| is only modified if |buflen| is longer |
| 306 | // than the length of the name. |
| 307 | // |
| 308 | // mark - handle to a content mark. |
| 309 | // buffer - buffer for holding the returned name in UTF16-LE. |
| 310 | // buflen - length of the buffer. |
| 311 | // |
| 312 | // Returns the length of the name. |
| 313 | FPDF_EXPORT unsigned long FPDF_CALLCONV |
| 314 | FPDFPageObjMark_GetName(FPDF_PAGEOBJECTMARK mark, |
| 315 | void* buffer, |
| 316 | unsigned long buflen); |
| 317 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 318 | // Load an image from a JPEG image file and then set it into |image_object|. |
| 319 | // |
| 320 | // pages - pointer to the start of all loaded pages, may be NULL. |
| 321 | // nCount - number of |pages|, may be 0. |
| 322 | // image_object - handle to an image object. |
| 323 | // fileAccess - file access handler which specifies the JPEG image file. |
| 324 | // |
| 325 | // Returns TRUE on success. |
| 326 | // |
| 327 | // The image object might already have an associated image, which is shared and |
| 328 | // cached by the loaded pages. In that case, we need to clear the cached image |
| 329 | // for all the loaded pages. Pass |pages| and page count (|nCount|) to this API |
| 330 | // to clear the image cache. If the image is not previously shared, or NULL is a |
| 331 | // valid |pages| value. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 332 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 333 | FPDFImageObj_LoadJpegFile(FPDF_PAGE* pages, |
| 334 | int nCount, |
| 335 | FPDF_PAGEOBJECT image_object, |
| 336 | FPDF_FILEACCESS* fileAccess); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 337 | |
rbpotter | f085db3 | 2016-12-14 11:44:31 -0800 | [diff] [blame] | 338 | // Load an image from a JPEG image file and then set it into |image_object|. |
| 339 | // |
| 340 | // pages - pointer to the start of all loaded pages, may be NULL. |
| 341 | // nCount - number of |pages|, may be 0. |
| 342 | // image_object - handle to an image object. |
| 343 | // fileAccess - file access handler which specifies the JPEG image file. |
| 344 | // |
| 345 | // Returns TRUE on success. |
| 346 | // |
| 347 | // The image object might already have an associated image, which is shared and |
| 348 | // cached by the loaded pages. In that case, we need to clear the cached image |
| 349 | // for all the loaded pages. Pass |pages| and page count (|nCount|) to this API |
| 350 | // to clear the image cache. If the image is not previously shared, or NULL is a |
| 351 | // valid |pages| value. This function loads the JPEG image inline, so the image |
| 352 | // content is copied to the file. This allows |fileAccess| and its associated |
| 353 | // data to be deleted after this function returns. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 354 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
rbpotter | f085db3 | 2016-12-14 11:44:31 -0800 | [diff] [blame] | 355 | FPDFImageObj_LoadJpegFileInline(FPDF_PAGE* pages, |
| 356 | int nCount, |
| 357 | FPDF_PAGEOBJECT image_object, |
| 358 | FPDF_FILEACCESS* fileAccess); |
| 359 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 360 | // Set the transform matrix of |image_object|. |
| 361 | // |
| 362 | // image_object - handle to an image object. |
| 363 | // a - matrix value. |
| 364 | // b - matrix value. |
| 365 | // c - matrix value. |
| 366 | // d - matrix value. |
| 367 | // e - matrix value. |
| 368 | // f - matrix value. |
| 369 | // |
| 370 | // The matrix is composed as: |
| 371 | // |a c e| |
| 372 | // |b d f| |
| 373 | // and can be used to scale, rotate, shear and translate the |page| annotations. |
| 374 | // |
| 375 | // Returns TRUE on success. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 376 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 377 | FPDFImageObj_SetMatrix(FPDF_PAGEOBJECT image_object, |
| 378 | double a, |
| 379 | double b, |
| 380 | double c, |
| 381 | double d, |
| 382 | double e, |
| 383 | double f); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 384 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 385 | // Set |bitmap| to |image_object|. |
| 386 | // |
| 387 | // pages - pointer to the start of all loaded pages, may be NULL. |
| 388 | // nCount - number of |pages|, may be 0. |
| 389 | // image_object - handle to an image object. |
| 390 | // bitmap - handle of the bitmap. |
| 391 | // |
| 392 | // Returns TRUE on success. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 393 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 394 | FPDFImageObj_SetBitmap(FPDF_PAGE* pages, |
| 395 | int nCount, |
| 396 | FPDF_PAGEOBJECT image_object, |
| 397 | FPDF_BITMAP bitmap); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 398 | |
Jane Liu | 28fb7ba | 2017-08-02 21:45:57 -0400 | [diff] [blame] | 399 | // Get a bitmap rasterisation of |image_object|. The returned bitmap will be |
| 400 | // owned by the caller, and FPDFBitmap_Destroy() must be called on the returned |
| 401 | // bitmap when it is no longer needed. |
| 402 | // |
| 403 | // image_object - handle to an image object. |
| 404 | // |
| 405 | // Returns the bitmap. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 406 | FPDF_EXPORT FPDF_BITMAP FPDF_CALLCONV |
Jane Liu | 28fb7ba | 2017-08-02 21:45:57 -0400 | [diff] [blame] | 407 | FPDFImageObj_GetBitmap(FPDF_PAGEOBJECT image_object); |
| 408 | |
Jane Liu | 548334e | 2017-08-03 16:33:40 -0400 | [diff] [blame] | 409 | // Get the decoded image data of |image_object|. The decoded data is the |
| 410 | // uncompressed image data, i.e. the raw image data after having all filters |
| 411 | // applied. |buffer| is only modified if |buflen| is longer than the length of |
| 412 | // the decoded image data. |
| 413 | // |
| 414 | // image_object - handle to an image object. |
| 415 | // buffer - buffer for holding the decoded image data in raw bytes. |
| 416 | // buflen - length of the buffer. |
| 417 | // |
| 418 | // Returns the length of the decoded image data. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 419 | FPDF_EXPORT unsigned long FPDF_CALLCONV |
Jane Liu | 548334e | 2017-08-03 16:33:40 -0400 | [diff] [blame] | 420 | FPDFImageObj_GetImageDataDecoded(FPDF_PAGEOBJECT image_object, |
| 421 | void* buffer, |
| 422 | unsigned long buflen); |
| 423 | |
| 424 | // Get the raw image data of |image_object|. The raw data is the image data as |
| 425 | // stored in the PDF without applying any filters. |buffer| is only modified if |
| 426 | // |buflen| is longer than the length of the raw image data. |
| 427 | // |
| 428 | // image_object - handle to an image object. |
| 429 | // buffer - buffer for holding the raw image data in raw bytes. |
| 430 | // buflen - length of the buffer. |
| 431 | // |
| 432 | // Returns the length of the raw image data. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 433 | FPDF_EXPORT unsigned long FPDF_CALLCONV |
Jane Liu | 548334e | 2017-08-03 16:33:40 -0400 | [diff] [blame] | 434 | FPDFImageObj_GetImageDataRaw(FPDF_PAGEOBJECT image_object, |
| 435 | void* buffer, |
| 436 | unsigned long buflen); |
| 437 | |
Jane Liu | be63ab9 | 2017-08-09 14:09:34 -0400 | [diff] [blame] | 438 | // Get the number of filters (i.e. decoders) of the image in |image_object|. |
| 439 | // |
| 440 | // image_object - handle to an image object. |
| 441 | // |
| 442 | // Returns the number of |image_object|'s filters. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 443 | FPDF_EXPORT int FPDF_CALLCONV |
Jane Liu | be63ab9 | 2017-08-09 14:09:34 -0400 | [diff] [blame] | 444 | FPDFImageObj_GetImageFilterCount(FPDF_PAGEOBJECT image_object); |
| 445 | |
| 446 | // Get the filter at |index| of |image_object|'s list of filters. Note that the |
| 447 | // filters need to be applied in order, i.e. the first filter should be applied |
| 448 | // first, then the second, etc. |buffer| is only modified if |buflen| is longer |
| 449 | // than the length of the filter string. |
| 450 | // |
| 451 | // image_object - handle to an image object. |
| 452 | // index - the index of the filter requested. |
Lei Zhang | 0733a1b | 2017-08-31 12:36:31 -0700 | [diff] [blame] | 453 | // buffer - buffer for holding filter string, encoded in UTF-8. |
Jane Liu | be63ab9 | 2017-08-09 14:09:34 -0400 | [diff] [blame] | 454 | // buflen - length of the buffer. |
| 455 | // |
| 456 | // Returns the length of the filter string. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 457 | FPDF_EXPORT unsigned long FPDF_CALLCONV |
Jane Liu | be63ab9 | 2017-08-09 14:09:34 -0400 | [diff] [blame] | 458 | FPDFImageObj_GetImageFilter(FPDF_PAGEOBJECT image_object, |
| 459 | int index, |
| 460 | void* buffer, |
| 461 | unsigned long buflen); |
| 462 | |
Jane Liu | ca89829 | 2017-08-16 11:25:35 -0400 | [diff] [blame] | 463 | // Get the image metadata of |image_object|, including dimension, DPI, bits per |
| 464 | // pixel, and colorspace. If the |image_object| is not an image object or if it |
| 465 | // does not have an image, then the return value will be false. Otherwise, |
| 466 | // failure to retrieve any specific parameter would result in its value being 0. |
| 467 | // |
| 468 | // image_object - handle to an image object. |
| 469 | // page - handle to the page that |image_object| is on. Required for |
| 470 | // retrieving the image's bits per pixel and colorspace. |
| 471 | // metadata - receives the image metadata; must not be NULL. |
| 472 | // |
| 473 | // Returns true if successful. |
| 474 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 475 | FPDFImageObj_GetImageMetadata(FPDF_PAGEOBJECT image_object, |
| 476 | FPDF_PAGE page, |
| 477 | FPDF_IMAGEOBJ_METADATA* metadata); |
| 478 | |
Nicolas Pena | 55e026b | 2017-02-07 14:59:23 -0500 | [diff] [blame] | 479 | // Create a new path object at an initial position. |
| 480 | // |
| 481 | // x - initial horizontal position. |
| 482 | // y - initial vertical position. |
| 483 | // |
| 484 | // Returns a handle to a new path object. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 485 | FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewPath(float x, |
| 486 | float y); |
Nicolas Pena | 55e026b | 2017-02-07 14:59:23 -0500 | [diff] [blame] | 487 | |
| 488 | // Create a closed path consisting of a rectangle. |
| 489 | // |
| 490 | // x - horizontal position for the left boundary of the rectangle. |
| 491 | // y - vertical position for the bottom boundary of the rectangle. |
| 492 | // w - width of the rectangle. |
| 493 | // h - height of the rectangle. |
| 494 | // |
| 495 | // Returns a handle to the new path object. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 496 | FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV FPDFPageObj_CreateNewRect(float x, |
| 497 | float y, |
| 498 | float w, |
| 499 | float h); |
Nicolas Pena | 55e026b | 2017-02-07 14:59:23 -0500 | [diff] [blame] | 500 | |
Nicolas Pena | 603a31d | 2017-06-14 11:41:18 -0400 | [diff] [blame] | 501 | // Get the bounding box of |page_object|. |
wileyrya | f1697fa | 2017-05-26 12:27:40 -0500 | [diff] [blame] | 502 | // |
Nicolas Pena | 603a31d | 2017-06-14 11:41:18 -0400 | [diff] [blame] | 503 | // page_object - handle to a page object. |
| 504 | // left - pointer where the left coordinate will be stored |
| 505 | // bottom - pointer where the bottom coordinate will be stored |
| 506 | // right - pointer where the right coordinate will be stored |
| 507 | // top - pointer where the top coordinate will be stored |
wileyrya | f1697fa | 2017-05-26 12:27:40 -0500 | [diff] [blame] | 508 | // |
| 509 | // Returns TRUE on success. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 510 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 511 | FPDFPageObj_GetBounds(FPDF_PAGEOBJECT page_object, |
| 512 | float* left, |
| 513 | float* bottom, |
| 514 | float* right, |
| 515 | float* top); |
wileyrya | f1697fa | 2017-05-26 12:27:40 -0500 | [diff] [blame] | 516 | |
Nicolas Pena | 603a31d | 2017-06-14 11:41:18 -0400 | [diff] [blame] | 517 | // Set the blend mode of |page_object|. |
wileyrya | 06bbdef | 2017-05-26 15:20:23 -0500 | [diff] [blame] | 518 | // |
Nicolas Pena | 603a31d | 2017-06-14 11:41:18 -0400 | [diff] [blame] | 519 | // page_object - handle to a page object. |
| 520 | // blend_mode - string containing the blend mode. |
wileyrya | 06bbdef | 2017-05-26 15:20:23 -0500 | [diff] [blame] | 521 | // |
| 522 | // Blend mode can be one of following: Color, ColorBurn, ColorDodge, Darken, |
| 523 | // Difference, Exclusion, HardLight, Hue, Lighten, Luminosity, Multiply, Normal, |
| 524 | // Overlay, Saturation, Screen, SoftLight |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 525 | FPDF_EXPORT void FPDF_CALLCONV |
| 526 | FPDFPageObj_SetBlendMode(FPDF_PAGEOBJECT page_object, |
| 527 | FPDF_BYTESTRING blend_mode); |
wileyrya | 06bbdef | 2017-05-26 15:20:23 -0500 | [diff] [blame] | 528 | |
Nicolas Pena | 55e026b | 2017-02-07 14:59:23 -0500 | [diff] [blame] | 529 | // Set the stroke RGBA of a path. Range of values: 0 - 255. |
| 530 | // |
| 531 | // path - the handle to the path object. |
| 532 | // R - the red component for the path stroke color. |
| 533 | // G - the green component for the path stroke color. |
| 534 | // B - the blue component for the path stroke color. |
| 535 | // A - the stroke alpha for the path. |
| 536 | // |
| 537 | // Returns TRUE on success. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 538 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 539 | FPDFPath_SetStrokeColor(FPDF_PAGEOBJECT path, |
| 540 | unsigned int R, |
| 541 | unsigned int G, |
| 542 | unsigned int B, |
| 543 | unsigned int A); |
Nicolas Pena | 55e026b | 2017-02-07 14:59:23 -0500 | [diff] [blame] | 544 | |
Jane Liu | 3b05743 | 2017-06-19 10:44:01 -0400 | [diff] [blame] | 545 | // Get the stroke RGBA of a path. Range of values: 0 - 255. |
| 546 | // |
| 547 | // path - the handle to the path object. |
| 548 | // R - the red component of the path stroke color. |
| 549 | // G - the green component of the path stroke color. |
| 550 | // B - the blue component of the path stroke color. |
| 551 | // A - the stroke alpha of the path. |
| 552 | // |
| 553 | // Returns TRUE on success. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 554 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 555 | FPDFPath_GetStrokeColor(FPDF_PAGEOBJECT path, |
| 556 | unsigned int* R, |
| 557 | unsigned int* G, |
| 558 | unsigned int* B, |
| 559 | unsigned int* A); |
Jane Liu | 3b05743 | 2017-06-19 10:44:01 -0400 | [diff] [blame] | 560 | |
Nicolas Pena | 2eb1a70 | 2017-02-09 18:17:33 -0500 | [diff] [blame] | 561 | // Set the stroke width of a path. |
| 562 | // |
| 563 | // path - the handle to the path object. |
| 564 | // width - the width of the stroke. |
| 565 | // |
| 566 | // Returns TRUE on success |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 567 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 568 | FPDFPath_SetStrokeWidth(FPDF_PAGEOBJECT path, float width); |
Nicolas Pena | 2eb1a70 | 2017-02-09 18:17:33 -0500 | [diff] [blame] | 569 | |
Nicolas Pena | 603a31d | 2017-06-14 11:41:18 -0400 | [diff] [blame] | 570 | // Set the line join of |page_object|. |
wileyrya | 22a237f | 2017-05-26 09:26:27 -0500 | [diff] [blame] | 571 | // |
Nicolas Pena | 603a31d | 2017-06-14 11:41:18 -0400 | [diff] [blame] | 572 | // page_object - handle to a page object. |
| 573 | // line_join - line join |
wileyrya | 22a237f | 2017-05-26 09:26:27 -0500 | [diff] [blame] | 574 | // |
wileyrya | 5be0b29 | 2017-05-31 19:13:37 -0500 | [diff] [blame] | 575 | // Line join can be one of following: FPDF_LINEJOIN_MITER, FPDF_LINEJOIN_ROUND, |
| 576 | // FPDF_LINEJOIN_BEVEL |
Lei Zhang | 9ccf087 | 2017-12-19 18:50:15 +0000 | [diff] [blame] | 577 | FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineJoin(FPDF_PAGEOBJECT page_object, |
| 578 | int line_join); |
wileyrya | 22a237f | 2017-05-26 09:26:27 -0500 | [diff] [blame] | 579 | |
Nicolas Pena | 603a31d | 2017-06-14 11:41:18 -0400 | [diff] [blame] | 580 | // Set the line cap of |page_object|. |
wileyrya | 22a237f | 2017-05-26 09:26:27 -0500 | [diff] [blame] | 581 | // |
Nicolas Pena | 603a31d | 2017-06-14 11:41:18 -0400 | [diff] [blame] | 582 | // page_object - handle to a page object. |
| 583 | // line_cap - line cap |
wileyrya | 22a237f | 2017-05-26 09:26:27 -0500 | [diff] [blame] | 584 | // |
wileyrya | 5be0b29 | 2017-05-31 19:13:37 -0500 | [diff] [blame] | 585 | // Line cap can be one of following: FPDF_LINECAP_BUTT, FPDF_LINECAP_ROUND, |
| 586 | // FPDF_LINECAP_PROJECTING_SQUARE |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 587 | FPDF_EXPORT void FPDF_CALLCONV FPDFPath_SetLineCap(FPDF_PAGEOBJECT page_object, |
| 588 | int line_cap); |
wileyrya | 22a237f | 2017-05-26 09:26:27 -0500 | [diff] [blame] | 589 | |
Nicolas Pena | 55e026b | 2017-02-07 14:59:23 -0500 | [diff] [blame] | 590 | // Set the fill RGBA of a path. Range of values: 0 - 255. |
| 591 | // |
| 592 | // path - the handle to the path object. |
| 593 | // R - the red component for the path fill color. |
| 594 | // G - the green component for the path fill color. |
| 595 | // B - the blue component for the path fill color. |
| 596 | // A - the fill alpha for the path. |
| 597 | // |
| 598 | // Returns TRUE on success. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 599 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetFillColor(FPDF_PAGEOBJECT path, |
| 600 | unsigned int R, |
| 601 | unsigned int G, |
| 602 | unsigned int B, |
| 603 | unsigned int A); |
Nicolas Pena | 55e026b | 2017-02-07 14:59:23 -0500 | [diff] [blame] | 604 | |
Miklos Vajna | ed4705b | 2017-04-05 09:24:50 +0200 | [diff] [blame] | 605 | // Get the fill RGBA of a path. Range of values: 0 - 255. |
| 606 | // |
| 607 | // path - the handle to the path object. |
| 608 | // R - the red component of the path fill color. |
| 609 | // G - the green component of the path fill color. |
| 610 | // B - the blue component of the path fill color. |
| 611 | // A - the fill alpha of the path. |
| 612 | // |
| 613 | // Returns TRUE on success. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 614 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_GetFillColor(FPDF_PAGEOBJECT path, |
| 615 | unsigned int* R, |
| 616 | unsigned int* G, |
| 617 | unsigned int* B, |
| 618 | unsigned int* A); |
Miklos Vajna | ed4705b | 2017-04-05 09:24:50 +0200 | [diff] [blame] | 619 | |
Miklos Vajna | 36eed87 | 2017-09-20 22:52:43 +0200 | [diff] [blame] | 620 | // Experimental API. |
Miklos Vajna | 0150a54 | 2017-09-21 21:46:56 +0200 | [diff] [blame] | 621 | // Get number of segments inside |path|. |
Miklos Vajna | 12abfd0 | 2017-09-15 07:49:03 +0200 | [diff] [blame] | 622 | // |
| 623 | // path - handle to a path. |
| 624 | // |
Miklos Vajna | 0150a54 | 2017-09-21 21:46:56 +0200 | [diff] [blame] | 625 | // A segment is a command, created by e.g. FPDFPath_MoveTo(), |
| 626 | // FPDFPath_LineTo() or FPDFPath_BezierTo(). |
Miklos Vajna | 12abfd0 | 2017-09-15 07:49:03 +0200 | [diff] [blame] | 627 | // |
| 628 | // Returns the number of objects in |path| or -1 on failure. |
Miklos Vajna | 0150a54 | 2017-09-21 21:46:56 +0200 | [diff] [blame] | 629 | FPDF_EXPORT int FPDF_CALLCONV FPDFPath_CountSegments(FPDF_PAGEOBJECT path); |
Miklos Vajna | 12abfd0 | 2017-09-15 07:49:03 +0200 | [diff] [blame] | 630 | |
Miklos Vajna | 36eed87 | 2017-09-20 22:52:43 +0200 | [diff] [blame] | 631 | // Experimental API. |
| 632 | // Get segment in |path| at |index|. |
| 633 | // |
| 634 | // path - handle to a path. |
| 635 | // index - the index of a segment. |
| 636 | // |
| 637 | // Returns the handle to the segment, or NULL on faiure. |
| 638 | FPDF_EXPORT FPDF_PATHSEGMENT FPDF_CALLCONV |
| 639 | FPDFPath_GetPathSegment(FPDF_PAGEOBJECT path, int index); |
| 640 | |
| 641 | // Experimental API. |
| 642 | // Get coordinates of |segment|. |
| 643 | // |
| 644 | // segment - handle to a segment. |
| 645 | // x - the horizontal position of the segment. |
| 646 | // y - the vertical position of the segment. |
| 647 | // |
| 648 | // Returns TRUE on success, otherwise |x| and |y| is not set. |
| 649 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 650 | FPDFPathSegment_GetPoint(FPDF_PATHSEGMENT segment, float* x, float* y); |
| 651 | |
| 652 | // Experimental API. |
| 653 | // Get type of |segment|. |
| 654 | // |
| 655 | // segment - handle to a segment. |
| 656 | // |
| 657 | // Returns one of the FPDF_SEGMENT_* values on success, |
| 658 | // FPDF_SEGMENT_UNKNOWN on error. |
| 659 | FPDF_EXPORT int FPDF_CALLCONV FPDFPathSegment_GetType(FPDF_PATHSEGMENT segment); |
| 660 | |
| 661 | // Experimental API. |
| 662 | // Gets if the |segment| closes the current subpath of a given path. |
| 663 | // |
| 664 | // segment - handle to a segment. |
| 665 | // |
| 666 | // Returns close flag for non-NULL segment, FALSE otherwise. |
| 667 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 668 | FPDFPathSegment_GetClose(FPDF_PATHSEGMENT segment); |
| 669 | |
Nicolas Pena | 55e026b | 2017-02-07 14:59:23 -0500 | [diff] [blame] | 670 | // Move a path's current point. |
| 671 | // |
| 672 | // path - the handle to the path object. |
| 673 | // x - the horizontal position of the new current point. |
| 674 | // y - the vertical position of the new current point. |
| 675 | // |
| 676 | // Note that no line will be created between the previous current point and the |
| 677 | // new one. |
| 678 | // |
| 679 | // Returns TRUE on success |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 680 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_MoveTo(FPDF_PAGEOBJECT path, |
| 681 | float x, |
| 682 | float y); |
Nicolas Pena | 55e026b | 2017-02-07 14:59:23 -0500 | [diff] [blame] | 683 | |
| 684 | // Add a line between the current point and a new point in the path. |
| 685 | // |
| 686 | // path - the handle to the path object. |
| 687 | // x - the horizontal position of the new point. |
| 688 | // y - the vertical position of the new point. |
| 689 | // |
| 690 | // The path's current point is changed to (x, y). |
| 691 | // |
| 692 | // Returns TRUE on success |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 693 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_LineTo(FPDF_PAGEOBJECT path, |
| 694 | float x, |
| 695 | float y); |
Nicolas Pena | 55e026b | 2017-02-07 14:59:23 -0500 | [diff] [blame] | 696 | |
| 697 | // Add a cubic Bezier curve to the given path, starting at the current point. |
| 698 | // |
| 699 | // path - the handle to the path object. |
| 700 | // x1 - the horizontal position of the first Bezier control point. |
| 701 | // y1 - the vertical position of the first Bezier control point. |
| 702 | // x2 - the horizontal position of the second Bezier control point. |
| 703 | // y2 - the vertical position of the second Bezier control point. |
| 704 | // x3 - the horizontal position of the ending point of the Bezier curve. |
| 705 | // y3 - the vertical position of the ending point of the Bezier curve. |
| 706 | // |
| 707 | // Returns TRUE on success |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 708 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_BezierTo(FPDF_PAGEOBJECT path, |
| 709 | float x1, |
| 710 | float y1, |
| 711 | float x2, |
| 712 | float y2, |
| 713 | float x3, |
| 714 | float y3); |
Nicolas Pena | 55e026b | 2017-02-07 14:59:23 -0500 | [diff] [blame] | 715 | |
| 716 | // Close the current subpath of a given path. |
| 717 | // |
| 718 | // path - the handle to the path object. |
| 719 | // |
| 720 | // This will add a line between the current point and the initial point of the |
| 721 | // subpath, thus terminating the current subpath. |
| 722 | // |
| 723 | // Returns TRUE on success |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 724 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_Close(FPDF_PAGEOBJECT path); |
Nicolas Pena | 55e026b | 2017-02-07 14:59:23 -0500 | [diff] [blame] | 725 | |
| 726 | // Set the drawing mode of a path. |
| 727 | // |
| 728 | // path - the handle to the path object. |
| 729 | // fillmode - the filling mode to be set: 0 for no fill, 1 for alternate, 2 for |
| 730 | // winding. |
| 731 | // stroke - a boolean specifying if the path should be stroked or not. |
| 732 | // |
| 733 | // Returns TRUE on success |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 734 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPath_SetDrawMode(FPDF_PAGEOBJECT path, |
| 735 | int fillmode, |
| 736 | FPDF_BOOL stroke); |
Nicolas Pena | 55e026b | 2017-02-07 14:59:23 -0500 | [diff] [blame] | 737 | |
Nicolas Pena | 4905840 | 2017-02-14 18:26:20 -0500 | [diff] [blame] | 738 | // Create a new text object using one of the standard PDF fonts. |
| 739 | // |
| 740 | // document - handle to the document. |
| 741 | // font - string containing the font name, without spaces. |
| 742 | // font_size - the font size for the new text object. |
| 743 | // |
| 744 | // Returns a handle to a new text object, or NULL on failure |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 745 | FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV |
| 746 | FPDFPageObj_NewTextObj(FPDF_DOCUMENT document, |
| 747 | FPDF_BYTESTRING font, |
| 748 | float font_size); |
Nicolas Pena | 4905840 | 2017-02-14 18:26:20 -0500 | [diff] [blame] | 749 | |
| 750 | // Set the text for a textobject. If it had text, it will be replaced. |
| 751 | // |
| 752 | // text_object - handle to the text object. |
Nicolas Pena | b316185 | 2017-05-02 14:12:50 -0400 | [diff] [blame] | 753 | // text - the UTF-16LE encoded string containing the text to be added. |
Nicolas Pena | 4905840 | 2017-02-14 18:26:20 -0500 | [diff] [blame] | 754 | // |
| 755 | // Returns TRUE on success |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 756 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 757 | FPDFText_SetText(FPDF_PAGEOBJECT text_object, FPDF_WIDESTRING text); |
Nicolas Pena | 4905840 | 2017-02-14 18:26:20 -0500 | [diff] [blame] | 758 | |
Nicolas Pena | d03ca42 | 2017-03-06 13:54:33 -0500 | [diff] [blame] | 759 | // Returns a font object loaded from a stream of data. The font is loaded |
Nicolas Pena | 46abb66 | 2017-05-17 17:23:22 -0400 | [diff] [blame] | 760 | // into the document. |
Nicolas Pena | be90aae | 2017-02-27 10:41:41 -0500 | [diff] [blame] | 761 | // |
Nicolas Pena | d03ca42 | 2017-03-06 13:54:33 -0500 | [diff] [blame] | 762 | // document - handle to the document. |
| 763 | // data - the stream of data, which will be copied by the font object. |
| 764 | // size - size of the stream, in bytes. |
| 765 | // font_type - FPDF_FONT_TYPE1 or FPDF_FONT_TRUETYPE depending on the font |
| 766 | // type. |
| 767 | // cid - a boolean specifying if the font is a CID font or not. |
Nicolas Pena | be90aae | 2017-02-27 10:41:41 -0500 | [diff] [blame] | 768 | // |
Nicolas Pena | b316185 | 2017-05-02 14:12:50 -0400 | [diff] [blame] | 769 | // The loaded font can be closed using FPDF_Font_Close. |
| 770 | // |
Nicolas Pena | be90aae | 2017-02-27 10:41:41 -0500 | [diff] [blame] | 771 | // Returns NULL on failure |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 772 | FPDF_EXPORT FPDF_FONT FPDF_CALLCONV FPDFText_LoadFont(FPDF_DOCUMENT document, |
| 773 | const uint8_t* data, |
| 774 | uint32_t size, |
| 775 | int font_type, |
| 776 | FPDF_BOOL cid); |
Nicolas Pena | be90aae | 2017-02-27 10:41:41 -0500 | [diff] [blame] | 777 | |
wileyrya | 864e9fb | 2017-05-26 11:38:14 -0500 | [diff] [blame] | 778 | // Set the fill RGBA of a text object. Range of values: 0 - 255. |
| 779 | // |
| 780 | // text_object - handle to the text object. |
| 781 | // R - the red component for the path fill color. |
| 782 | // G - the green component for the path fill color. |
| 783 | // B - the blue component for the path fill color. |
| 784 | // A - the fill alpha for the path. |
| 785 | // |
| 786 | // Returns TRUE on success. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 787 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 788 | FPDFText_SetFillColor(FPDF_PAGEOBJECT text_object, |
| 789 | unsigned int R, |
| 790 | unsigned int G, |
| 791 | unsigned int B, |
| 792 | unsigned int A); |
wileyrya | 864e9fb | 2017-05-26 11:38:14 -0500 | [diff] [blame] | 793 | |
Nicolas Pena | b316185 | 2017-05-02 14:12:50 -0400 | [diff] [blame] | 794 | // Close a loaded PDF font. |
| 795 | // |
| 796 | // font - Handle to the loaded font. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 797 | FPDF_EXPORT void FPDF_CALLCONV FPDFFont_Close(FPDF_FONT font); |
Nicolas Pena | b316185 | 2017-05-02 14:12:50 -0400 | [diff] [blame] | 798 | |
| 799 | // Create a new text object using a loaded font. |
| 800 | // |
| 801 | // document - handle to the document. |
| 802 | // font - handle to the font object. |
| 803 | // font_size - the font size for the new text object. |
| 804 | // |
| 805 | // Returns a handle to a new text object, or NULL on failure |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 806 | FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV |
Nicolas Pena | b316185 | 2017-05-02 14:12:50 -0400 | [diff] [blame] | 807 | FPDFPageObj_CreateTextObj(FPDF_DOCUMENT document, |
| 808 | FPDF_FONT font, |
| 809 | float font_size); |
| 810 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 811 | #ifdef __cplusplus |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 812 | } // extern "C" |
| 813 | #endif // __cplusplus |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 814 | |
| 815 | #endif // PUBLIC_FPDF_EDIT_H_ |