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 | e10509a | 2017-06-20 16:47:41 -0400 | [diff] [blame] | 137 | // Close an annotation. Must be called when the annotation returned by |
| 138 | // FPDFPage_CreateAnnot() or FPDFPage_GetAnnot() is no longer needed. This |
| 139 | // function does not remove the annotation from the document. |
| 140 | // |
| 141 | // annot - handle to an annotation. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 142 | FPDF_EXPORT void FPDF_CALLCONV FPDFPage_CloseAnnot(FPDF_ANNOTATION annot); |
Jane Liu | e10509a | 2017-06-20 16:47:41 -0400 | [diff] [blame] | 143 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 144 | // Experimental API. |
Jane Liu | 8ce58f5 | 2017-06-29 13:40:22 -0400 | [diff] [blame] | 145 | // Remove the annotation in |page| at |index|. |
| 146 | // |
| 147 | // page - handle to a page. |
| 148 | // index - the index of the annotation. |
| 149 | // |
| 150 | // Returns true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 151 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_RemoveAnnot(FPDF_PAGE page, |
| 152 | int index); |
Jane Liu | 8ce58f5 | 2017-06-29 13:40:22 -0400 | [diff] [blame] | 153 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 154 | // Experimental API. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 155 | // Get the subtype of an annotation. |
| 156 | // |
| 157 | // annot - handle to an annotation. |
| 158 | // |
| 159 | // Returns the annotation subtype. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 160 | FPDF_EXPORT FPDF_ANNOTATION_SUBTYPE FPDF_CALLCONV |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 161 | FPDFAnnot_GetSubtype(FPDF_ANNOTATION annot); |
| 162 | |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 163 | // Experimental API. |
Jane Liu | 7a9a38b | 2017-07-11 13:47:37 -0400 | [diff] [blame] | 164 | // Check if an annotation subtype is currently supported for object extraction, |
| 165 | // update, and removal. |
| 166 | // Currently supported subtypes: ink and stamp. |
| 167 | // |
| 168 | // subtype - the subtype to be checked. |
| 169 | // |
| 170 | // Returns true if this subtype supported. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 171 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
Jane Liu | 7a9a38b | 2017-07-11 13:47:37 -0400 | [diff] [blame] | 172 | FPDFAnnot_IsObjectSupportedSubtype(FPDF_ANNOTATION_SUBTYPE subtype); |
| 173 | |
| 174 | // Experimental API. |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 175 | // Update |obj| in |annot|. |obj| must be in |annot| already and must have |
| 176 | // been retrieved by FPDFAnnot_GetObject(). Currently, only ink and stamp |
| 177 | // annotations are supported by this API. Also note that only path, image, and |
| 178 | // text objects have APIs for modification; see FPDFPath_*(), FPDFText_*(), and |
| 179 | // FPDFImageObj_*(). |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 180 | // |
| 181 | // annot - handle to an annotation. |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 182 | // obj - handle to the object that |annot| needs to update. |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 183 | // |
| 184 | // Return true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 185 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 186 | FPDFAnnot_UpdateObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj); |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 187 | |
| 188 | // Experimental API. |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 189 | // Add |obj| to |annot|. |obj| must have been created by |
| 190 | // FPDFPageObj_CreateNew{Path|Rect}() or FPDFPageObj_New{Text|Image}Obj(), and |
| 191 | // will be owned by |annot|. Note that an |obj| cannot belong to more than one |
| 192 | // |annot|. Currently, only ink and stamp annotations are supported by this API. |
| 193 | // 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] | 194 | // |
| 195 | // annot - handle to an annotation. |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 196 | // obj - handle to the object that is to be added to |annot|. |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 197 | // |
| 198 | // Return true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 199 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 200 | FPDFAnnot_AppendObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj); |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 201 | |
| 202 | // Experimental API. |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 203 | // Get the total number of objects in |annot|, including path objects, text |
| 204 | // objects, external objects, image objects, and shading objects. |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 205 | // |
| 206 | // annot - handle to an annotation. |
| 207 | // |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 208 | // Returns the number of objects in |annot|. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 209 | FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetObjectCount(FPDF_ANNOTATION annot); |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 210 | |
| 211 | // Experimental API. |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 212 | // Get the object in |annot| at |index|. |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 213 | // |
| 214 | // annot - handle to an annotation. |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 215 | // index - the index of the object. |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 216 | // |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 217 | // Return a handle to the object, or NULL on failure. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 218 | FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV |
| 219 | FPDFAnnot_GetObject(FPDF_ANNOTATION annot, int index); |
Jane Liu | baa7ff4 | 2017-06-29 19:18:23 -0400 | [diff] [blame] | 220 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 221 | // Experimental API. |
Jane Liu | 7a9a38b | 2017-07-11 13:47:37 -0400 | [diff] [blame] | 222 | // Remove the object in |annot| at |index|. |
| 223 | // |
| 224 | // annot - handle to an annotation. |
| 225 | // index - the index of the object to be removed. |
| 226 | // |
| 227 | // Return true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 228 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 229 | FPDFAnnot_RemoveObject(FPDF_ANNOTATION annot, int index); |
Jane Liu | 7a9a38b | 2017-07-11 13:47:37 -0400 | [diff] [blame] | 230 | |
| 231 | // Experimental API. |
Jane Liu | 0646275 | 2017-06-27 16:41:14 -0400 | [diff] [blame] | 232 | // Set the color of an annotation. Fails when called on annotations with |
| 233 | // appearance streams already defined; instead use |
| 234 | // FPDFPath_Set{Stroke|Fill}Color(). |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 235 | // |
| 236 | // annot - handle to an annotation. |
| 237 | // type - type of the color to be set. |
| 238 | // R, G, B - buffer to hold the RGB value of the color. Ranges from 0 to 255. |
| 239 | // A - buffer to hold the opacity. Ranges from 0 to 255. |
| 240 | // |
Jane Liu | 8ce58f5 | 2017-06-29 13:40:22 -0400 | [diff] [blame] | 241 | // Returns true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 242 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetColor(FPDF_ANNOTATION annot, |
| 243 | FPDFANNOT_COLORTYPE type, |
| 244 | unsigned int R, |
| 245 | unsigned int G, |
| 246 | unsigned int B, |
| 247 | unsigned int A); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 248 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 249 | // Experimental API. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 250 | // 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] | 251 | // for highlight annotation, black for all else. Fails when called on |
| 252 | // annotations with appearance streams already defined; instead use |
| 253 | // FPDFPath_Get{Stroke|Fill}Color(). |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 254 | // |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 255 | // annot - handle to an annotation. |
| 256 | // type - type of the color requested. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 257 | // 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] | 258 | // A - buffer to hold the opacity. Ranges from 0 to 255. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 259 | // |
Jane Liu | 8ce58f5 | 2017-06-29 13:40:22 -0400 | [diff] [blame] | 260 | // Returns true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 261 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetColor(FPDF_ANNOTATION annot, |
| 262 | FPDFANNOT_COLORTYPE type, |
| 263 | unsigned int* R, |
| 264 | unsigned int* G, |
| 265 | unsigned int* B, |
| 266 | unsigned int* A); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 267 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 268 | // Experimental API. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 269 | // Check if the annotation is of a type that has attachment points |
| 270 | // (i.e. quadpoints). Quadpoints are the vertices of the rectange that |
| 271 | // encompasses the texts affected by the annotation. They provide the |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 272 | // coordinates in the page where the annotation is attached. Only text markup |
| 273 | // annotations (i.e. highlight, strikeout, squiggly, and underline) and link |
| 274 | // annotations have quadpoints. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 275 | // |
| 276 | // annot - handle to an annotation. |
| 277 | // |
| 278 | // Returns true if the annotation is of a type that has quadpoints, false |
| 279 | // otherwise. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 280 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 281 | FPDFAnnot_HasAttachmentPoints(FPDF_ANNOTATION annot); |
| 282 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 283 | // Experimental API. |
Jane Liu | 0646275 | 2017-06-27 16:41:14 -0400 | [diff] [blame] | 284 | // Set the attachment points (i.e. quadpoints) of an annotation. If the |
| 285 | // 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^] | 286 | // with quadpoints, then update the bounding box too if the new quadpoints |
| 287 | // define a bigger one. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 288 | // |
| 289 | // annot - handle to an annotation. |
| 290 | // quadPoints - the quadpoints to be set. |
| 291 | // |
Jane Liu | 8ce58f5 | 2017-06-29 13:40:22 -0400 | [diff] [blame] | 292 | // Returns true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 293 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
Jane Liu | 0646275 | 2017-06-27 16:41:14 -0400 | [diff] [blame] | 294 | FPDFAnnot_SetAttachmentPoints(FPDF_ANNOTATION annot, |
| 295 | const FS_QUADPOINTSF* quadPoints); |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 296 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 297 | // Experimental API. |
Jane Liu | b370e5a | 2017-08-16 13:24:58 -0400 | [diff] [blame^] | 298 | // Get the attachment points (i.e. quadpoints) of an annotation. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 299 | // |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 300 | // annot - handle to an annotation. |
Jane Liu | 0c6b07d | 2017-08-15 10:50:22 -0400 | [diff] [blame] | 301 | // quadPoints - receives the quadpoints; must not be NULL. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 302 | // |
Jane Liu | 0c6b07d | 2017-08-15 10:50:22 -0400 | [diff] [blame] | 303 | // Returns true if successful. |
| 304 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 305 | FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot, |
| 306 | FS_QUADPOINTSF* quadPoints); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 307 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 308 | // Experimental API. |
Jane Liu | 0646275 | 2017-06-27 16:41:14 -0400 | [diff] [blame] | 309 | // Set the annotation rectangle defining the location of the annotation. If the |
| 310 | // 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^] | 311 | // without quadpoints, then update the bounding box too if the new rectangle |
| 312 | // defines a bigger one. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 313 | // |
| 314 | // annot - handle to an annotation. |
| 315 | // rect - the annotation rectangle to be set. |
| 316 | // |
Jane Liu | 8ce58f5 | 2017-06-29 13:40:22 -0400 | [diff] [blame] | 317 | // Returns true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 318 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetRect(FPDF_ANNOTATION annot, |
| 319 | const FS_RECTF* rect); |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 320 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 321 | // Experimental API. |
Jane Liu | b370e5a | 2017-08-16 13:24:58 -0400 | [diff] [blame^] | 322 | // Get the annotation rectangle defining the location of the annotation. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 323 | // |
| 324 | // annot - handle to an annotation. |
Jane Liu | 0c6b07d | 2017-08-15 10:50:22 -0400 | [diff] [blame] | 325 | // rect - receives the rectangle; must not be NULL. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 326 | // |
Jane Liu | 0c6b07d | 2017-08-15 10:50:22 -0400 | [diff] [blame] | 327 | // Returns true if successful. |
| 328 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetRect(FPDF_ANNOTATION annot, |
| 329 | FS_RECTF* rect); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 330 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 331 | // Experimental API. |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 332 | // Check if |annot|'s dictionary has |key| as a key. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 333 | // |
| 334 | // annot - handle to an annotation. |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 335 | // key - the key to look for. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 336 | // |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 337 | // Returns true if |key| exists. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 338 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_HasKey(FPDF_ANNOTATION annot, |
| 339 | FPDF_WIDESTRING key); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 340 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 341 | // Experimental API. |
Jane Liu | 57f228d | 2017-07-13 18:10:30 -0400 | [diff] [blame] | 342 | // 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] | 343 | // |
| 344 | // annot - handle to an annotation. |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 345 | // key - the key to look for. |
| 346 | // |
| 347 | // Returns the type of the dictionary value. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 348 | FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV |
| 349 | FPDFAnnot_GetValueType(FPDF_ANNOTATION annot, FPDF_WIDESTRING key); |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 350 | |
| 351 | // Experimental API. |
| 352 | // Set the string value corresponding to |key| in |annot|'s dictionary, |
| 353 | // overwriting the existing value if any. The value type would be |
Jane Liu | 57f228d | 2017-07-13 18:10:30 -0400 | [diff] [blame] | 354 | // FPDF_OBJECT_STRING after this function call succeeds. |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 355 | // |
| 356 | // annot - handle to an annotation. |
| 357 | // key - the key to the dictionary entry to be set, encoded in UTF16-LE. |
| 358 | // value - the string value to be set, encoded in UTF16-LE. |
| 359 | // |
| 360 | // Returns true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 361 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 362 | FPDFAnnot_SetStringValue(FPDF_ANNOTATION annot, |
| 363 | FPDF_WIDESTRING key, |
| 364 | FPDF_WIDESTRING value); |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 365 | |
| 366 | // Experimental API. |
| 367 | // Get the string value corresponding to |key| in |annot|'s dictionary. |buffer| |
| 368 | // is only modified if |buflen| is longer than the length of contents. Note that |
| 369 | // if |key| does not exist in the dictionary or if |key|'s corresponding value |
| 370 | // in the dictionary is not a string (i.e. the value is not of type |
| 371 | // FPDF_OBJECT_STRING or FPDF_OBJECT_NAME), then an empty string would be copied |
| 372 | // to |buffer| and the return value would be 2. On other errors, nothing would |
| 373 | // be added to |buffer| and the return value would be 0. |
| 374 | // |
| 375 | // annot - handle to an annotation. |
| 376 | // key - the key to the requested dictionary entry. |
| 377 | // buffer - buffer for holding the value string, encoded in UTF16-LE. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 378 | // buflen - length of the buffer. |
| 379 | // |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 380 | // Returns the length of the string value. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 381 | FPDF_EXPORT unsigned long FPDF_CALLCONV |
| 382 | FPDFAnnot_GetStringValue(FPDF_ANNOTATION annot, |
| 383 | FPDF_WIDESTRING key, |
| 384 | void* buffer, |
| 385 | unsigned long buflen); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 386 | |
Jane Liu | b137e75 | 2017-07-05 15:04:33 -0400 | [diff] [blame] | 387 | // Experimental API. |
| 388 | // Get the annotation flags of |annot|. |
| 389 | // |
| 390 | // annot - handle to an annotation. |
| 391 | // |
| 392 | // Returns the annotation flags. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 393 | FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetFlags(FPDF_ANNOTATION annot); |
Jane Liu | b137e75 | 2017-07-05 15:04:33 -0400 | [diff] [blame] | 394 | |
| 395 | // Experimental API. |
| 396 | // Set the |annot|'s flags to be of the value |flags|. |
| 397 | // |
| 398 | // annot - handle to an annotation. |
| 399 | // flags - the flag values to be set. |
| 400 | // |
| 401 | // Returns true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 402 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetFlags(FPDF_ANNOTATION annot, |
| 403 | int flags); |
Jane Liu | b137e75 | 2017-07-05 15:04:33 -0400 | [diff] [blame] | 404 | |
Diana Gage | 7e0c05d | 2017-07-19 17:33:33 -0700 | [diff] [blame] | 405 | // Experimental API. |
| 406 | // Get the annotation flags of |annot|, which is an interactive form |
| 407 | // annotation in |page|. |
| 408 | // |
| 409 | // page - handle to a page. |
| 410 | // annot - handle to an interactive form annotation. |
| 411 | // |
| 412 | // Returns the annotation flags specific to interactive forms. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 413 | FPDF_EXPORT int FPDF_CALLCONV |
| 414 | FPDFAnnot_GetFormFieldFlags(FPDF_PAGE page, FPDF_ANNOTATION annot); |
Diana Gage | 7e0c05d | 2017-07-19 17:33:33 -0700 | [diff] [blame] | 415 | |
Diana Gage | 40870db | 2017-07-19 18:16:03 -0700 | [diff] [blame] | 416 | // Experimental API. |
| 417 | // Retrieves an interactive form annotation whose rectangle contains a given |
| 418 | // point on a page. Must call FPDFPage_CloseAnnot() when the annotation returned |
| 419 | // is no longer needed. |
| 420 | // |
| 421 | // |
| 422 | // hHandle - handle to the form fill module, returned by |
| 423 | // FPDFDOC_InitFormFillEnvironment. |
| 424 | // page - handle to the page, returned by FPDF_LoadPage function. |
| 425 | // page_x - X position in PDF "user space". |
| 426 | // page_y - Y position in PDF "user space". |
| 427 | // |
| 428 | // Returns the interactive form annotation whose rectangle contains the given |
| 429 | // coordinates on the page. If there is no such annotation, return NULL. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 430 | FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV |
Diana Gage | 40870db | 2017-07-19 18:16:03 -0700 | [diff] [blame] | 431 | FPDFAnnot_GetFormFieldAtPoint(FPDF_FORMHANDLE hHandle, |
| 432 | FPDF_PAGE page, |
| 433 | double page_x, |
| 434 | double page_y); |
| 435 | |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 436 | #ifdef __cplusplus |
| 437 | } // extern "C" |
| 438 | #endif // __cplusplus |
| 439 | |
| 440 | #endif // PUBLIC_FPDF_ANNOT_H_ |