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 |
| 286 | // with quadpoints, then update the bounding box too. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 287 | // |
| 288 | // annot - handle to an annotation. |
| 289 | // quadPoints - the quadpoints to be set. |
| 290 | // |
Jane Liu | 8ce58f5 | 2017-06-29 13:40:22 -0400 | [diff] [blame] | 291 | // Returns true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 292 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
Jane Liu | 0646275 | 2017-06-27 16:41:14 -0400 | [diff] [blame] | 293 | FPDFAnnot_SetAttachmentPoints(FPDF_ANNOTATION annot, |
| 294 | const FS_QUADPOINTSF* quadPoints); |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 295 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 296 | // Experimental API. |
Jane Liu | 0646275 | 2017-06-27 16:41:14 -0400 | [diff] [blame] | 297 | // Get the attachment points (i.e. quadpoints) of an annotation. If the |
| 298 | // annotation's appearance stream is defined and this annotation is of a type |
| 299 | // with quadpoints, then return the bounding box it specifies instead. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 300 | // |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 301 | // annot - handle to an annotation. |
Jane Liu | 0c6b07d | 2017-08-15 10:50:22 -0400 | [diff] [blame^] | 302 | // quadPoints - receives the quadpoints; must not be NULL. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 303 | // |
Jane Liu | 0c6b07d | 2017-08-15 10:50:22 -0400 | [diff] [blame^] | 304 | // Returns true if successful. |
| 305 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 306 | FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot, |
| 307 | FS_QUADPOINTSF* quadPoints); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 308 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 309 | // Experimental API. |
Jane Liu | 0646275 | 2017-06-27 16:41:14 -0400 | [diff] [blame] | 310 | // Set the annotation rectangle defining the location of the annotation. If the |
| 311 | // annotation's appearance stream is defined and this annotation is of a type |
| 312 | // without quadpoints, then update the bounding box too. |
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 | 0646275 | 2017-06-27 16:41:14 -0400 | [diff] [blame] | 322 | // Get the annotation rectangle defining the location of the annotation. If the |
| 323 | // annotation's appearance stream is defined and this annotation is of a type |
| 324 | // without quadpoints, then return the bounding box it specifies instead. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 325 | // |
| 326 | // annot - handle to an annotation. |
Jane Liu | 0c6b07d | 2017-08-15 10:50:22 -0400 | [diff] [blame^] | 327 | // rect - receives the rectangle; must not be NULL. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 328 | // |
Jane Liu | 0c6b07d | 2017-08-15 10:50:22 -0400 | [diff] [blame^] | 329 | // Returns true if successful. |
| 330 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetRect(FPDF_ANNOTATION annot, |
| 331 | FS_RECTF* rect); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 332 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 333 | // Experimental API. |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 334 | // Check if |annot|'s dictionary has |key| as a key. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 335 | // |
| 336 | // annot - handle to an annotation. |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 337 | // key - the key to look for. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 338 | // |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 339 | // Returns true if |key| exists. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 340 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_HasKey(FPDF_ANNOTATION annot, |
| 341 | FPDF_WIDESTRING key); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 342 | |
Jane Liu | 3656774 | 2017-07-06 11:13:35 -0400 | [diff] [blame] | 343 | // Experimental API. |
Jane Liu | 57f228d | 2017-07-13 18:10:30 -0400 | [diff] [blame] | 344 | // 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] | 345 | // |
| 346 | // annot - handle to an annotation. |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 347 | // key - the key to look for. |
| 348 | // |
| 349 | // Returns the type of the dictionary value. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 350 | FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV |
| 351 | FPDFAnnot_GetValueType(FPDF_ANNOTATION annot, FPDF_WIDESTRING key); |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 352 | |
| 353 | // Experimental API. |
| 354 | // Set the string value corresponding to |key| in |annot|'s dictionary, |
| 355 | // overwriting the existing value if any. The value type would be |
Jane Liu | 57f228d | 2017-07-13 18:10:30 -0400 | [diff] [blame] | 356 | // FPDF_OBJECT_STRING after this function call succeeds. |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 357 | // |
| 358 | // annot - handle to an annotation. |
| 359 | // key - the key to the dictionary entry to be set, encoded in UTF16-LE. |
| 360 | // value - the string value to be set, encoded in UTF16-LE. |
| 361 | // |
| 362 | // Returns true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 363 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV |
| 364 | FPDFAnnot_SetStringValue(FPDF_ANNOTATION annot, |
| 365 | FPDF_WIDESTRING key, |
| 366 | FPDF_WIDESTRING value); |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 367 | |
| 368 | // Experimental API. |
| 369 | // Get the string value corresponding to |key| in |annot|'s dictionary. |buffer| |
| 370 | // is only modified if |buflen| is longer than the length of contents. Note that |
| 371 | // if |key| does not exist in the dictionary or if |key|'s corresponding value |
| 372 | // in the dictionary is not a string (i.e. the value is not of type |
| 373 | // FPDF_OBJECT_STRING or FPDF_OBJECT_NAME), then an empty string would be copied |
| 374 | // to |buffer| and the return value would be 2. On other errors, nothing would |
| 375 | // be added to |buffer| and the return value would be 0. |
| 376 | // |
| 377 | // annot - handle to an annotation. |
| 378 | // key - the key to the requested dictionary entry. |
| 379 | // buffer - buffer for holding the value string, encoded in UTF16-LE. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 380 | // buflen - length of the buffer. |
| 381 | // |
Jane Liu | 2e1a32b | 2017-07-06 12:01:25 -0400 | [diff] [blame] | 382 | // Returns the length of the string value. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 383 | FPDF_EXPORT unsigned long FPDF_CALLCONV |
| 384 | FPDFAnnot_GetStringValue(FPDF_ANNOTATION annot, |
| 385 | FPDF_WIDESTRING key, |
| 386 | void* buffer, |
| 387 | unsigned long buflen); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 388 | |
Jane Liu | b137e75 | 2017-07-05 15:04:33 -0400 | [diff] [blame] | 389 | // Experimental API. |
| 390 | // Get the annotation flags of |annot|. |
| 391 | // |
| 392 | // annot - handle to an annotation. |
| 393 | // |
| 394 | // Returns the annotation flags. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 395 | FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetFlags(FPDF_ANNOTATION annot); |
Jane Liu | b137e75 | 2017-07-05 15:04:33 -0400 | [diff] [blame] | 396 | |
| 397 | // Experimental API. |
| 398 | // Set the |annot|'s flags to be of the value |flags|. |
| 399 | // |
| 400 | // annot - handle to an annotation. |
| 401 | // flags - the flag values to be set. |
| 402 | // |
| 403 | // Returns true if successful. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 404 | FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetFlags(FPDF_ANNOTATION annot, |
| 405 | int flags); |
Jane Liu | b137e75 | 2017-07-05 15:04:33 -0400 | [diff] [blame] | 406 | |
Diana Gage | 7e0c05d | 2017-07-19 17:33:33 -0700 | [diff] [blame] | 407 | // Experimental API. |
| 408 | // Get the annotation flags of |annot|, which is an interactive form |
| 409 | // annotation in |page|. |
| 410 | // |
| 411 | // page - handle to a page. |
| 412 | // annot - handle to an interactive form annotation. |
| 413 | // |
| 414 | // Returns the annotation flags specific to interactive forms. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 415 | FPDF_EXPORT int FPDF_CALLCONV |
| 416 | FPDFAnnot_GetFormFieldFlags(FPDF_PAGE page, FPDF_ANNOTATION annot); |
Diana Gage | 7e0c05d | 2017-07-19 17:33:33 -0700 | [diff] [blame] | 417 | |
Diana Gage | 40870db | 2017-07-19 18:16:03 -0700 | [diff] [blame] | 418 | // Experimental API. |
| 419 | // Retrieves an interactive form annotation whose rectangle contains a given |
| 420 | // point on a page. Must call FPDFPage_CloseAnnot() when the annotation returned |
| 421 | // is no longer needed. |
| 422 | // |
| 423 | // |
| 424 | // hHandle - handle to the form fill module, returned by |
| 425 | // FPDFDOC_InitFormFillEnvironment. |
| 426 | // page - handle to the page, returned by FPDF_LoadPage function. |
| 427 | // page_x - X position in PDF "user space". |
| 428 | // page_y - Y position in PDF "user space". |
| 429 | // |
| 430 | // Returns the interactive form annotation whose rectangle contains the given |
| 431 | // coordinates on the page. If there is no such annotation, return NULL. |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 432 | FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV |
Diana Gage | 40870db | 2017-07-19 18:16:03 -0700 | [diff] [blame] | 433 | FPDFAnnot_GetFormFieldAtPoint(FPDF_FORMHANDLE hHandle, |
| 434 | FPDF_PAGE page, |
| 435 | double page_x, |
| 436 | double page_y); |
| 437 | |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 438 | #ifdef __cplusplus |
| 439 | } // extern "C" |
| 440 | #endif // __cplusplus |
| 441 | |
| 442 | #endif // PUBLIC_FPDF_ANNOT_H_ |