blob: ef30d9a2e0d6f9ae709f3751e48d8fb5bf35ff6b [file] [log] [blame]
K. Moon832a6942022-10-31 20:11:31 +00001// Copyright 2017 The PDFium Authors
Jane Liu4fd9a472017-06-01 18:56:09 -04002// 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
Henrique Nakashima5098b252018-03-26 21:46:00 +00008#include <stddef.h>
9
Jane Liu4fd9a472017-06-01 18:56:09 -040010// NOLINTNEXTLINE(build/include)
11#include "fpdfview.h"
12
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
Miklos Vajnad1a24fb2020-10-26 18:07:13 +000048#define FPDF_ANNOT_REDACT 28
Jane Liu4fd9a472017-06-01 18:56:09 -040049
Jane Liub137e752017-07-05 15:04:33 -040050// Refer to PDF Reference (6th edition) table 8.16 for all annotation flags.
51#define FPDF_ANNOT_FLAG_NONE 0
52#define FPDF_ANNOT_FLAG_INVISIBLE (1 << 0)
53#define FPDF_ANNOT_FLAG_HIDDEN (1 << 1)
54#define FPDF_ANNOT_FLAG_PRINT (1 << 2)
55#define FPDF_ANNOT_FLAG_NOZOOM (1 << 3)
56#define FPDF_ANNOT_FLAG_NOROTATE (1 << 4)
57#define FPDF_ANNOT_FLAG_NOVIEW (1 << 5)
58#define FPDF_ANNOT_FLAG_READONLY (1 << 6)
59#define FPDF_ANNOT_FLAG_LOCKED (1 << 7)
60#define FPDF_ANNOT_FLAG_TOGGLENOVIEW (1 << 8)
61
Henrique Nakashimaa74e75d2018-01-10 18:06:55 +000062#define FPDF_ANNOT_APPEARANCEMODE_NORMAL 0
63#define FPDF_ANNOT_APPEARANCEMODE_ROLLOVER 1
64#define FPDF_ANNOT_APPEARANCEMODE_DOWN 2
65#define FPDF_ANNOT_APPEARANCEMODE_COUNT 3
66
Diana Gage7e0c05d2017-07-19 17:33:33 -070067// Refer to PDF Reference version 1.7 table 8.70 for field flags common to all
68// interactive form field types.
69#define FPDF_FORMFLAG_NONE 0
70#define FPDF_FORMFLAG_READONLY (1 << 0)
71#define FPDF_FORMFLAG_REQUIRED (1 << 1)
72#define FPDF_FORMFLAG_NOEXPORT (1 << 2)
73
74// Refer to PDF Reference version 1.7 table 8.77 for field flags specific to
75// interactive form text fields.
76#define FPDF_FORMFLAG_TEXT_MULTILINE (1 << 12)
Mansi Awasthi0b5da672020-01-23 18:17:18 +000077#define FPDF_FORMFLAG_TEXT_PASSWORD (1 << 13)
Diana Gage7e0c05d2017-07-19 17:33:33 -070078
79// Refer to PDF Reference version 1.7 table 8.79 for field flags specific to
80// interactive form choice fields.
81#define FPDF_FORMFLAG_CHOICE_COMBO (1 << 17)
82#define FPDF_FORMFLAG_CHOICE_EDIT (1 << 18)
Mansi Awasthi2acdf792020-05-12 08:48:04 +000083#define FPDF_FORMFLAG_CHOICE_MULTI_SELECT (1 << 21)
Diana Gage7e0c05d2017-07-19 17:33:33 -070084
Miklos Vajnaf929f2f2022-09-16 20:42:32 +000085// Additional actions type of form field:
86// K, on key stroke, JavaScript action.
87// F, on format, JavaScript action.
88// V, on validate, JavaScript action.
89// C, on calculate, JavaScript action.
90#define FPDF_ANNOT_AACTION_KEY_STROKE 12
91#define FPDF_ANNOT_AACTION_FORMAT 13
92#define FPDF_ANNOT_AACTION_VALIDATE 14
93#define FPDF_ANNOT_AACTION_CALCULATE 15
94
Jane Liu20eafda2017-06-07 10:33:24 -040095typedef enum FPDFANNOT_COLORTYPE {
96 FPDFANNOT_COLORTYPE_Color = 0,
97 FPDFANNOT_COLORTYPE_InteriorColor
98} FPDFANNOT_COLORTYPE;
99
Jane Liu36567742017-07-06 11:13:35 -0400100// Experimental API.
Jane Liubaa7ff42017-06-29 19:18:23 -0400101// Check if an annotation subtype is currently supported for creation.
Lei Zhangf8c518d2021-04-19 17:47:23 +0000102// Currently supported subtypes:
103// - circle
Ivan Odulo1908cfc2024-02-16 21:25:11 +0000104// - fileattachment
Lei Zhangf8c518d2021-04-19 17:47:23 +0000105// - freetext
106// - highlight
107// - ink
108// - link
109// - popup
110// - square,
111// - squiggly
112// - stamp
113// - strikeout
114// - text
115// - underline
Jane Liu20eafda2017-06-07 10:33:24 -0400116//
117// subtype - the subtype to be checked.
118//
Jane Liu8ce58f52017-06-29 13:40:22 -0400119// Returns true if this subtype supported.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400120FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Jane Liu20eafda2017-06-07 10:33:24 -0400121FPDFAnnot_IsSupportedSubtype(FPDF_ANNOTATION_SUBTYPE subtype);
122
Jane Liu36567742017-07-06 11:13:35 -0400123// Experimental API.
Jane Liu20eafda2017-06-07 10:33:24 -0400124// Create an annotation in |page| of the subtype |subtype|. If the specified
125// subtype is illegal or unsupported, then a new annotation will not be created.
Jane Liubaa7ff42017-06-29 19:18:23 -0400126// Must call FPDFPage_CloseAnnot() when the annotation returned by this
127// function is no longer needed.
Jane Liu20eafda2017-06-07 10:33:24 -0400128//
129// page - handle to a page.
130// subtype - the subtype of the new annotation.
Jane Liu20eafda2017-06-07 10:33:24 -0400131//
Jane Liud60e9ad2017-06-26 11:28:36 -0400132// Returns a handle to the new annotation object, or NULL on failure.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400133FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV
Jane Liud60e9ad2017-06-26 11:28:36 -0400134FPDFPage_CreateAnnot(FPDF_PAGE page, FPDF_ANNOTATION_SUBTYPE subtype);
Jane Liu20eafda2017-06-07 10:33:24 -0400135
Jane Liu36567742017-07-06 11:13:35 -0400136// Experimental API.
Jane Liu4fd9a472017-06-01 18:56:09 -0400137// Get the number of annotations in |page|.
138//
139// page - handle to a page.
140//
141// Returns the number of annotations in |page|.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400142FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetAnnotCount(FPDF_PAGE page);
Jane Liu4fd9a472017-06-01 18:56:09 -0400143
Jane Liu36567742017-07-06 11:13:35 -0400144// Experimental API.
Jane Liubaa7ff42017-06-29 19:18:23 -0400145// Get annotation in |page| at |index|. Must call FPDFPage_CloseAnnot() when the
146// annotation returned by this function is no longer needed.
Jane Liu4fd9a472017-06-01 18:56:09 -0400147//
148// page - handle to a page.
149// index - the index of the annotation.
Jane Liu4fd9a472017-06-01 18:56:09 -0400150//
Jane Liud60e9ad2017-06-26 11:28:36 -0400151// Returns a handle to the annotation object, or NULL on failure.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400152FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV FPDFPage_GetAnnot(FPDF_PAGE page,
153 int index);
Jane Liu4fd9a472017-06-01 18:56:09 -0400154
Jane Liu36567742017-07-06 11:13:35 -0400155// Experimental API.
Jane Liud1ed1ce2017-08-24 12:31:10 -0400156// Get the index of |annot| in |page|. This is the opposite of
157// FPDFPage_GetAnnot().
158//
159// page - handle to the page that the annotation is on.
160// annot - handle to an annotation.
161//
162// Returns the index of |annot|, or -1 on failure.
163FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetAnnotIndex(FPDF_PAGE page,
164 FPDF_ANNOTATION annot);
165
166// Experimental API.
Jane Liue10509a2017-06-20 16:47:41 -0400167// Close an annotation. Must be called when the annotation returned by
168// FPDFPage_CreateAnnot() or FPDFPage_GetAnnot() is no longer needed. This
169// function does not remove the annotation from the document.
170//
171// annot - handle to an annotation.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400172FPDF_EXPORT void FPDF_CALLCONV FPDFPage_CloseAnnot(FPDF_ANNOTATION annot);
Jane Liue10509a2017-06-20 16:47:41 -0400173
Jane Liu36567742017-07-06 11:13:35 -0400174// Experimental API.
Jane Liu8ce58f52017-06-29 13:40:22 -0400175// Remove the annotation in |page| at |index|.
176//
177// page - handle to a page.
178// index - the index of the annotation.
179//
180// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400181FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_RemoveAnnot(FPDF_PAGE page,
182 int index);
Jane Liu8ce58f52017-06-29 13:40:22 -0400183
Jane Liu36567742017-07-06 11:13:35 -0400184// Experimental API.
Jane Liu4fd9a472017-06-01 18:56:09 -0400185// Get the subtype of an annotation.
186//
187// annot - handle to an annotation.
188//
189// Returns the annotation subtype.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400190FPDF_EXPORT FPDF_ANNOTATION_SUBTYPE FPDF_CALLCONV
Jane Liu4fd9a472017-06-01 18:56:09 -0400191FPDFAnnot_GetSubtype(FPDF_ANNOTATION annot);
192
Jane Liubaa7ff42017-06-29 19:18:23 -0400193// Experimental API.
Jane Liu7a9a38b2017-07-11 13:47:37 -0400194// Check if an annotation subtype is currently supported for object extraction,
195// update, and removal.
196// Currently supported subtypes: ink and stamp.
197//
198// subtype - the subtype to be checked.
199//
200// Returns true if this subtype supported.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400201FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Jane Liu7a9a38b2017-07-11 13:47:37 -0400202FPDFAnnot_IsObjectSupportedSubtype(FPDF_ANNOTATION_SUBTYPE subtype);
203
204// Experimental API.
Jane Liu36567742017-07-06 11:13:35 -0400205// Update |obj| in |annot|. |obj| must be in |annot| already and must have
206// been retrieved by FPDFAnnot_GetObject(). Currently, only ink and stamp
207// annotations are supported by this API. Also note that only path, image, and
208// text objects have APIs for modification; see FPDFPath_*(), FPDFText_*(), and
209// FPDFImageObj_*().
Jane Liubaa7ff42017-06-29 19:18:23 -0400210//
211// annot - handle to an annotation.
Jane Liu36567742017-07-06 11:13:35 -0400212// obj - handle to the object that |annot| needs to update.
Jane Liubaa7ff42017-06-29 19:18:23 -0400213//
214// Return true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400215FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
216FPDFAnnot_UpdateObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj);
Jane Liubaa7ff42017-06-29 19:18:23 -0400217
218// Experimental API.
Shikha Walia000cf142020-04-07 16:40:10 +0000219// Add a new InkStroke, represented by an array of points, to the InkList of
220// |annot|. The API creates an InkList if one doesn't already exist in |annot|.
Lei Zhang87f35282021-10-18 05:03:08 +0000221// This API works only for ink annotations. Please refer to ISO 32000-1:2008
222// spec, section 12.5.6.13.
Shikha Walia000cf142020-04-07 16:40:10 +0000223//
224// annot - handle to an annotation.
225// points - pointer to a FS_POINTF array representing input points.
226// point_count - number of elements in |points| array. This should not exceed
227// the maximum value that can be represented by an int32_t).
228//
229// Returns the 0-based index at which the new InkStroke is added in the InkList
230// of the |annot|. Returns -1 on failure.
231FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_AddInkStroke(FPDF_ANNOTATION annot,
232 const FS_POINTF* points,
233 size_t point_count);
234
235// Experimental API.
Shikha Waliaf6fd09c2020-04-16 17:38:34 +0000236// Removes an InkList in |annot|.
237// This API works only for ink annotations.
238//
239// annot - handle to an annotation.
240//
241// Return true on successful removal of /InkList entry from context of the
242// non-null ink |annot|. Returns false on failure.
243FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
244FPDFAnnot_RemoveInkList(FPDF_ANNOTATION annot);
245
246// Experimental API.
Jane Liu36567742017-07-06 11:13:35 -0400247// Add |obj| to |annot|. |obj| must have been created by
248// FPDFPageObj_CreateNew{Path|Rect}() or FPDFPageObj_New{Text|Image}Obj(), and
249// will be owned by |annot|. Note that an |obj| cannot belong to more than one
250// |annot|. Currently, only ink and stamp annotations are supported by this API.
251// Also note that only path, image, and text objects have APIs for creation.
Jane Liubaa7ff42017-06-29 19:18:23 -0400252//
253// annot - handle to an annotation.
Jane Liu36567742017-07-06 11:13:35 -0400254// obj - handle to the object that is to be added to |annot|.
Jane Liubaa7ff42017-06-29 19:18:23 -0400255//
256// Return true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400257FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
258FPDFAnnot_AppendObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj);
Jane Liubaa7ff42017-06-29 19:18:23 -0400259
260// Experimental API.
Jane Liu36567742017-07-06 11:13:35 -0400261// Get the total number of objects in |annot|, including path objects, text
262// objects, external objects, image objects, and shading objects.
Jane Liubaa7ff42017-06-29 19:18:23 -0400263//
264// annot - handle to an annotation.
265//
Jane Liu36567742017-07-06 11:13:35 -0400266// Returns the number of objects in |annot|.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400267FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetObjectCount(FPDF_ANNOTATION annot);
Jane Liubaa7ff42017-06-29 19:18:23 -0400268
269// Experimental API.
Jane Liu36567742017-07-06 11:13:35 -0400270// Get the object in |annot| at |index|.
Jane Liubaa7ff42017-06-29 19:18:23 -0400271//
272// annot - handle to an annotation.
Jane Liu36567742017-07-06 11:13:35 -0400273// index - the index of the object.
Jane Liubaa7ff42017-06-29 19:18:23 -0400274//
Jane Liu36567742017-07-06 11:13:35 -0400275// Return a handle to the object, or NULL on failure.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400276FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
277FPDFAnnot_GetObject(FPDF_ANNOTATION annot, int index);
Jane Liubaa7ff42017-06-29 19:18:23 -0400278
Jane Liu36567742017-07-06 11:13:35 -0400279// Experimental API.
Jane Liu7a9a38b2017-07-11 13:47:37 -0400280// Remove the object in |annot| at |index|.
281//
282// annot - handle to an annotation.
283// index - the index of the object to be removed.
284//
285// Return true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400286FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
287FPDFAnnot_RemoveObject(FPDF_ANNOTATION annot, int index);
Jane Liu7a9a38b2017-07-11 13:47:37 -0400288
289// Experimental API.
Jane Liu06462752017-06-27 16:41:14 -0400290// Set the color of an annotation. Fails when called on annotations with
291// appearance streams already defined; instead use
292// FPDFPath_Set{Stroke|Fill}Color().
Jane Liu20eafda2017-06-07 10:33:24 -0400293//
294// annot - handle to an annotation.
295// type - type of the color to be set.
296// R, G, B - buffer to hold the RGB value of the color. Ranges from 0 to 255.
297// A - buffer to hold the opacity. Ranges from 0 to 255.
298//
Jane Liu8ce58f52017-06-29 13:40:22 -0400299// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400300FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetColor(FPDF_ANNOTATION annot,
301 FPDFANNOT_COLORTYPE type,
302 unsigned int R,
303 unsigned int G,
304 unsigned int B,
305 unsigned int A);
Jane Liu4fd9a472017-06-01 18:56:09 -0400306
Jane Liu36567742017-07-06 11:13:35 -0400307// Experimental API.
Jane Liu4fd9a472017-06-01 18:56:09 -0400308// Get the color of an annotation. If no color is specified, default to yellow
Jane Liu06462752017-06-27 16:41:14 -0400309// for highlight annotation, black for all else. Fails when called on
310// annotations with appearance streams already defined; instead use
311// FPDFPath_Get{Stroke|Fill}Color().
Jane Liu4fd9a472017-06-01 18:56:09 -0400312//
Jane Liu20eafda2017-06-07 10:33:24 -0400313// annot - handle to an annotation.
314// type - type of the color requested.
Jane Liu4fd9a472017-06-01 18:56:09 -0400315// R, G, B - buffer to hold the RGB value of the color. Ranges from 0 to 255.
Jane Liu20eafda2017-06-07 10:33:24 -0400316// A - buffer to hold the opacity. Ranges from 0 to 255.
Jane Liu4fd9a472017-06-01 18:56:09 -0400317//
Jane Liu8ce58f52017-06-29 13:40:22 -0400318// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400319FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetColor(FPDF_ANNOTATION annot,
320 FPDFANNOT_COLORTYPE type,
321 unsigned int* R,
322 unsigned int* G,
323 unsigned int* B,
324 unsigned int* A);
Jane Liu4fd9a472017-06-01 18:56:09 -0400325
Jane Liu36567742017-07-06 11:13:35 -0400326// Experimental API.
Jane Liu4fd9a472017-06-01 18:56:09 -0400327// Check if the annotation is of a type that has attachment points
Ralf Sippl16381792018-04-12 21:20:26 +0000328// (i.e. quadpoints). Quadpoints are the vertices of the rectangle that
Jane Liu4fd9a472017-06-01 18:56:09 -0400329// encompasses the texts affected by the annotation. They provide the
Jane Liu20eafda2017-06-07 10:33:24 -0400330// coordinates in the page where the annotation is attached. Only text markup
331// annotations (i.e. highlight, strikeout, squiggly, and underline) and link
332// annotations have quadpoints.
Jane Liu4fd9a472017-06-01 18:56:09 -0400333//
334// annot - handle to an annotation.
335//
336// Returns true if the annotation is of a type that has quadpoints, false
337// otherwise.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400338FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Jane Liu4fd9a472017-06-01 18:56:09 -0400339FPDFAnnot_HasAttachmentPoints(FPDF_ANNOTATION annot);
340
Jane Liu36567742017-07-06 11:13:35 -0400341// Experimental API.
Ralf Sippl16381792018-04-12 21:20:26 +0000342// Replace the attachment points (i.e. quadpoints) set of an annotation at
343// |quad_index|. This index needs to be within the result of
344// FPDFAnnot_CountAttachmentPoints().
345// If the annotation's appearance stream is defined and this annotation is of a
346// type with quadpoints, then update the bounding box too if the new quadpoints
347// define a bigger one.
348//
349// annot - handle to an annotation.
350// quad_index - index of the set of quadpoints.
351// quad_points - the quadpoints to be set.
352//
353// Returns true if successful.
354FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
355FPDFAnnot_SetAttachmentPoints(FPDF_ANNOTATION annot,
356 size_t quad_index,
357 const FS_QUADPOINTSF* quad_points);
358
359// Experimental API.
360// Append to the list of attachment points (i.e. quadpoints) of an annotation.
361// If the annotation's appearance stream is defined and this annotation is of a
362// type with quadpoints, then update the bounding box too if the new quadpoints
Jane Liub370e5a2017-08-16 13:24:58 -0400363// define a bigger one.
Jane Liu20eafda2017-06-07 10:33:24 -0400364//
Lei Zhangc3cffbe2018-03-21 13:37:46 +0000365// annot - handle to an annotation.
366// quad_points - the quadpoints to be set.
Jane Liu20eafda2017-06-07 10:33:24 -0400367//
Jane Liu8ce58f52017-06-29 13:40:22 -0400368// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400369FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Ralf Sippl16381792018-04-12 21:20:26 +0000370FPDFAnnot_AppendAttachmentPoints(FPDF_ANNOTATION annot,
371 const FS_QUADPOINTSF* quad_points);
Jane Liu20eafda2017-06-07 10:33:24 -0400372
Jane Liu36567742017-07-06 11:13:35 -0400373// Experimental API.
Henrique Nakashima5098b252018-03-26 21:46:00 +0000374// Get the number of sets of quadpoints of an annotation.
375//
376// annot - handle to an annotation.
377//
378// Returns the number of sets of quadpoints, or 0 on failure.
379FPDF_EXPORT size_t FPDF_CALLCONV
380FPDFAnnot_CountAttachmentPoints(FPDF_ANNOTATION annot);
381
382// Experimental API.
Jane Liub370e5a2017-08-16 13:24:58 -0400383// Get the attachment points (i.e. quadpoints) of an annotation.
Jane Liu4fd9a472017-06-01 18:56:09 -0400384//
Lei Zhangc3cffbe2018-03-21 13:37:46 +0000385// annot - handle to an annotation.
Ralf Sippl16381792018-04-12 21:20:26 +0000386// quad_index - index of the set of quadpoints.
Lei Zhangc3cffbe2018-03-21 13:37:46 +0000387// quad_points - receives the quadpoints; must not be NULL.
Jane Liu4fd9a472017-06-01 18:56:09 -0400388//
Jane Liu0c6b07d2017-08-15 10:50:22 -0400389// Returns true if successful.
390FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
391FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot,
Ralf Sippl16381792018-04-12 21:20:26 +0000392 size_t quad_index,
Lei Zhangc3cffbe2018-03-21 13:37:46 +0000393 FS_QUADPOINTSF* quad_points);
Jane Liu4fd9a472017-06-01 18:56:09 -0400394
Jane Liu36567742017-07-06 11:13:35 -0400395// Experimental API.
Jane Liu06462752017-06-27 16:41:14 -0400396// Set the annotation rectangle defining the location of the annotation. If the
397// annotation's appearance stream is defined and this annotation is of a type
Jane Liub370e5a2017-08-16 13:24:58 -0400398// without quadpoints, then update the bounding box too if the new rectangle
399// defines a bigger one.
Jane Liu20eafda2017-06-07 10:33:24 -0400400//
401// annot - handle to an annotation.
402// rect - the annotation rectangle to be set.
403//
Jane Liu8ce58f52017-06-29 13:40:22 -0400404// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400405FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetRect(FPDF_ANNOTATION annot,
406 const FS_RECTF* rect);
Jane Liu20eafda2017-06-07 10:33:24 -0400407
Jane Liu36567742017-07-06 11:13:35 -0400408// Experimental API.
Jane Liub370e5a2017-08-16 13:24:58 -0400409// Get the annotation rectangle defining the location of the annotation.
Jane Liu4fd9a472017-06-01 18:56:09 -0400410//
411// annot - handle to an annotation.
Jane Liu0c6b07d2017-08-15 10:50:22 -0400412// rect - receives the rectangle; must not be NULL.
Jane Liu4fd9a472017-06-01 18:56:09 -0400413//
Jane Liu0c6b07d2017-08-15 10:50:22 -0400414// Returns true if successful.
415FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetRect(FPDF_ANNOTATION annot,
416 FS_RECTF* rect);
Jane Liu4fd9a472017-06-01 18:56:09 -0400417
Jane Liu36567742017-07-06 11:13:35 -0400418// Experimental API.
Miklos Vajna09ecef62020-11-10 21:50:38 +0000419// Get the vertices of a polygon or polyline annotation. |buffer| is an array of
420// points of the annotation. If |length| is less than the returned length, or
421// |annot| or |buffer| is NULL, |buffer| will not be modified.
422//
423// annot - handle to an annotation, as returned by e.g. FPDFPage_GetAnnot()
424// buffer - buffer for holding the points.
425// length - length of the buffer in points.
426//
427// Returns the number of points if the annotation is of type polygon or
428// polyline, 0 otherwise.
429FPDF_EXPORT unsigned long FPDF_CALLCONV
430FPDFAnnot_GetVertices(FPDF_ANNOTATION annot,
431 FS_POINTF* buffer,
432 unsigned long length);
433
434// Experimental API.
Miklos Vajna8f7b1ae2020-11-17 16:53:14 +0000435// Get the number of paths in the ink list of an ink annotation.
436//
437// annot - handle to an annotation, as returned by e.g. FPDFPage_GetAnnot()
438//
439// Returns the number of paths in the ink list if the annotation is of type ink,
440// 0 otherwise.
441FPDF_EXPORT unsigned long FPDF_CALLCONV
442FPDFAnnot_GetInkListCount(FPDF_ANNOTATION annot);
443
444// Experimental API.
445// Get a path in the ink list of an ink annotation. |buffer| is an array of
446// points of the path. If |length| is less than the returned length, or |annot|
447// or |buffer| is NULL, |buffer| will not be modified.
448//
449// annot - handle to an annotation, as returned by e.g. FPDFPage_GetAnnot()
450// path_index - index of the path
451// buffer - buffer for holding the points.
452// length - length of the buffer in points.
453//
454// Returns the number of points of the path if the annotation is of type ink, 0
455// otherwise.
456FPDF_EXPORT unsigned long FPDF_CALLCONV
457FPDFAnnot_GetInkListPath(FPDF_ANNOTATION annot,
458 unsigned long path_index,
459 FS_POINTF* buffer,
460 unsigned long length);
461
462// Experimental API.
Miklos Vajna30f45a62020-12-04 19:12:31 +0000463// Get the starting and ending coordinates of a line annotation.
464//
465// annot - handle to an annotation, as returned by e.g. FPDFPage_GetAnnot()
466// start - starting point
467// end - ending point
468//
469// Returns true if the annotation is of type line, |start| and |end| are not
470// NULL, false otherwise.
471FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetLine(FPDF_ANNOTATION annot,
472 FS_POINTF* start,
473 FS_POINTF* end);
474
475// Experimental API.
Lei Zhang21ea6652021-04-15 23:24:46 +0000476// Set the characteristics of the annotation's border (rounded rectangle).
477//
478// annot - handle to an annotation
479// horizontal_radius - horizontal corner radius, in default user space units
480// vertical_radius - vertical corner radius, in default user space units
481// border_width - border width, in default user space units
482//
Lei Zhang24de1492021-04-19 18:06:43 +0000483// Returns true if setting the border for |annot| succeeds, false otherwise.
484//
485// If |annot| contains an appearance stream that overrides the border values,
486// then the appearance stream will be removed on success.
Lei Zhang21ea6652021-04-15 23:24:46 +0000487FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetBorder(FPDF_ANNOTATION annot,
488 float horizontal_radius,
489 float vertical_radius,
490 float border_width);
491
492// Experimental API.
Miklos Vajna305d2ed2020-12-15 17:28:49 +0000493// Get the characteristics of the annotation's border (rounded rectangle).
494//
Lei Zhang21ea6652021-04-15 23:24:46 +0000495// annot - handle to an annotation
496// horizontal_radius - horizontal corner radius, in default user space units
497// vertical_radius - vertical corner radius, in default user space units
498// border_width - border width, in default user space units
Miklos Vajna305d2ed2020-12-15 17:28:49 +0000499//
500// Returns true if |horizontal_radius|, |vertical_radius| and |border_width| are
501// not NULL, false otherwise.
502FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
503FPDFAnnot_GetBorder(FPDF_ANNOTATION annot,
504 float* horizontal_radius,
505 float* vertical_radius,
506 float* border_width);
507
508// Experimental API.
Miklos Vajnaf929f2f2022-09-16 20:42:32 +0000509// Get the JavaScript of an event of the annotation's additional actions.
510// |buffer| is only modified if |buflen| is large enough to hold the whole
511// JavaScript string. If |buflen| is smaller, the total size of the JavaScript
512// is still returned, but nothing is copied. If there is no JavaScript for
513// |event| in |annot|, an empty string is written to |buf| and 2 is returned,
514// denoting the size of the null terminator in the buffer. On other errors,
515// nothing is written to |buffer| and 0 is returned.
516//
517// hHandle - handle to the form fill module, returned by
518// FPDFDOC_InitFormFillEnvironment().
519// annot - handle to an interactive form annotation.
520// event - event type, one of the FPDF_ANNOT_AACTION_* values.
521// buffer - buffer for holding the value string, encoded in UTF-16LE.
522// buflen - length of the buffer in bytes.
523//
524// Returns the length of the string value in bytes, including the 2-byte
525// null terminator.
526FPDF_EXPORT unsigned long FPDF_CALLCONV
527FPDFAnnot_GetFormAdditionalActionJavaScript(FPDF_FORMHANDLE hHandle,
528 FPDF_ANNOTATION annot,
529 int event,
530 FPDF_WCHAR* buffer,
531 unsigned long buflen);
532
533// Experimental API.
Jane Liu2e1a32b2017-07-06 12:01:25 -0400534// Check if |annot|'s dictionary has |key| as a key.
Jane Liu20eafda2017-06-07 10:33:24 -0400535//
536// annot - handle to an annotation.
Lei Zhangba14c0a2017-09-22 16:43:01 -0700537// key - the key to look for, encoded in UTF-8.
Jane Liu20eafda2017-06-07 10:33:24 -0400538//
Jane Liu2e1a32b2017-07-06 12:01:25 -0400539// Returns true if |key| exists.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400540FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_HasKey(FPDF_ANNOTATION annot,
Lei Zhangdf064df2017-08-31 02:33:27 -0700541 FPDF_BYTESTRING key);
Jane Liu4fd9a472017-06-01 18:56:09 -0400542
Jane Liu36567742017-07-06 11:13:35 -0400543// Experimental API.
Jane Liu57f228d2017-07-13 18:10:30 -0400544// Get the type of the value corresponding to |key| in |annot|'s dictionary.
Jane Liu4fd9a472017-06-01 18:56:09 -0400545//
546// annot - handle to an annotation.
Lei Zhangba14c0a2017-09-22 16:43:01 -0700547// key - the key to look for, encoded in UTF-8.
Jane Liu2e1a32b2017-07-06 12:01:25 -0400548//
549// Returns the type of the dictionary value.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400550FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV
Lei Zhangdf064df2017-08-31 02:33:27 -0700551FPDFAnnot_GetValueType(FPDF_ANNOTATION annot, FPDF_BYTESTRING key);
Jane Liu2e1a32b2017-07-06 12:01:25 -0400552
553// Experimental API.
554// Set the string value corresponding to |key| in |annot|'s dictionary,
555// overwriting the existing value if any. The value type would be
Jane Liu57f228d2017-07-13 18:10:30 -0400556// FPDF_OBJECT_STRING after this function call succeeds.
Jane Liu2e1a32b2017-07-06 12:01:25 -0400557//
558// annot - handle to an annotation.
Lei Zhangba14c0a2017-09-22 16:43:01 -0700559// key - the key to the dictionary entry to be set, encoded in UTF-8.
Lei Zhang2f048542019-05-21 13:10:21 +0000560// value - the string value to be set, encoded in UTF-16LE.
Jane Liu2e1a32b2017-07-06 12:01:25 -0400561//
562// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400563FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
564FPDFAnnot_SetStringValue(FPDF_ANNOTATION annot,
Lei Zhangdf064df2017-08-31 02:33:27 -0700565 FPDF_BYTESTRING key,
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400566 FPDF_WIDESTRING value);
Jane Liu2e1a32b2017-07-06 12:01:25 -0400567
568// Experimental API.
569// Get the string value corresponding to |key| in |annot|'s dictionary. |buffer|
570// is only modified if |buflen| is longer than the length of contents. Note that
571// if |key| does not exist in the dictionary or if |key|'s corresponding value
572// in the dictionary is not a string (i.e. the value is not of type
573// FPDF_OBJECT_STRING or FPDF_OBJECT_NAME), then an empty string would be copied
574// to |buffer| and the return value would be 2. On other errors, nothing would
575// be added to |buffer| and the return value would be 0.
576//
577// annot - handle to an annotation.
Lei Zhangba14c0a2017-09-22 16:43:01 -0700578// key - the key to the requested dictionary entry, encoded in UTF-8.
Lei Zhang2f048542019-05-21 13:10:21 +0000579// buffer - buffer for holding the value string, encoded in UTF-16LE.
Lei Zhang5bf8c7f2019-04-08 17:50:11 +0000580// buflen - length of the buffer in bytes.
Jane Liu4fd9a472017-06-01 18:56:09 -0400581//
Lei Zhang5bf8c7f2019-04-08 17:50:11 +0000582// Returns the length of the string value in bytes.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400583FPDF_EXPORT unsigned long FPDF_CALLCONV
584FPDFAnnot_GetStringValue(FPDF_ANNOTATION annot,
Lei Zhangdf064df2017-08-31 02:33:27 -0700585 FPDF_BYTESTRING key,
Lei Zhang5bf8c7f2019-04-08 17:50:11 +0000586 FPDF_WCHAR* buffer,
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400587 unsigned long buflen);
Jane Liu4fd9a472017-06-01 18:56:09 -0400588
Jane Liub137e752017-07-05 15:04:33 -0400589// Experimental API.
rycsmith3e785602019-03-05 21:48:36 +0000590// Get the float value corresponding to |key| in |annot|'s dictionary. Writes
591// value to |value| and returns True if |key| exists in the dictionary and
592// |key|'s corresponding value is a number (FPDF_OBJECT_NUMBER), False
593// otherwise.
594//
595// annot - handle to an annotation.
596// key - the key to the requested dictionary entry, encoded in UTF-8.
597// value - receives the value, must not be NULL.
598//
599// Returns True if value found, False otherwise.
600FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
601FPDFAnnot_GetNumberValue(FPDF_ANNOTATION annot,
602 FPDF_BYTESTRING key,
603 float* value);
604
605// Experimental API.
Henrique Nakashima5970a472018-01-11 22:40:59 +0000606// Set the AP (appearance string) in |annot|'s dictionary for a given
607// |appearanceMode|.
608//
609// annot - handle to an annotation.
610// appearanceMode - the appearance mode (normal, rollover or down) for which
611// to get the AP.
Lei Zhang2f048542019-05-21 13:10:21 +0000612// value - the string value to be set, encoded in UTF-16LE. If
Henrique Nakashima5970a472018-01-11 22:40:59 +0000613// nullptr is passed, the AP is cleared for that mode. If the
614// mode is Normal, APs for all modes are cleared.
615//
616// Returns true if successful.
617FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
618FPDFAnnot_SetAP(FPDF_ANNOTATION annot,
619 FPDF_ANNOT_APPEARANCEMODE appearanceMode,
620 FPDF_WIDESTRING value);
621
622// Experimental API.
Henrique Nakashimaa74e75d2018-01-10 18:06:55 +0000623// Get the AP (appearance string) from |annot|'s dictionary for a given
624// |appearanceMode|.
625// |buffer| is only modified if |buflen| is large enough to hold the whole AP
626// string. If |buflen| is smaller, the total size of the AP is still returned,
627// but nothing is copied.
628// If there is no appearance stream for |annot| in |appearanceMode|, an empty
629// string is written to |buf| and 2 is returned.
630// On other errors, nothing is written to |buffer| and 0 is returned.
631//
632// annot - handle to an annotation.
633// appearanceMode - the appearance mode (normal, rollover or down) for which
634// to get the AP.
Lei Zhang2f048542019-05-21 13:10:21 +0000635// buffer - buffer for holding the value string, encoded in UTF-16LE.
Lei Zhang5bf8c7f2019-04-08 17:50:11 +0000636// buflen - length of the buffer in bytes.
Henrique Nakashimaa74e75d2018-01-10 18:06:55 +0000637//
Lei Zhang5bf8c7f2019-04-08 17:50:11 +0000638// Returns the length of the string value in bytes.
Henrique Nakashimaa74e75d2018-01-10 18:06:55 +0000639FPDF_EXPORT unsigned long FPDF_CALLCONV
640FPDFAnnot_GetAP(FPDF_ANNOTATION annot,
641 FPDF_ANNOT_APPEARANCEMODE appearanceMode,
Lei Zhang5bf8c7f2019-04-08 17:50:11 +0000642 FPDF_WCHAR* buffer,
Henrique Nakashimaa74e75d2018-01-10 18:06:55 +0000643 unsigned long buflen);
644
645// Experimental API.
Jane Liu300bb272017-08-21 14:37:53 -0400646// Get the annotation corresponding to |key| in |annot|'s dictionary. Common
647// keys for linking annotations include "IRT" and "Popup". Must call
648// FPDFPage_CloseAnnot() when the annotation returned by this function is no
649// longer needed.
650//
651// annot - handle to an annotation.
Lei Zhangba14c0a2017-09-22 16:43:01 -0700652// key - the key to the requested dictionary entry, encoded in UTF-8.
Jane Liu300bb272017-08-21 14:37:53 -0400653//
654// Returns a handle to the linked annotation object, or NULL on failure.
655FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV
Lei Zhangdf064df2017-08-31 02:33:27 -0700656FPDFAnnot_GetLinkedAnnot(FPDF_ANNOTATION annot, FPDF_BYTESTRING key);
Jane Liu300bb272017-08-21 14:37:53 -0400657
658// Experimental API.
Jane Liub137e752017-07-05 15:04:33 -0400659// Get the annotation flags of |annot|.
660//
661// annot - handle to an annotation.
662//
663// Returns the annotation flags.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400664FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetFlags(FPDF_ANNOTATION annot);
Jane Liub137e752017-07-05 15:04:33 -0400665
666// Experimental API.
667// Set the |annot|'s flags to be of the value |flags|.
668//
669// annot - handle to an annotation.
670// flags - the flag values to be set.
671//
672// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400673FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetFlags(FPDF_ANNOTATION annot,
674 int flags);
Jane Liub137e752017-07-05 15:04:33 -0400675
Diana Gage7e0c05d2017-07-19 17:33:33 -0700676// Experimental API.
Lei Zhanga9d33bd2019-07-31 05:37:31 +0000677// Get the annotation flags of |annot|.
Diana Gage7e0c05d2017-07-19 17:33:33 -0700678//
Lei Zhange6fcdfa2019-02-14 04:07:09 +0000679// hHandle - handle to the form fill module, returned by
680// FPDFDOC_InitFormFillEnvironment().
Lei Zhange6fcdfa2019-02-14 04:07:09 +0000681// annot - handle to an interactive form annotation.
Diana Gage7e0c05d2017-07-19 17:33:33 -0700682//
683// Returns the annotation flags specific to interactive forms.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400684FPDF_EXPORT int FPDF_CALLCONV
Lei Zhange6fcdfa2019-02-14 04:07:09 +0000685FPDFAnnot_GetFormFieldFlags(FPDF_FORMHANDLE handle,
Lei Zhange6fcdfa2019-02-14 04:07:09 +0000686 FPDF_ANNOTATION annot);
Diana Gage7e0c05d2017-07-19 17:33:33 -0700687
Diana Gage40870db2017-07-19 18:16:03 -0700688// Experimental API.
689// Retrieves an interactive form annotation whose rectangle contains a given
690// point on a page. Must call FPDFPage_CloseAnnot() when the annotation returned
691// is no longer needed.
692//
693//
694// hHandle - handle to the form fill module, returned by
Lei Zhange6fcdfa2019-02-14 04:07:09 +0000695// FPDFDOC_InitFormFillEnvironment().
Diana Gage40870db2017-07-19 18:16:03 -0700696// page - handle to the page, returned by FPDF_LoadPage function.
Lei Zhang8da98232019-12-11 23:29:33 +0000697// point - position in PDF "user space".
Diana Gage40870db2017-07-19 18:16:03 -0700698//
699// Returns the interactive form annotation whose rectangle contains the given
700// coordinates on the page. If there is no such annotation, return NULL.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400701FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV
Diana Gage40870db2017-07-19 18:16:03 -0700702FPDFAnnot_GetFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
703 FPDF_PAGE page,
Lei Zhang8da98232019-12-11 23:29:33 +0000704 const FS_POINTF* point);
Diana Gage40870db2017-07-19 18:16:03 -0700705
rycsmithcb752f32019-02-21 18:40:53 +0000706// Experimental API.
Mansi Awasthi07bf7e62020-01-24 10:34:17 +0000707// Gets the name of |annot|, which is an interactive form annotation.
708// |buffer| is only modified if |buflen| is longer than the length of contents.
709// In case of error, nothing will be added to |buffer| and the return value will
710// be 0. Note that return value of empty string is 2 for "\0\0".
711//
712// hHandle - handle to the form fill module, returned by
713// FPDFDOC_InitFormFillEnvironment().
714// annot - handle to an interactive form annotation.
715// buffer - buffer for holding the name string, encoded in UTF-16LE.
716// buflen - length of the buffer in bytes.
717//
718// Returns the length of the string value in bytes.
719FPDF_EXPORT unsigned long FPDF_CALLCONV
720FPDFAnnot_GetFormFieldName(FPDF_FORMHANDLE hHandle,
721 FPDF_ANNOTATION annot,
722 FPDF_WCHAR* buffer,
723 unsigned long buflen);
724
725// Experimental API.
Miklos Vajna786e8f62022-09-22 14:20:17 +0000726// Gets the alternate name of |annot|, which is an interactive form annotation.
727// |buffer| is only modified if |buflen| is longer than the length of contents.
728// In case of error, nothing will be added to |buffer| and the return value will
729// be 0. Note that return value of empty string is 2 for "\0\0".
730//
731// hHandle - handle to the form fill module, returned by
732// FPDFDOC_InitFormFillEnvironment().
733// annot - handle to an interactive form annotation.
734// buffer - buffer for holding the alternate name string, encoded in
735// UTF-16LE.
736// buflen - length of the buffer in bytes.
737//
738// Returns the length of the string value in bytes.
739FPDF_EXPORT unsigned long FPDF_CALLCONV
740FPDFAnnot_GetFormFieldAlternateName(FPDF_FORMHANDLE hHandle,
741 FPDF_ANNOTATION annot,
742 FPDF_WCHAR* buffer,
743 unsigned long buflen);
744
745// Experimental API.
Mansi Awasthi07bf7e62020-01-24 10:34:17 +0000746// Gets the form field type of |annot|, which is an interactive form annotation.
747//
748// hHandle - handle to the form fill module, returned by
749// FPDFDOC_InitFormFillEnvironment().
750// annot - handle to an interactive form annotation.
751//
752// Returns the type of the form field (one of the FPDF_FORMFIELD_* values) on
753// success. Returns -1 on error.
754// See field types in fpdf_formfill.h.
755FPDF_EXPORT int FPDF_CALLCONV
756FPDFAnnot_GetFormFieldType(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot);
757
758// Experimental API.
759// Gets the value of |annot|, which is an interactive form annotation.
760// |buffer| is only modified if |buflen| is longer than the length of contents.
761// In case of error, nothing will be added to |buffer| and the return value will
762// be 0. Note that return value of empty string is 2 for "\0\0".
763//
764// hHandle - handle to the form fill module, returned by
765// FPDFDOC_InitFormFillEnvironment().
766// annot - handle to an interactive form annotation.
767// buffer - buffer for holding the value string, encoded in UTF-16LE.
768// buflen - length of the buffer in bytes.
769//
770// Returns the length of the string value in bytes.
771FPDF_EXPORT unsigned long FPDF_CALLCONV
772FPDFAnnot_GetFormFieldValue(FPDF_FORMHANDLE hHandle,
773 FPDF_ANNOTATION annot,
774 FPDF_WCHAR* buffer,
775 unsigned long buflen);
776
777// Experimental API.
rycsmithcb752f32019-02-21 18:40:53 +0000778// Get the number of options in the |annot|'s "Opt" dictionary. Intended for
779// use with listbox and combobox widget annotations.
780//
781// hHandle - handle to the form fill module, returned by
782// FPDFDOC_InitFormFillEnvironment.
783// annot - handle to an annotation.
784//
785// Returns the number of options in "Opt" dictionary on success. Return value
786// will be -1 if annotation does not have an "Opt" dictionary or other error.
787FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetOptionCount(FPDF_FORMHANDLE hHandle,
788 FPDF_ANNOTATION annot);
789
790// Experimental API.
791// Get the string value for the label of the option at |index| in |annot|'s
792// "Opt" dictionary. Intended for use with listbox and combobox widget
793// annotations. |buffer| is only modified if |buflen| is longer than the length
794// of contents. If index is out of range or in case of other error, nothing
795// will be added to |buffer| and the return value will be 0. Note that
796// return value of empty string is 2 for "\0\0".
797//
798// hHandle - handle to the form fill module, returned by
799// FPDFDOC_InitFormFillEnvironment.
800// annot - handle to an annotation.
801// index - numeric index of the option in the "Opt" array
Lei Zhang2f048542019-05-21 13:10:21 +0000802// buffer - buffer for holding the value string, encoded in UTF-16LE.
Lei Zhang5bf8c7f2019-04-08 17:50:11 +0000803// buflen - length of the buffer in bytes.
rycsmithcb752f32019-02-21 18:40:53 +0000804//
Lei Zhang5bf8c7f2019-04-08 17:50:11 +0000805// Returns the length of the string value in bytes.
806// If |annot| does not have an "Opt" array, |index| is out of range or if any
807// other error occurs, returns 0.
rycsmithcb752f32019-02-21 18:40:53 +0000808FPDF_EXPORT unsigned long FPDF_CALLCONV
809FPDFAnnot_GetOptionLabel(FPDF_FORMHANDLE hHandle,
810 FPDF_ANNOTATION annot,
811 int index,
Lei Zhang5bf8c7f2019-04-08 17:50:11 +0000812 FPDF_WCHAR* buffer,
rycsmithcb752f32019-02-21 18:40:53 +0000813 unsigned long buflen);
814
Ryan Smith09c23b12019-04-25 18:09:06 +0000815// Experimental API.
Mansi Awasthi2acdf792020-05-12 08:48:04 +0000816// Determine whether or not the option at |index| in |annot|'s "Opt" dictionary
817// is selected. Intended for use with listbox and combobox widget annotations.
818//
819// handle - handle to the form fill module, returned by
820// FPDFDOC_InitFormFillEnvironment.
821// annot - handle to an annotation.
822// index - numeric index of the option in the "Opt" array.
823//
824// Returns true if the option at |index| in |annot|'s "Opt" dictionary is
825// selected, false otherwise.
826FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
827FPDFAnnot_IsOptionSelected(FPDF_FORMHANDLE handle,
828 FPDF_ANNOTATION annot,
829 int index);
830
831// Experimental API.
Ryan Smith09c23b12019-04-25 18:09:06 +0000832// Get the float value of the font size for an |annot| with variable text.
833// If 0, the font is to be auto-sized: its size is computed as a function of
834// the height of the annotation rectangle.
835//
836// hHandle - handle to the form fill module, returned by
837// FPDFDOC_InitFormFillEnvironment.
838// annot - handle to an annotation.
839// value - Required. Float which will be set to font size on success.
840//
841// Returns true if the font size was set in |value|, false on error or if
842// |value| not provided.
843FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
844FPDFAnnot_GetFontSize(FPDF_FORMHANDLE hHandle,
845 FPDF_ANNOTATION annot,
846 float* value);
847
Ryan Smith23fdf892019-07-17 21:51:26 +0000848// Experimental API.
Miklos Vajna7b997652024-06-21 19:34:53 +0000849// Get the RGB value of the font color for an |annot| with variable text.
850//
851// hHandle - handle to the form fill module, returned by
852// FPDFDOC_InitFormFillEnvironment.
853// annot - handle to an annotation.
854// R, G, B - buffer to hold the RGB value of the color. Ranges from 0 to 255.
855//
856// Returns true if the font color was set, false on error or if the font
857// color was not provided.
858FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
859FPDFAnnot_GetFontColor(FPDF_FORMHANDLE hHandle,
860 FPDF_ANNOTATION annot,
861 unsigned int* R,
862 unsigned int* G,
863 unsigned int* B);
864
865// Experimental API.
Ryan Smith23fdf892019-07-17 21:51:26 +0000866// Determine if |annot| is a form widget that is checked. Intended for use with
867// checkbox and radio button widgets.
868//
869// hHandle - handle to the form fill module, returned by
870// FPDFDOC_InitFormFillEnvironment.
871// annot - handle to an annotation.
872//
873// Returns true if |annot| is a form widget and is checked, false otherwise.
874FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_IsChecked(FPDF_FORMHANDLE hHandle,
875 FPDF_ANNOTATION annot);
876
Neha Gupta1eb6ddd2020-03-19 08:37:15 +0000877// Experimental API.
878// Set the list of focusable annotation subtypes. Annotations of subtype
879// FPDF_ANNOT_WIDGET are by default focusable. New subtypes set using this API
880// will override the existing subtypes.
881//
882// hHandle - handle to the form fill module, returned by
883// FPDFDOC_InitFormFillEnvironment.
884// subtypes - list of annotation subtype which can be tabbed over.
885// count - total number of annotation subtype in list.
886// Returns true if list of annotation subtype is set successfully, false
887// otherwise.
888FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
889FPDFAnnot_SetFocusableSubtypes(FPDF_FORMHANDLE hHandle,
890 const FPDF_ANNOTATION_SUBTYPE* subtypes,
891 size_t count);
892
893// Experimental API.
894// Get the count of focusable annotation subtypes as set by host
895// for a |hHandle|.
896//
897// hHandle - handle to the form fill module, returned by
898// FPDFDOC_InitFormFillEnvironment.
899// Returns the count of focusable annotation subtypes or -1 on error.
900// Note : Annotations of type FPDF_ANNOT_WIDGET are by default focusable.
901FPDF_EXPORT int FPDF_CALLCONV
902FPDFAnnot_GetFocusableSubtypesCount(FPDF_FORMHANDLE hHandle);
903
904// Experimental API.
905// Get the list of focusable annotation subtype as set by host.
906//
907// hHandle - handle to the form fill module, returned by
908// FPDFDOC_InitFormFillEnvironment.
909// subtypes - receives the list of annotation subtype which can be tabbed
910// over. Caller must have allocated |subtypes| more than or
911// equal to the count obtained from
912// FPDFAnnot_GetFocusableSubtypesCount() API.
913// count - size of |subtypes|.
914// Returns true on success and set list of annotation subtype to |subtypes|,
915// false otherwise.
916// Note : Annotations of type FPDF_ANNOT_WIDGET are by default focusable.
917FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
918FPDFAnnot_GetFocusableSubtypes(FPDF_FORMHANDLE hHandle,
919 FPDF_ANNOTATION_SUBTYPE* subtypes,
920 size_t count);
921
Badhri Ravikumarcd628912020-05-07 19:23:51 +0000922// Experimental API.
923// Gets FPDF_LINK object for |annot|. Intended to use for link annotations.
924//
925// annot - handle to an annotation.
926//
927// Returns FPDF_LINK from the FPDF_ANNOTATION and NULL on failure,
928// if the input annot is NULL or input annot's subtype is not link.
929FPDF_EXPORT FPDF_LINK FPDF_CALLCONV FPDFAnnot_GetLink(FPDF_ANNOTATION annot);
930
Mansi Awasthi23bba0e2020-05-15 12:18:25 +0000931// Experimental API.
932// Gets the count of annotations in the |annot|'s control group.
933// A group of interactive form annotations is collectively called a form
934// control group. Here, |annot|, an interactive form annotation, should be
935// either a radio button or a checkbox.
936//
937// hHandle - handle to the form fill module, returned by
938// FPDFDOC_InitFormFillEnvironment.
939// annot - handle to an annotation.
940//
941// Returns number of controls in its control group or -1 on error.
942FPDF_EXPORT int FPDF_CALLCONV
943FPDFAnnot_GetFormControlCount(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot);
944
945// Experimental API.
946// Gets the index of |annot| in |annot|'s control group.
947// A group of interactive form annotations is collectively called a form
948// control group. Here, |annot|, an interactive form annotation, should be
949// either a radio button or a checkbox.
950//
951// hHandle - handle to the form fill module, returned by
952// FPDFDOC_InitFormFillEnvironment.
953// annot - handle to an annotation.
954//
955// Returns index of a given |annot| in its control group or -1 on error.
956FPDF_EXPORT int FPDF_CALLCONV
957FPDFAnnot_GetFormControlIndex(FPDF_FORMHANDLE hHandle, FPDF_ANNOTATION annot);
958
959// Experimental API.
960// Gets the export value of |annot| which is an interactive form annotation.
961// Intended for use with radio button and checkbox widget annotations.
962// |buffer| is only modified if |buflen| is longer than the length of contents.
963// In case of error, nothing will be added to |buffer| and the return value
964// will be 0. Note that return value of empty string is 2 for "\0\0".
965//
966// hHandle - handle to the form fill module, returned by
967// FPDFDOC_InitFormFillEnvironment().
968// annot - handle to an interactive form annotation.
969// buffer - buffer for holding the value string, encoded in UTF-16LE.
970// buflen - length of the buffer in bytes.
971//
972// Returns the length of the string value in bytes.
973FPDF_EXPORT unsigned long FPDF_CALLCONV
974FPDFAnnot_GetFormFieldExportValue(FPDF_FORMHANDLE hHandle,
975 FPDF_ANNOTATION annot,
976 FPDF_WCHAR* buffer,
977 unsigned long buflen);
978
Lei Zhang81395aa2021-04-16 00:40:46 +0000979// Experimental API.
980// Add a URI action to |annot|, overwriting the existing action, if any.
981//
982// annot - handle to a link annotation.
983// uri - the URI to be set, encoded in 7-bit ASCII.
984//
985// Returns true if successful.
986FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetURI(FPDF_ANNOTATION annot,
987 const char* uri);
988
Ivan Odulo1908cfc2024-02-16 21:25:11 +0000989// Experimental API.
990// Get the attachment from |annot|.
991//
992// annot - handle to a file annotation.
993//
994// Returns the handle to the attachment object, or NULL on failure.
995FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV
996FPDFAnnot_GetFileAttachment(FPDF_ANNOTATION annot);
997
998// Experimental API.
999// Add an embedded file with |name| to |annot|.
1000//
1001// annot - handle to a file annotation.
1002// name - name of the new attachment.
1003//
1004// Returns a handle to the new attachment object, or NULL on failure.
1005FPDF_EXPORT FPDF_ATTACHMENT FPDF_CALLCONV
1006FPDFAnnot_AddFileAttachment(FPDF_ANNOTATION annot, FPDF_WIDESTRING name);
1007
Jane Liu4fd9a472017-06-01 18:56:09 -04001008#ifdef __cplusplus
1009} // extern "C"
1010#endif // __cplusplus
1011
1012#endif // PUBLIC_FPDF_ANNOT_H_