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