Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 1 | // Copyright 2017 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. |
| 4 | |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 5 | #ifndef PUBLIC_FPDF_ANNOT_H_ |
| 6 | #define PUBLIC_FPDF_ANNOT_H_ |
| 7 | |
| 8 | // NOLINTNEXTLINE(build/include) |
| 9 | #include "fpdfview.h" |
| 10 | |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 11 | // NOLINTNEXTLINE(build/include) |
Jane Liu | c5ea630 | 2017-07-18 19:31:42 -0400 | [diff] [blame] | 12 | #include "fpdf_doc.h" |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 13 | // NOLINTNEXTLINE(build/include) |
Diana Gage | 40870db | 2017-07-19 18:16:03 -0700 | [diff] [blame] | 14 | #include "fpdf_formfill.h" |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 15 | |
| 16 | #ifdef __cplusplus |
| 17 | extern "C" { |
| 18 | #endif // __cplusplus |
| 19 | |
| 20 | #define FPDF_ANNOT_UNKNOWN 0 |
| 21 | #define FPDF_ANNOT_TEXT 1 |
| 22 | #define FPDF_ANNOT_LINK 2 |
| 23 | #define FPDF_ANNOT_FREETEXT 3 |
| 24 | #define FPDF_ANNOT_LINE 4 |
| 25 | #define FPDF_ANNOT_SQUARE 5 |
| 26 | #define FPDF_ANNOT_CIRCLE 6 |
| 27 | #define FPDF_ANNOT_POLYGON 7 |
| 28 | #define FPDF_ANNOT_POLYLINE 8 |
| 29 | #define FPDF_ANNOT_HIGHLIGHT 9 |
| 30 | #define FPDF_ANNOT_UNDERLINE 10 |
| 31 | #define FPDF_ANNOT_SQUIGGLY 11 |
| 32 | #define FPDF_ANNOT_STRIKEOUT 12 |
| 33 | #define FPDF_ANNOT_STAMP 13 |
| 34 | #define FPDF_ANNOT_CARET 14 |
| 35 | #define FPDF_ANNOT_INK 15 |
| 36 | #define FPDF_ANNOT_POPUP 16 |
| 37 | #define FPDF_ANNOT_FILEATTACHMENT 17 |
| 38 | #define FPDF_ANNOT_SOUND 18 |
| 39 | #define FPDF_ANNOT_MOVIE 19 |
| 40 | #define FPDF_ANNOT_WIDGET 20 |
| 41 | #define FPDF_ANNOT_SCREEN 21 |
| 42 | #define FPDF_ANNOT_PRINTERMARK 22 |
| 43 | #define FPDF_ANNOT_TRAPNET 23 |
| 44 | #define FPDF_ANNOT_WATERMARK 24 |
| 45 | #define FPDF_ANNOT_THREED 25 |
| 46 | #define FPDF_ANNOT_RICHMEDIA 26 |
| 47 | #define FPDF_ANNOT_XFAWIDGET 27 |
| 48 | |
Jane Liu | b137e75 | 2017-07-05 15:04:33 -0400 | [diff] [blame] | 49 | // Refer to PDF Reference (6th edition) table 8.16 for all annotation flags. |
| 50 | #define FPDF_ANNOT_FLAG_NONE 0 |
| 51 | #define FPDF_ANNOT_FLAG_INVISIBLE (1 << 0) |
| 52 | #define FPDF_ANNOT_FLAG_HIDDEN (1 << 1) |
| 53 | #define FPDF_ANNOT_FLAG_PRINT (1 << 2) |
| 54 | #define FPDF_ANNOT_FLAG_NOZOOM (1 << 3) |
| 55 | #define FPDF_ANNOT_FLAG_NOROTATE (1 << 4) |
| 56 | #define FPDF_ANNOT_FLAG_NOVIEW (1 << 5) |
| 57 | #define FPDF_ANNOT_FLAG_READONLY (1 << 6) |
| 58 | #define FPDF_ANNOT_FLAG_LOCKED (1 << 7) |
| 59 | #define FPDF_ANNOT_FLAG_TOGGLENOVIEW (1 << 8) |
| 60 | |
Diana Gage | 7e0c05d | 2017-07-19 17:33:33 -0700 | [diff] [blame] | 61 | #define FPDF_OBJECT_UNKNOWN 0 |
| 62 | #define FPDF_OBJECT_BOOLEAN 1 |
| 63 | #define FPDF_OBJECT_NUMBER 2 |
| 64 | #define FPDF_OBJECT_STRING 3 |
| 65 | #define FPDF_OBJECT_NAME 4 |
| 66 | #define FPDF_OBJECT_ARRAY 5 |
| 67 | #define FPDF_OBJECT_DICTIONARY 6 |
| 68 | #define FPDF_OBJECT_STREAM 7 |
| 69 | #define FPDF_OBJECT_NULLOBJ 8 |
| 70 | #define FPDF_OBJECT_REFERENCE 9 |
| 71 | |
| 72 | // Refer to PDF Reference version 1.7 table 8.70 for field flags common to all |
| 73 | // interactive form field types. |
| 74 | #define FPDF_FORMFLAG_NONE 0 |
| 75 | #define FPDF_FORMFLAG_READONLY (1 << 0) |
| 76 | #define FPDF_FORMFLAG_REQUIRED (1 << 1) |
| 77 | #define FPDF_FORMFLAG_NOEXPORT (1 << 2) |
| 78 | |
| 79 | // Refer to PDF Reference version 1.7 table 8.77 for field flags specific to |
| 80 | // interactive form text fields. |
| 81 | #define FPDF_FORMFLAG_TEXT_MULTILINE (1 << 12) |
| 82 | |
| 83 | // Refer to PDF Reference version 1.7 table 8.79 for field flags specific to |
| 84 | // interactive form choice fields. |
| 85 | #define FPDF_FORMFLAG_CHOICE_COMBO (1 << 17) |
| 86 | #define FPDF_FORMFLAG_CHOICE_EDIT (1 << 18) |
| 87 | |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 88 | typedef enum FPDFANNOT_COLORTYPE { |
| 89 | FPDFANNOT_COLORTYPE_Color = 0, |
| 90 | FPDFANNOT_COLORTYPE_InteriorColor |
| 91 | } FPDFANNOT_COLORTYPE; |
| 92 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 93 | // Experimental API. |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 94 | // Check if an annotation subtype is currently supported for creation. |
| 95 | // Currently supported subtypes: circle, highlight, ink, popup, square, |
| 96 | // squiggly, stamp, strikeout, text, and underline. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 97 | // |
| 98 | // subtype - the subtype to be checked. |
| 99 | // |
Jane Liu | 8ce58f5 | 2017-06-29 13:40:22 -0400 | [diff] [blame] | 100 | // Returns true if this subtype supported. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 101 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 102 | FPDFAnnot_IsSupportedSubtype(FPDF_ANNOTATION_SUBTYPE subtype); |
| 103 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 104 | // Experimental API. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 105 | // Create an annotation in |page| of the subtype |subtype|. If the specified |
| 106 | // subtype is illegal or unsupported, then a new annotation will not be created. |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 107 | // Must call FPDFPage_CloseAnnot() when the annotation returned by this |
| 108 | // function is no longer needed. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 109 | // |
| 110 | // page - handle to a page. |
| 111 | // subtype - the subtype of the new annotation. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 112 | // |
Jane Liu | d60e9ad | 2017-06-26 11:28:36 -0400 | [diff] [blame] | 113 | // Returns a handle to the new annotation object, or NULL on failure. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 114 | FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV |
Jane Liu | d60e9ad | 2017-06-26 11:28:36 -0400 | [diff] [blame] | 115 | FPDFPage_CreateAnnot(FPDF_PAGE page, FPDF_ANNOTATION_SUBTYPE subtype); |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 116 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 117 | // Experimental API. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 118 | // Get the number of annotations in |page|. |
| 119 | // |
| 120 | // page - handle to a page. |
| 121 | // |
| 122 | // Returns the number of annotations in |page|. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 123 | FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetAnnotCount(FPDF_PAGE page); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 124 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 125 | // Experimental API. |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 126 | // Get annotation in |page| at |index|. Must call FPDFPage_CloseAnnot() when the |
| 127 | // annotation returned by this function is no longer needed. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 128 | // |
| 129 | // page - handle to a page. |
| 130 | // index - the index of the annotation. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 131 | // |
Jane Liu | d60e9ad | 2017-06-26 11:28:36 -0400 | [diff] [blame] | 132 | // Returns a handle to the annotation object, or NULL on failure. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 133 | FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV FPDFPage_GetAnnot(FPDF_PAGE page, |
| 134 | int index); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 135 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 136 | // Experimental API. |
Jane Liu | d1ed1ce | 2017-08-24 12:31:10 -0400 | [diff] [blame] | 137 | // Get the index of |annot| in |page|. This is the opposite of |
| 138 | // FPDFPage_GetAnnot(). |
| 139 | // |
| 140 | // page - handle to the page that the annotation is on. |
| 141 | // annot - handle to an annotation. |
| 142 | // |
| 143 | // Returns the index of |annot|, or -1 on failure. |
| 144 | FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetAnnotIndex(FPDF_PAGE page, |
| 145 | FPDF_ANNOTATION annot); |
| 146 | |
| 147 | // Experimental API. |
Jane Liu | e10509a | 2017-06-20 16:47:41 -0400 | [diff] [blame] | 148 | // Close an annotation. Must be called when the annotation returned by |
| 149 | // FPDFPage_CreateAnnot() or FPDFPage_GetAnnot() is no longer needed. This |
| 150 | // function does not remove the annotation from the document. |
| 151 | // |
| 152 | // annot - handle to an annotation. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 153 | FPDF_EXPORT void FPDF_CALLCONV FPDFPage_CloseAnnot(FPDF_ANNOTATION annot); |
Jane Liu | e10509a | 2017-06-20 16:47:41 -0400 | [diff] [blame] | 154 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 155 | // Experimental API. |
Jane Liu | 8ce58f5 | 2017-06-29 13:40:22 -0400 | [diff] [blame] | 156 | // Remove the annotation in |page| at |index|. |
| 157 | // |
| 158 | // page - handle to a page. |
| 159 | // index - the index of the annotation. |
| 160 | // |
| 161 | // Returns true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 162 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_RemoveAnnot(FPDF_PAGE page, |
| 163 | int index); |
Jane Liu | 8ce58f5 | 2017-06-29 13:40:22 -0400 | [diff] [blame] | 164 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 165 | // Experimental API. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 166 | // Get the subtype of an annotation. |
| 167 | // |
| 168 | // annot - handle to an annotation. |
| 169 | // |
| 170 | // Returns the annotation subtype. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 171 | FPDF_EXPORT FPDF_ANNOTATION_SUBTYPE FPDF_CALLCONV |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 172 | FPDFAnnot_GetSubtype(FPDF_ANNOTATION annot); |
| 173 | |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 174 | // Experimental API. |
Jane Liu | 7a9a38b | 2017-07-11 13:47:37 -0400 | [diff] [blame] | 175 | // Check if an annotation subtype is currently supported for object extraction, |
| 176 | // update, and removal. |
| 177 | // Currently supported subtypes: ink and stamp. |
| 178 | // |
| 179 | // subtype - the subtype to be checked. |
| 180 | // |
| 181 | // Returns true if this subtype supported. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 182 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
Jane Liu | 7a9a38b | 2017-07-11 13:47:37 -0400 | [diff] [blame] | 183 | FPDFAnnot_IsObjectSupportedSubtype(FPDF_ANNOTATION_SUBTYPE subtype); |
| 184 | |
| 185 | // Experimental API. |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 186 | // Update |obj| in |annot|. |obj| must be in |annot| already and must have |
| 187 | // been retrieved by FPDFAnnot_GetObject(). Currently, only ink and stamp |
| 188 | // annotations are supported by this API. Also note that only path, image, and |
| 189 | // text objects have APIs for modification; see FPDFPath_*(), FPDFText_*(), and |
| 190 | // FPDFImageObj_*(). |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 191 | // |
| 192 | // annot - handle to an annotation. |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 193 | // obj - handle to the object that |annot| needs to update. |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 194 | // |
| 195 | // Return true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 196 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 197 | FPDFAnnot_UpdateObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj); |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 198 | |
| 199 | // Experimental API. |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 200 | // Add |obj| to |annot|. |obj| must have been created by |
| 201 | // FPDFPageObj_CreateNew{Path|Rect}() or FPDFPageObj_New{Text|Image}Obj(), and |
| 202 | // will be owned by |annot|. Note that an |obj| cannot belong to more than one |
| 203 | // |annot|. Currently, only ink and stamp annotations are supported by this API. |
| 204 | // Also note that only path, image, and text objects have APIs for creation. |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 205 | // |
| 206 | // annot - handle to an annotation. |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 207 | // obj - handle to the object that is to be added to |annot|. |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 208 | // |
| 209 | // Return true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 210 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 211 | FPDFAnnot_AppendObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj); |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 212 | |
| 213 | // Experimental API. |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 214 | // Get the total number of objects in |annot|, including path objects, text |
| 215 | // objects, external objects, image objects, and shading objects. |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 216 | // |
| 217 | // annot - handle to an annotation. |
| 218 | // |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 219 | // Returns the number of objects in |annot|. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 220 | FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetObjectCount(FPDF_ANNOTATION annot); |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 221 | |
| 222 | // Experimental API. |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 223 | // Get the object in |annot| at |index|. |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 224 | // |
| 225 | // annot - handle to an annotation. |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 226 | // index - the index of the object. |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 227 | // |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 228 | // Return a handle to the object, or NULL on failure. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 229 | FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV |
| 230 | FPDFAnnot_GetObject(FPDF_ANNOTATION annot, int index); |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 231 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 232 | // Experimental API. |
Jane Liu | 7a9a38b | 2017-07-11 13:47:37 -0400 | [diff] [blame] | 233 | // Remove the object in |annot| at |index|. |
| 234 | // |
| 235 | // annot - handle to an annotation. |
| 236 | // index - the index of the object to be removed. |
| 237 | // |
| 238 | // Return true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 239 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 240 | FPDFAnnot_RemoveObject(FPDF_ANNOTATION annot, int index); |
Jane Liu | 7a9a38b | 2017-07-11 13:47:37 -0400 | [diff] [blame] | 241 | |
| 242 | // Experimental API. |
Jane Liu | 0646275 | 2017-06-27 16:41:14 -0400 | [diff] [blame] | 243 | // Set the color of an annotation. Fails when called on annotations with |
| 244 | // appearance streams already defined; instead use |
| 245 | // FPDFPath_Set{Stroke|Fill}Color(). |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 246 | // |
| 247 | // annot - handle to an annotation. |
| 248 | // type - type of the color to be set. |
| 249 | // R, G, B - buffer to hold the RGB value of the color. Ranges from 0 to 255. |
| 250 | // A - buffer to hold the opacity. Ranges from 0 to 255. |
| 251 | // |
Jane Liu | 8ce58f5 | 2017-06-29 13:40:22 -0400 | [diff] [blame] | 252 | // Returns true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 253 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetColor(FPDF_ANNOTATION annot, |
| 254 | FPDFANNOT_COLORTYPE type, |
| 255 | unsigned int R, |
| 256 | unsigned int G, |
| 257 | unsigned int B, |
| 258 | unsigned int A); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 259 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 260 | // Experimental API. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 261 | // Get the color of an annotation. If no color is specified, default to yellow |
Jane Liu | 0646275 | 2017-06-27 16:41:14 -0400 | [diff] [blame] | 262 | // for highlight annotation, black for all else. Fails when called on |
| 263 | // annotations with appearance streams already defined; instead use |
| 264 | // FPDFPath_Get{Stroke|Fill}Color(). |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 265 | // |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 266 | // annot - handle to an annotation. |
| 267 | // type - type of the color requested. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 268 | // R, G, B - buffer to hold the RGB value of the color. Ranges from 0 to 255. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 269 | // A - buffer to hold the opacity. Ranges from 0 to 255. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 270 | // |
Jane Liu | 8ce58f5 | 2017-06-29 13:40:22 -0400 | [diff] [blame] | 271 | // Returns true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 272 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetColor(FPDF_ANNOTATION annot, |
| 273 | FPDFANNOT_COLORTYPE type, |
| 274 | unsigned int* R, |
| 275 | unsigned int* G, |
| 276 | unsigned int* B, |
| 277 | unsigned int* A); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 278 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 279 | // Experimental API. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 280 | // Check if the annotation is of a type that has attachment points |
| 281 | // (i.e. quadpoints). Quadpoints are the vertices of the rectange that |
| 282 | // encompasses the texts affected by the annotation. They provide the |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 283 | // coordinates in the page where the annotation is attached. Only text markup |
| 284 | // annotations (i.e. highlight, strikeout, squiggly, and underline) and link |
| 285 | // annotations have quadpoints. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 286 | // |
| 287 | // annot - handle to an annotation. |
| 288 | // |
| 289 | // Returns true if the annotation is of a type that has quadpoints, false |
| 290 | // otherwise. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 291 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 292 | FPDFAnnot_HasAttachmentPoints(FPDF_ANNOTATION annot); |
| 293 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 294 | // Experimental API. |
Jane Liu | 0646275 | 2017-06-27 16:41:14 -0400 | [diff] [blame] | 295 | // Set the attachment points (i.e. quadpoints) of an annotation. If the |
| 296 | // annotation's appearance stream is defined and this annotation is of a type |
Jane Liu | b370e5a | 2017-08-16 13:24:58 -0400 | [diff] [blame] | 297 | // with quadpoints, then update the bounding box too if the new quadpoints |
| 298 | // define a bigger one. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 299 | // |
| 300 | // annot - handle to an annotation. |
| 301 | // quadPoints - the quadpoints to be set. |
| 302 | // |
Jane Liu | 8ce58f5 | 2017-06-29 13:40:22 -0400 | [diff] [blame] | 303 | // Returns true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 304 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
Jane Liu | 0646275 | 2017-06-27 16:41:14 -0400 | [diff] [blame] | 305 | FPDFAnnot_SetAttachmentPoints(FPDF_ANNOTATION annot, |
| 306 | const FS_QUADPOINTSF* quadPoints); |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 307 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 308 | // Experimental API. |
Jane Liu | b370e5a | 2017-08-16 13:24:58 -0400 | [diff] [blame] | 309 | // Get the attachment points (i.e. quadpoints) of an annotation. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 310 | // |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 311 | // annot - handle to an annotation. |
Jane Liu | 0c6b07d | 2017-08-15 10:50:22 -0400 | [diff] [blame] | 312 | // quadPoints - receives the quadpoints; must not be NULL. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 313 | // |
Jane Liu | 0c6b07d | 2017-08-15 10:50:22 -0400 | [diff] [blame] | 314 | // Returns true if successful. |
| 315 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 316 | FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot, |
| 317 | FS_QUADPOINTSF* quadPoints); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 318 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 319 | // Experimental API. |
Jane Liu | 0646275 | 2017-06-27 16:41:14 -0400 | [diff] [blame] | 320 | // Set the annotation rectangle defining the location of the annotation. If the |
| 321 | // annotation's appearance stream is defined and this annotation is of a type |
Jane Liu | b370e5a | 2017-08-16 13:24:58 -0400 | [diff] [blame] | 322 | // without quadpoints, then update the bounding box too if the new rectangle |
| 323 | // defines a bigger one. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 324 | // |
| 325 | // annot - handle to an annotation. |
| 326 | // rect - the annotation rectangle to be set. |
| 327 | // |
Jane Liu | 8ce58f5 | 2017-06-29 13:40:22 -0400 | [diff] [blame] | 328 | // Returns true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 329 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetRect(FPDF_ANNOTATION annot, |
| 330 | const FS_RECTF* rect); |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 331 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 332 | // Experimental API. |
Jane Liu | b370e5a | 2017-08-16 13:24:58 -0400 | [diff] [blame] | 333 | // Get the annotation rectangle defining the location of the annotation. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 334 | // |
| 335 | // annot - handle to an annotation. |
Jane Liu | 0c6b07d | 2017-08-15 10:50:22 -0400 | [diff] [blame] | 336 | // rect - receives the rectangle; must not be NULL. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 337 | // |
Jane Liu | 0c6b07d | 2017-08-15 10:50:22 -0400 | [diff] [blame] | 338 | // Returns true if successful. |
| 339 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetRect(FPDF_ANNOTATION annot, |
| 340 | FS_RECTF* rect); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 341 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 342 | // Experimental API. |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 343 | // Check if |annot|'s dictionary has |key| as a key. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 344 | // |
| 345 | // annot - handle to an annotation. |
Lei Zhang | ba14c0a | 2017-09-22 16:43:01 -0700 | [diff] [blame] | 346 | // key - the key to look for, encoded in UTF-8. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 347 | // |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 348 | // Returns true if |key| exists. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 349 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_HasKey(FPDF_ANNOTATION annot, |
Lei Zhang | df064df | 2017-08-31 02:33:27 -0700 | [diff] [blame] | 350 | FPDF_BYTESTRING key); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 351 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 352 | // Experimental API. |
Jane Liu | 57f228d | 2017-07-13 18:10:30 -0400 | [diff] [blame] | 353 | // Get the type of the value corresponding to |key| in |annot|'s dictionary. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 354 | // |
| 355 | // annot - handle to an annotation. |
Lei Zhang | ba14c0a | 2017-09-22 16:43:01 -0700 | [diff] [blame] | 356 | // key - the key to look for, encoded in UTF-8. |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 357 | // |
| 358 | // Returns the type of the dictionary value. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 359 | FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV |
Lei Zhang | df064df | 2017-08-31 02:33:27 -0700 | [diff] [blame] | 360 | FPDFAnnot_GetValueType(FPDF_ANNOTATION annot, FPDF_BYTESTRING key); |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 361 | |
| 362 | // Experimental API. |
| 363 | // Set the string value corresponding to |key| in |annot|'s dictionary, |
| 364 | // overwriting the existing value if any. The value type would be |
Jane Liu | 57f228d | 2017-07-13 18:10:30 -0400 | [diff] [blame] | 365 | // FPDF_OBJECT_STRING after this function call succeeds. |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 366 | // |
| 367 | // annot - handle to an annotation. |
Lei Zhang | ba14c0a | 2017-09-22 16:43:01 -0700 | [diff] [blame] | 368 | // key - the key to the dictionary entry to be set, encoded in UTF-8. |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 369 | // value - the string value to be set, encoded in UTF16-LE. |
| 370 | // |
| 371 | // Returns true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 372 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 373 | FPDFAnnot_SetStringValue(FPDF_ANNOTATION annot, |
Lei Zhang | df064df | 2017-08-31 02:33:27 -0700 | [diff] [blame] | 374 | FPDF_BYTESTRING key, |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 375 | FPDF_WIDESTRING value); |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 376 | |
| 377 | // Experimental API. |
| 378 | // Get the string value corresponding to |key| in |annot|'s dictionary. |buffer| |
| 379 | // is only modified if |buflen| is longer than the length of contents. Note that |
| 380 | // if |key| does not exist in the dictionary or if |key|'s corresponding value |
| 381 | // in the dictionary is not a string (i.e. the value is not of type |
| 382 | // FPDF_OBJECT_STRING or FPDF_OBJECT_NAME), then an empty string would be copied |
| 383 | // to |buffer| and the return value would be 2. On other errors, nothing would |
| 384 | // be added to |buffer| and the return value would be 0. |
| 385 | // |
| 386 | // annot - handle to an annotation. |
Lei Zhang | ba14c0a | 2017-09-22 16:43:01 -0700 | [diff] [blame] | 387 | // key - the key to the requested dictionary entry, encoded in UTF-8. |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 388 | // buffer - buffer for holding the value string, encoded in UTF16-LE. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 389 | // buflen - length of the buffer. |
| 390 | // |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 391 | // Returns the length of the string value. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 392 | FPDF_EXPORT unsigned long FPDF_CALLCONV |
| 393 | FPDFAnnot_GetStringValue(FPDF_ANNOTATION annot, |
Lei Zhang | df064df | 2017-08-31 02:33:27 -0700 | [diff] [blame] | 394 | FPDF_BYTESTRING key, |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 395 | void* buffer, |
| 396 | unsigned long buflen); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 397 | |
Jane Liu | b137e75 | 2017-07-05 15:04:33 -0400 | [diff] [blame] | 398 | // Experimental API. |
Jane Liu | 300bb27 | 2017-08-21 14:37:53 -0400 | [diff] [blame] | 399 | // Get the annotation corresponding to |key| in |annot|'s dictionary. Common |
| 400 | // keys for linking annotations include "IRT" and "Popup". Must call |
| 401 | // FPDFPage_CloseAnnot() when the annotation returned by this function is no |
| 402 | // longer needed. |
| 403 | // |
| 404 | // annot - handle to an annotation. |
Lei Zhang | ba14c0a | 2017-09-22 16:43:01 -0700 | [diff] [blame] | 405 | // key - the key to the requested dictionary entry, encoded in UTF-8. |
Jane Liu | 300bb27 | 2017-08-21 14:37:53 -0400 | [diff] [blame] | 406 | // |
| 407 | // Returns a handle to the linked annotation object, or NULL on failure. |
| 408 | FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV |
Lei Zhang | df064df | 2017-08-31 02:33:27 -0700 | [diff] [blame] | 409 | FPDFAnnot_GetLinkedAnnot(FPDF_ANNOTATION annot, FPDF_BYTESTRING key); |
Jane Liu | 300bb27 | 2017-08-21 14:37:53 -0400 | [diff] [blame] | 410 | |
| 411 | // Experimental API. |
Jane Liu | b137e75 | 2017-07-05 15:04:33 -0400 | [diff] [blame] | 412 | // Get the annotation flags of |annot|. |
| 413 | // |
| 414 | // annot - handle to an annotation. |
| 415 | // |
| 416 | // Returns the annotation flags. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 417 | FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetFlags(FPDF_ANNOTATION annot); |
Jane Liu | b137e75 | 2017-07-05 15:04:33 -0400 | [diff] [blame] | 418 | |
| 419 | // Experimental API. |
| 420 | // Set the |annot|'s flags to be of the value |flags|. |
| 421 | // |
| 422 | // annot - handle to an annotation. |
| 423 | // flags - the flag values to be set. |
| 424 | // |
| 425 | // Returns true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 426 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetFlags(FPDF_ANNOTATION annot, |
| 427 | int flags); |
Jane Liu | b137e75 | 2017-07-05 15:04:33 -0400 | [diff] [blame] | 428 | |
Diana Gage | 7e0c05d | 2017-07-19 17:33:33 -0700 | [diff] [blame] | 429 | // Experimental API. |
| 430 | // Get the annotation flags of |annot|, which is an interactive form |
| 431 | // annotation in |page|. |
| 432 | // |
| 433 | // page - handle to a page. |
| 434 | // annot - handle to an interactive form annotation. |
| 435 | // |
| 436 | // Returns the annotation flags specific to interactive forms. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 437 | FPDF_EXPORT int FPDF_CALLCONV |
| 438 | FPDFAnnot_GetFormFieldFlags(FPDF_PAGE page, FPDF_ANNOTATION annot); |
Diana Gage | 7e0c05d | 2017-07-19 17:33:33 -0700 | [diff] [blame] | 439 | |
Diana Gage | 40870db | 2017-07-19 18:16:03 -0700 | [diff] [blame] | 440 | // Experimental API. |
| 441 | // Retrieves an interactive form annotation whose rectangle contains a given |
| 442 | // point on a page. Must call FPDFPage_CloseAnnot() when the annotation returned |
| 443 | // is no longer needed. |
| 444 | // |
| 445 | // |
| 446 | // hHandle - handle to the form fill module, returned by |
| 447 | // FPDFDOC_InitFormFillEnvironment. |
| 448 | // page - handle to the page, returned by FPDF_LoadPage function. |
| 449 | // page_x - X position in PDF "user space". |
| 450 | // page_y - Y position in PDF "user space". |
| 451 | // |
| 452 | // Returns the interactive form annotation whose rectangle contains the given |
| 453 | // coordinates on the page. If there is no such annotation, return NULL. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 454 | FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV |
Diana Gage | 40870db | 2017-07-19 18:16:03 -0700 | [diff] [blame] | 455 | FPDFAnnot_GetFormFieldAtPoint(FPDF_FORMHANDLE hHandle, |
| 456 | FPDF_PAGE page, |
| 457 | double page_x, |
| 458 | double page_y); |
| 459 | |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 460 | #ifdef __cplusplus |
| 461 | } // extern "C" |
| 462 | #endif // __cplusplus |
| 463 | |
| 464 | #endif // PUBLIC_FPDF_ANNOT_H_ |