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 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
| 7 | #ifndef PUBLIC_FPDF_ANNOT_H_ |
| 8 | #define PUBLIC_FPDF_ANNOT_H_ |
| 9 | |
| 10 | // NOLINTNEXTLINE(build/include) |
| 11 | #include "fpdfview.h" |
| 12 | |
| 13 | #include "public/fpdf_doc.h" |
| 14 | |
| 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif // __cplusplus |
| 18 | |
| 19 | #define FPDF_ANNOT_UNKNOWN 0 |
| 20 | #define FPDF_ANNOT_TEXT 1 |
| 21 | #define FPDF_ANNOT_LINK 2 |
| 22 | #define FPDF_ANNOT_FREETEXT 3 |
| 23 | #define FPDF_ANNOT_LINE 4 |
| 24 | #define FPDF_ANNOT_SQUARE 5 |
| 25 | #define FPDF_ANNOT_CIRCLE 6 |
| 26 | #define FPDF_ANNOT_POLYGON 7 |
| 27 | #define FPDF_ANNOT_POLYLINE 8 |
| 28 | #define FPDF_ANNOT_HIGHLIGHT 9 |
| 29 | #define FPDF_ANNOT_UNDERLINE 10 |
| 30 | #define FPDF_ANNOT_SQUIGGLY 11 |
| 31 | #define FPDF_ANNOT_STRIKEOUT 12 |
| 32 | #define FPDF_ANNOT_STAMP 13 |
| 33 | #define FPDF_ANNOT_CARET 14 |
| 34 | #define FPDF_ANNOT_INK 15 |
| 35 | #define FPDF_ANNOT_POPUP 16 |
| 36 | #define FPDF_ANNOT_FILEATTACHMENT 17 |
| 37 | #define FPDF_ANNOT_SOUND 18 |
| 38 | #define FPDF_ANNOT_MOVIE 19 |
| 39 | #define FPDF_ANNOT_WIDGET 20 |
| 40 | #define FPDF_ANNOT_SCREEN 21 |
| 41 | #define FPDF_ANNOT_PRINTERMARK 22 |
| 42 | #define FPDF_ANNOT_TRAPNET 23 |
| 43 | #define FPDF_ANNOT_WATERMARK 24 |
| 44 | #define FPDF_ANNOT_THREED 25 |
| 45 | #define FPDF_ANNOT_RICHMEDIA 26 |
| 46 | #define FPDF_ANNOT_XFAWIDGET 27 |
| 47 | |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 48 | typedef enum FPDFANNOT_COLORTYPE { |
| 49 | FPDFANNOT_COLORTYPE_Color = 0, |
| 50 | FPDFANNOT_COLORTYPE_InteriorColor |
| 51 | } FPDFANNOT_COLORTYPE; |
| 52 | |
| 53 | typedef enum FPDFANNOT_TEXTTYPE { |
| 54 | FPDFANNOT_TEXTTYPE_Contents = 0, |
| 55 | FPDFANNOT_TEXTTYPE_Author |
| 56 | } FPDFANNOT_TEXTTYPE; |
| 57 | |
| 58 | // Check if an annotation subtype is currently supported for creating and |
| 59 | // displaying. The supported subtypes must be consistent with the ones supported |
| 60 | // by AP generation - see the list of calls to CPVT_GenerateAP::Generate*AP() in |
| 61 | // CPDF_Annot::GenerateAPIfNeeded(). |
| 62 | // |
| 63 | // subtype - the subtype to be checked. |
| 64 | // |
| 65 | // Returns true if this subtype supported, false otherwise. |
| 66 | DLLEXPORT FPDF_BOOL STDCALL |
| 67 | FPDFAnnot_IsSupportedSubtype(FPDF_ANNOTATION_SUBTYPE subtype); |
| 68 | |
| 69 | // Create an annotation in |page| of the subtype |subtype|. If the specified |
| 70 | // subtype is illegal or unsupported, then a new annotation will not be created. |
| 71 | // |
| 72 | // page - handle to a page. |
| 73 | // subtype - the subtype of the new annotation. |
| 74 | // annot - receives the newly created annotation. |
| 75 | // |
| 76 | // Returns true if successful, false otherwise. |
| 77 | DLLEXPORT FPDF_BOOL STDCALL |
| 78 | FPDFPage_CreateAnnot(FPDF_PAGE page, |
| 79 | FPDF_ANNOTATION_SUBTYPE subtype, |
| 80 | FPDF_ANNOTATION* annot); |
| 81 | |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 82 | // Get the number of annotations in |page|. |
| 83 | // |
| 84 | // page - handle to a page. |
| 85 | // |
| 86 | // Returns the number of annotations in |page|. |
| 87 | DLLEXPORT int STDCALL FPDFPage_GetAnnotCount(FPDF_PAGE page); |
| 88 | |
| 89 | // Get annotation in |page| at |index|. |
| 90 | // |
| 91 | // page - handle to a page. |
| 92 | // index - the index of the annotation. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 93 | // annot - receives the annotation. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 94 | // |
| 95 | // Returns true if successful, false otherwise. |
| 96 | DLLEXPORT FPDF_BOOL STDCALL FPDFPage_GetAnnot(FPDF_PAGE page, |
| 97 | int index, |
| 98 | FPDF_ANNOTATION* annot); |
| 99 | |
Jane Liu | e10509a | 2017-06-20 16:47:41 -0400 | [diff] [blame] | 100 | // Close an annotation. Must be called when the annotation returned by |
| 101 | // FPDFPage_CreateAnnot() or FPDFPage_GetAnnot() is no longer needed. This |
| 102 | // function does not remove the annotation from the document. |
| 103 | // |
| 104 | // annot - handle to an annotation. |
| 105 | DLLEXPORT void STDCALL FPDFPage_CloseAnnot(FPDF_ANNOTATION annot); |
| 106 | |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 107 | // Get the subtype of an annotation. |
| 108 | // |
| 109 | // annot - handle to an annotation. |
| 110 | // |
| 111 | // Returns the annotation subtype. |
| 112 | DLLEXPORT FPDF_ANNOTATION_SUBTYPE STDCALL |
| 113 | FPDFAnnot_GetSubtype(FPDF_ANNOTATION annot); |
| 114 | |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 115 | // Set the color of an annotation. |
| 116 | // |
| 117 | // annot - handle to an annotation. |
| 118 | // type - type of the color to be set. |
| 119 | // R, G, B - buffer to hold the RGB value of the color. Ranges from 0 to 255. |
| 120 | // A - buffer to hold the opacity. Ranges from 0 to 255. |
| 121 | // |
| 122 | // Returns true if successful, false otherwise. |
| 123 | DLLEXPORT FPDF_BOOL STDCALL FPDFAnnot_SetColor(FPDF_ANNOTATION annot, |
| 124 | FPDFANNOT_COLORTYPE type, |
| 125 | unsigned int R, |
| 126 | unsigned int G, |
| 127 | unsigned int B, |
| 128 | unsigned int A); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 129 | |
| 130 | // Get the color of an annotation. If no color is specified, default to yellow |
| 131 | // for highlight annotation, black for all else. |
| 132 | // |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 133 | // annot - handle to an annotation. |
| 134 | // type - type of the color requested. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 135 | // 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] | 136 | // A - buffer to hold the opacity. Ranges from 0 to 255. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 137 | // |
| 138 | // Returns true if successful, false otherwise. |
| 139 | DLLEXPORT FPDF_BOOL STDCALL FPDFAnnot_GetColor(FPDF_ANNOTATION annot, |
| 140 | FPDFANNOT_COLORTYPE type, |
| 141 | unsigned int* R, |
| 142 | unsigned int* G, |
| 143 | unsigned int* B, |
| 144 | unsigned int* A); |
| 145 | |
| 146 | // Check if the annotation is of a type that has attachment points |
| 147 | // (i.e. quadpoints). Quadpoints are the vertices of the rectange that |
| 148 | // encompasses the texts affected by the annotation. They provide the |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 149 | // coordinates in the page where the annotation is attached. Only text markup |
| 150 | // annotations (i.e. highlight, strikeout, squiggly, and underline) and link |
| 151 | // annotations have quadpoints. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 152 | // |
| 153 | // annot - handle to an annotation. |
| 154 | // |
| 155 | // Returns true if the annotation is of a type that has quadpoints, false |
| 156 | // otherwise. |
| 157 | DLLEXPORT FPDF_BOOL STDCALL |
| 158 | FPDFAnnot_HasAttachmentPoints(FPDF_ANNOTATION annot); |
| 159 | |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 160 | // Set the attachment points (i.e. quadpoints) of an annotation. |
| 161 | // |
| 162 | // annot - handle to an annotation. |
| 163 | // quadPoints - the quadpoints to be set. |
| 164 | // |
| 165 | // Returns true if successful, false otherwise. |
| 166 | DLLEXPORT FPDF_BOOL STDCALL |
| 167 | FPDFAnnot_SetAttachmentPoints(FPDF_ANNOTATION annot, FS_QUADPOINTSF quadPoints); |
| 168 | |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 169 | // Get the attachment points (i.e. quadpoints) of an annotation. |
| 170 | // |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 171 | // annot - handle to an annotation. |
| 172 | // quadPoints - receives the attachment points. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 173 | // |
| 174 | // Returns true if successful, false otherwise. |
| 175 | DLLEXPORT FPDF_BOOL STDCALL |
| 176 | FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot, |
| 177 | FS_QUADPOINTSF* quadPoints); |
| 178 | |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 179 | // Set the annotation rectangle defining the location of the annotation. |
| 180 | // |
| 181 | // annot - handle to an annotation. |
| 182 | // rect - the annotation rectangle to be set. |
| 183 | // |
| 184 | // Returns true if successful, false otherwise. |
| 185 | DLLEXPORT FPDF_BOOL STDCALL FPDFAnnot_SetRect(FPDF_ANNOTATION annot, |
| 186 | FS_RECTF rect); |
| 187 | |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 188 | // Get the annotation rectangle defining the location of the annotation. |
| 189 | // |
| 190 | // annot - handle to an annotation. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 191 | // rect - receives the annotation rectangle. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 192 | // |
| 193 | // Returns true if successful, false otherwise. |
| 194 | DLLEXPORT FPDF_BOOL STDCALL FPDFAnnot_GetRect(FPDF_ANNOTATION annot, |
| 195 | FS_RECTF* rect); |
| 196 | |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 197 | // Set the contents of an annotation. |
| 198 | // |
| 199 | // annot - handle to an annotation. |
| 200 | // type - type of the text to be set. |
| 201 | // text - the text to be set. |
| 202 | // |
| 203 | // Returns true if successful, false otherwise. |
| 204 | DLLEXPORT FPDF_BOOL STDCALL FPDFAnnot_SetText(FPDF_ANNOTATION annot, |
| 205 | FPDFANNOT_TEXTTYPE type, |
| 206 | FPDF_WIDESTRING text); |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 207 | |
| 208 | // Get the contents of an annotation. |buffer| is only modified if |buflen| |
| 209 | // is longer than the length of contents. |
| 210 | // |
| 211 | // annot - handle to an annotation. |
Jane Liu | 20eafda | 2017-06-07 10:33:24 -0400 | [diff] [blame] | 212 | // type - type of the text requested. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 213 | // buffer - buffer for holding the contents string, encoded in UTF16-LE. |
| 214 | // buflen - length of the buffer. |
| 215 | // |
| 216 | // Returns the length of the contents. |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 217 | DLLEXPORT unsigned long STDCALL FPDFAnnot_GetText(FPDF_ANNOTATION annot, |
| 218 | FPDFANNOT_TEXTTYPE type, |
Jane Liu | 262cf46 | 2017-06-09 11:36:37 -0400 | [diff] [blame] | 219 | void* buffer, |
Jane Liu | 4fd9a47 | 2017-06-01 18:56:09 -0400 | [diff] [blame] | 220 | unsigned long buflen); |
| 221 | |
| 222 | #ifdef __cplusplus |
| 223 | } // extern "C" |
| 224 | #endif // __cplusplus |
| 225 | |
| 226 | #endif // PUBLIC_FPDF_ANNOT_H_ |