blob: 1de99453fc88d1b1b2793ea1aacac6622c258874 [file] [log] [blame]
Jane Liu4fd9a472017-06-01 18:56:09 -04001// 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 Liu4fd9a472017-06-01 18:56:09 -04005#ifndef PUBLIC_FPDF_ANNOT_H_
6#define PUBLIC_FPDF_ANNOT_H_
7
8// NOLINTNEXTLINE(build/include)
9#include "fpdfview.h"
10
Dan Sinclair00d2ad12017-08-10 14:13:02 -040011// NOLINTNEXTLINE(build/include)
Jane Liuc5ea6302017-07-18 19:31:42 -040012#include "fpdf_doc.h"
Dan Sinclair00d2ad12017-08-10 14:13:02 -040013// NOLINTNEXTLINE(build/include)
Diana Gage40870db2017-07-19 18:16:03 -070014#include "fpdf_formfill.h"
Jane Liu4fd9a472017-06-01 18:56:09 -040015
16#ifdef __cplusplus
17extern "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 Liub137e752017-07-05 15:04:33 -040049// 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 Gage7e0c05d2017-07-19 17:33:33 -070061#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 Liu20eafda2017-06-07 10:33:24 -040088typedef enum FPDFANNOT_COLORTYPE {
89 FPDFANNOT_COLORTYPE_Color = 0,
90 FPDFANNOT_COLORTYPE_InteriorColor
91} FPDFANNOT_COLORTYPE;
92
Jane Liu36567742017-07-06 11:13:35 -040093// Experimental API.
Jane Liubaa7ff42017-06-29 19:18:23 -040094// 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 Liu20eafda2017-06-07 10:33:24 -040097//
98// subtype - the subtype to be checked.
99//
Jane Liu8ce58f52017-06-29 13:40:22 -0400100// Returns true if this subtype supported.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400101FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Jane Liu20eafda2017-06-07 10:33:24 -0400102FPDFAnnot_IsSupportedSubtype(FPDF_ANNOTATION_SUBTYPE subtype);
103
Jane Liu36567742017-07-06 11:13:35 -0400104// Experimental API.
Jane Liu20eafda2017-06-07 10:33:24 -0400105// 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 Liubaa7ff42017-06-29 19:18:23 -0400107// Must call FPDFPage_CloseAnnot() when the annotation returned by this
108// function is no longer needed.
Jane Liu20eafda2017-06-07 10:33:24 -0400109//
110// page - handle to a page.
111// subtype - the subtype of the new annotation.
Jane Liu20eafda2017-06-07 10:33:24 -0400112//
Jane Liud60e9ad2017-06-26 11:28:36 -0400113// Returns a handle to the new annotation object, or NULL on failure.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400114FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV
Jane Liud60e9ad2017-06-26 11:28:36 -0400115FPDFPage_CreateAnnot(FPDF_PAGE page, FPDF_ANNOTATION_SUBTYPE subtype);
Jane Liu20eafda2017-06-07 10:33:24 -0400116
Jane Liu36567742017-07-06 11:13:35 -0400117// Experimental API.
Jane Liu4fd9a472017-06-01 18:56:09 -0400118// Get the number of annotations in |page|.
119//
120// page - handle to a page.
121//
122// Returns the number of annotations in |page|.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400123FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetAnnotCount(FPDF_PAGE page);
Jane Liu4fd9a472017-06-01 18:56:09 -0400124
Jane Liu36567742017-07-06 11:13:35 -0400125// Experimental API.
Jane Liubaa7ff42017-06-29 19:18:23 -0400126// Get annotation in |page| at |index|. Must call FPDFPage_CloseAnnot() when the
127// annotation returned by this function is no longer needed.
Jane Liu4fd9a472017-06-01 18:56:09 -0400128//
129// page - handle to a page.
130// index - the index of the annotation.
Jane Liu4fd9a472017-06-01 18:56:09 -0400131//
Jane Liud60e9ad2017-06-26 11:28:36 -0400132// Returns a handle to the annotation object, or NULL on failure.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400133FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV FPDFPage_GetAnnot(FPDF_PAGE page,
134 int index);
Jane Liu4fd9a472017-06-01 18:56:09 -0400135
Jane Liu36567742017-07-06 11:13:35 -0400136// Experimental API.
Jane Liue10509a2017-06-20 16:47:41 -0400137// 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 Sinclair00d2ad12017-08-10 14:13:02 -0400142FPDF_EXPORT void FPDF_CALLCONV FPDFPage_CloseAnnot(FPDF_ANNOTATION annot);
Jane Liue10509a2017-06-20 16:47:41 -0400143
Jane Liu36567742017-07-06 11:13:35 -0400144// Experimental API.
Jane Liu8ce58f52017-06-29 13:40:22 -0400145// 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 Sinclair00d2ad12017-08-10 14:13:02 -0400151FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_RemoveAnnot(FPDF_PAGE page,
152 int index);
Jane Liu8ce58f52017-06-29 13:40:22 -0400153
Jane Liu36567742017-07-06 11:13:35 -0400154// Experimental API.
Jane Liu4fd9a472017-06-01 18:56:09 -0400155// Get the subtype of an annotation.
156//
157// annot - handle to an annotation.
158//
159// Returns the annotation subtype.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400160FPDF_EXPORT FPDF_ANNOTATION_SUBTYPE FPDF_CALLCONV
Jane Liu4fd9a472017-06-01 18:56:09 -0400161FPDFAnnot_GetSubtype(FPDF_ANNOTATION annot);
162
Jane Liubaa7ff42017-06-29 19:18:23 -0400163// Experimental API.
Jane Liu7a9a38b2017-07-11 13:47:37 -0400164// 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 Sinclair00d2ad12017-08-10 14:13:02 -0400171FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Jane Liu7a9a38b2017-07-11 13:47:37 -0400172FPDFAnnot_IsObjectSupportedSubtype(FPDF_ANNOTATION_SUBTYPE subtype);
173
174// Experimental API.
Jane Liu36567742017-07-06 11:13:35 -0400175// 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 Liubaa7ff42017-06-29 19:18:23 -0400180//
181// annot - handle to an annotation.
Jane Liu36567742017-07-06 11:13:35 -0400182// obj - handle to the object that |annot| needs to update.
Jane Liubaa7ff42017-06-29 19:18:23 -0400183//
184// Return true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400185FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
186FPDFAnnot_UpdateObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj);
Jane Liubaa7ff42017-06-29 19:18:23 -0400187
188// Experimental API.
Jane Liu36567742017-07-06 11:13:35 -0400189// 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 Liubaa7ff42017-06-29 19:18:23 -0400194//
195// annot - handle to an annotation.
Jane Liu36567742017-07-06 11:13:35 -0400196// obj - handle to the object that is to be added to |annot|.
Jane Liubaa7ff42017-06-29 19:18:23 -0400197//
198// Return true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400199FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
200FPDFAnnot_AppendObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj);
Jane Liubaa7ff42017-06-29 19:18:23 -0400201
202// Experimental API.
Jane Liu36567742017-07-06 11:13:35 -0400203// Get the total number of objects in |annot|, including path objects, text
204// objects, external objects, image objects, and shading objects.
Jane Liubaa7ff42017-06-29 19:18:23 -0400205//
206// annot - handle to an annotation.
207//
Jane Liu36567742017-07-06 11:13:35 -0400208// Returns the number of objects in |annot|.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400209FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetObjectCount(FPDF_ANNOTATION annot);
Jane Liubaa7ff42017-06-29 19:18:23 -0400210
211// Experimental API.
Jane Liu36567742017-07-06 11:13:35 -0400212// Get the object in |annot| at |index|.
Jane Liubaa7ff42017-06-29 19:18:23 -0400213//
214// annot - handle to an annotation.
Jane Liu36567742017-07-06 11:13:35 -0400215// index - the index of the object.
Jane Liubaa7ff42017-06-29 19:18:23 -0400216//
Jane Liu36567742017-07-06 11:13:35 -0400217// Return a handle to the object, or NULL on failure.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400218FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
219FPDFAnnot_GetObject(FPDF_ANNOTATION annot, int index);
Jane Liubaa7ff42017-06-29 19:18:23 -0400220
Jane Liu36567742017-07-06 11:13:35 -0400221// Experimental API.
Jane Liu7a9a38b2017-07-11 13:47:37 -0400222// 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 Sinclair00d2ad12017-08-10 14:13:02 -0400228FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
229FPDFAnnot_RemoveObject(FPDF_ANNOTATION annot, int index);
Jane Liu7a9a38b2017-07-11 13:47:37 -0400230
231// Experimental API.
Jane Liu06462752017-06-27 16:41:14 -0400232// 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 Liu20eafda2017-06-07 10:33:24 -0400235//
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 Liu8ce58f52017-06-29 13:40:22 -0400241// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400242FPDF_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 Liu4fd9a472017-06-01 18:56:09 -0400248
Jane Liu36567742017-07-06 11:13:35 -0400249// Experimental API.
Jane Liu4fd9a472017-06-01 18:56:09 -0400250// Get the color of an annotation. If no color is specified, default to yellow
Jane Liu06462752017-06-27 16:41:14 -0400251// 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 Liu4fd9a472017-06-01 18:56:09 -0400254//
Jane Liu20eafda2017-06-07 10:33:24 -0400255// annot - handle to an annotation.
256// type - type of the color requested.
Jane Liu4fd9a472017-06-01 18:56:09 -0400257// R, G, B - buffer to hold the RGB value of the color. Ranges from 0 to 255.
Jane Liu20eafda2017-06-07 10:33:24 -0400258// A - buffer to hold the opacity. Ranges from 0 to 255.
Jane Liu4fd9a472017-06-01 18:56:09 -0400259//
Jane Liu8ce58f52017-06-29 13:40:22 -0400260// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400261FPDF_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 Liu4fd9a472017-06-01 18:56:09 -0400267
Jane Liu36567742017-07-06 11:13:35 -0400268// Experimental API.
Jane Liu4fd9a472017-06-01 18:56:09 -0400269// 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 Liu20eafda2017-06-07 10:33:24 -0400272// 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 Liu4fd9a472017-06-01 18:56:09 -0400275//
276// annot - handle to an annotation.
277//
278// Returns true if the annotation is of a type that has quadpoints, false
279// otherwise.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400280FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Jane Liu4fd9a472017-06-01 18:56:09 -0400281FPDFAnnot_HasAttachmentPoints(FPDF_ANNOTATION annot);
282
Jane Liu36567742017-07-06 11:13:35 -0400283// Experimental API.
Jane Liu06462752017-06-27 16:41:14 -0400284// 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 Liu20eafda2017-06-07 10:33:24 -0400287//
288// annot - handle to an annotation.
289// quadPoints - the quadpoints to be set.
290//
Jane Liu8ce58f52017-06-29 13:40:22 -0400291// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400292FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Jane Liu06462752017-06-27 16:41:14 -0400293FPDFAnnot_SetAttachmentPoints(FPDF_ANNOTATION annot,
294 const FS_QUADPOINTSF* quadPoints);
Jane Liu20eafda2017-06-07 10:33:24 -0400295
Jane Liu36567742017-07-06 11:13:35 -0400296// Experimental API.
Jane Liu06462752017-06-27 16:41:14 -0400297// 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 Liu4fd9a472017-06-01 18:56:09 -0400300//
Jane Liu20eafda2017-06-07 10:33:24 -0400301// annot - handle to an annotation.
Jane Liu0c6b07d2017-08-15 10:50:22 -0400302// quadPoints - receives the quadpoints; must not be NULL.
Jane Liu4fd9a472017-06-01 18:56:09 -0400303//
Jane Liu0c6b07d2017-08-15 10:50:22 -0400304// Returns true if successful.
305FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
306FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot,
307 FS_QUADPOINTSF* quadPoints);
Jane Liu4fd9a472017-06-01 18:56:09 -0400308
Jane Liu36567742017-07-06 11:13:35 -0400309// Experimental API.
Jane Liu06462752017-06-27 16:41:14 -0400310// 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 Liu20eafda2017-06-07 10:33:24 -0400313//
314// annot - handle to an annotation.
315// rect - the annotation rectangle to be set.
316//
Jane Liu8ce58f52017-06-29 13:40:22 -0400317// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400318FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetRect(FPDF_ANNOTATION annot,
319 const FS_RECTF* rect);
Jane Liu20eafda2017-06-07 10:33:24 -0400320
Jane Liu36567742017-07-06 11:13:35 -0400321// Experimental API.
Jane Liu06462752017-06-27 16:41:14 -0400322// 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 Liu4fd9a472017-06-01 18:56:09 -0400325//
326// annot - handle to an annotation.
Jane Liu0c6b07d2017-08-15 10:50:22 -0400327// rect - receives the rectangle; must not be NULL.
Jane Liu4fd9a472017-06-01 18:56:09 -0400328//
Jane Liu0c6b07d2017-08-15 10:50:22 -0400329// Returns true if successful.
330FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetRect(FPDF_ANNOTATION annot,
331 FS_RECTF* rect);
Jane Liu4fd9a472017-06-01 18:56:09 -0400332
Jane Liu36567742017-07-06 11:13:35 -0400333// Experimental API.
Jane Liu2e1a32b2017-07-06 12:01:25 -0400334// Check if |annot|'s dictionary has |key| as a key.
Jane Liu20eafda2017-06-07 10:33:24 -0400335//
336// annot - handle to an annotation.
Jane Liu2e1a32b2017-07-06 12:01:25 -0400337// key - the key to look for.
Jane Liu20eafda2017-06-07 10:33:24 -0400338//
Jane Liu2e1a32b2017-07-06 12:01:25 -0400339// Returns true if |key| exists.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400340FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_HasKey(FPDF_ANNOTATION annot,
341 FPDF_WIDESTRING key);
Jane Liu4fd9a472017-06-01 18:56:09 -0400342
Jane Liu36567742017-07-06 11:13:35 -0400343// Experimental API.
Jane Liu57f228d2017-07-13 18:10:30 -0400344// Get the type of the value corresponding to |key| in |annot|'s dictionary.
Jane Liu4fd9a472017-06-01 18:56:09 -0400345//
346// annot - handle to an annotation.
Jane Liu2e1a32b2017-07-06 12:01:25 -0400347// key - the key to look for.
348//
349// Returns the type of the dictionary value.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400350FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV
351FPDFAnnot_GetValueType(FPDF_ANNOTATION annot, FPDF_WIDESTRING key);
Jane Liu2e1a32b2017-07-06 12:01:25 -0400352
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 Liu57f228d2017-07-13 18:10:30 -0400356// FPDF_OBJECT_STRING after this function call succeeds.
Jane Liu2e1a32b2017-07-06 12:01:25 -0400357//
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 Sinclair00d2ad12017-08-10 14:13:02 -0400363FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
364FPDFAnnot_SetStringValue(FPDF_ANNOTATION annot,
365 FPDF_WIDESTRING key,
366 FPDF_WIDESTRING value);
Jane Liu2e1a32b2017-07-06 12:01:25 -0400367
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 Liu4fd9a472017-06-01 18:56:09 -0400380// buflen - length of the buffer.
381//
Jane Liu2e1a32b2017-07-06 12:01:25 -0400382// Returns the length of the string value.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400383FPDF_EXPORT unsigned long FPDF_CALLCONV
384FPDFAnnot_GetStringValue(FPDF_ANNOTATION annot,
385 FPDF_WIDESTRING key,
386 void* buffer,
387 unsigned long buflen);
Jane Liu4fd9a472017-06-01 18:56:09 -0400388
Jane Liub137e752017-07-05 15:04:33 -0400389// Experimental API.
390// Get the annotation flags of |annot|.
391//
392// annot - handle to an annotation.
393//
394// Returns the annotation flags.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400395FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetFlags(FPDF_ANNOTATION annot);
Jane Liub137e752017-07-05 15:04:33 -0400396
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 Sinclair00d2ad12017-08-10 14:13:02 -0400404FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetFlags(FPDF_ANNOTATION annot,
405 int flags);
Jane Liub137e752017-07-05 15:04:33 -0400406
Diana Gage7e0c05d2017-07-19 17:33:33 -0700407// 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 Sinclair00d2ad12017-08-10 14:13:02 -0400415FPDF_EXPORT int FPDF_CALLCONV
416FPDFAnnot_GetFormFieldFlags(FPDF_PAGE page, FPDF_ANNOTATION annot);
Diana Gage7e0c05d2017-07-19 17:33:33 -0700417
Diana Gage40870db2017-07-19 18:16:03 -0700418// 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 Sinclair00d2ad12017-08-10 14:13:02 -0400432FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV
Diana Gage40870db2017-07-19 18:16:03 -0700433FPDFAnnot_GetFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
434 FPDF_PAGE page,
435 double page_x,
436 double page_y);
437
Jane Liu4fd9a472017-06-01 18:56:09 -0400438#ifdef __cplusplus
439} // extern "C"
440#endif // __cplusplus
441
442#endif // PUBLIC_FPDF_ANNOT_H_