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