blob: 1fbc3668720b0c949654dbbf92bb7ff589447ec6 [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 Liud1ed1ce2017-08-24 12:31:10 -0400137// Get the index of |annot| in |page|. This is the opposite of
138// FPDFPage_GetAnnot().
139//
140// page - handle to the page that the annotation is on.
141// annot - handle to an annotation.
142//
143// Returns the index of |annot|, or -1 on failure.
144FPDF_EXPORT int FPDF_CALLCONV FPDFPage_GetAnnotIndex(FPDF_PAGE page,
145 FPDF_ANNOTATION annot);
146
147// Experimental API.
Jane Liue10509a2017-06-20 16:47:41 -0400148// Close an annotation. Must be called when the annotation returned by
149// FPDFPage_CreateAnnot() or FPDFPage_GetAnnot() is no longer needed. This
150// function does not remove the annotation from the document.
151//
152// annot - handle to an annotation.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400153FPDF_EXPORT void FPDF_CALLCONV FPDFPage_CloseAnnot(FPDF_ANNOTATION annot);
Jane Liue10509a2017-06-20 16:47:41 -0400154
Jane Liu36567742017-07-06 11:13:35 -0400155// Experimental API.
Jane Liu8ce58f52017-06-29 13:40:22 -0400156// Remove the annotation in |page| at |index|.
157//
158// page - handle to a page.
159// index - the index of the annotation.
160//
161// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400162FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFPage_RemoveAnnot(FPDF_PAGE page,
163 int index);
Jane Liu8ce58f52017-06-29 13:40:22 -0400164
Jane Liu36567742017-07-06 11:13:35 -0400165// Experimental API.
Jane Liu4fd9a472017-06-01 18:56:09 -0400166// Get the subtype of an annotation.
167//
168// annot - handle to an annotation.
169//
170// Returns the annotation subtype.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400171FPDF_EXPORT FPDF_ANNOTATION_SUBTYPE FPDF_CALLCONV
Jane Liu4fd9a472017-06-01 18:56:09 -0400172FPDFAnnot_GetSubtype(FPDF_ANNOTATION annot);
173
Jane Liubaa7ff42017-06-29 19:18:23 -0400174// Experimental API.
Jane Liu7a9a38b2017-07-11 13:47:37 -0400175// Check if an annotation subtype is currently supported for object extraction,
176// update, and removal.
177// Currently supported subtypes: ink and stamp.
178//
179// subtype - the subtype to be checked.
180//
181// Returns true if this subtype supported.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400182FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Jane Liu7a9a38b2017-07-11 13:47:37 -0400183FPDFAnnot_IsObjectSupportedSubtype(FPDF_ANNOTATION_SUBTYPE subtype);
184
185// Experimental API.
Jane Liu36567742017-07-06 11:13:35 -0400186// Update |obj| in |annot|. |obj| must be in |annot| already and must have
187// been retrieved by FPDFAnnot_GetObject(). Currently, only ink and stamp
188// annotations are supported by this API. Also note that only path, image, and
189// text objects have APIs for modification; see FPDFPath_*(), FPDFText_*(), and
190// FPDFImageObj_*().
Jane Liubaa7ff42017-06-29 19:18:23 -0400191//
192// annot - handle to an annotation.
Jane Liu36567742017-07-06 11:13:35 -0400193// obj - handle to the object that |annot| needs to update.
Jane Liubaa7ff42017-06-29 19:18:23 -0400194//
195// Return true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400196FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
197FPDFAnnot_UpdateObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj);
Jane Liubaa7ff42017-06-29 19:18:23 -0400198
199// Experimental API.
Jane Liu36567742017-07-06 11:13:35 -0400200// Add |obj| to |annot|. |obj| must have been created by
201// FPDFPageObj_CreateNew{Path|Rect}() or FPDFPageObj_New{Text|Image}Obj(), and
202// will be owned by |annot|. Note that an |obj| cannot belong to more than one
203// |annot|. Currently, only ink and stamp annotations are supported by this API.
204// Also note that only path, image, and text objects have APIs for creation.
Jane Liubaa7ff42017-06-29 19:18:23 -0400205//
206// annot - handle to an annotation.
Jane Liu36567742017-07-06 11:13:35 -0400207// obj - handle to the object that is to be added to |annot|.
Jane Liubaa7ff42017-06-29 19:18:23 -0400208//
209// Return true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400210FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
211FPDFAnnot_AppendObject(FPDF_ANNOTATION annot, FPDF_PAGEOBJECT obj);
Jane Liubaa7ff42017-06-29 19:18:23 -0400212
213// Experimental API.
Jane Liu36567742017-07-06 11:13:35 -0400214// Get the total number of objects in |annot|, including path objects, text
215// objects, external objects, image objects, and shading objects.
Jane Liubaa7ff42017-06-29 19:18:23 -0400216//
217// annot - handle to an annotation.
218//
Jane Liu36567742017-07-06 11:13:35 -0400219// Returns the number of objects in |annot|.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400220FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetObjectCount(FPDF_ANNOTATION annot);
Jane Liubaa7ff42017-06-29 19:18:23 -0400221
222// Experimental API.
Jane Liu36567742017-07-06 11:13:35 -0400223// Get the object in |annot| at |index|.
Jane Liubaa7ff42017-06-29 19:18:23 -0400224//
225// annot - handle to an annotation.
Jane Liu36567742017-07-06 11:13:35 -0400226// index - the index of the object.
Jane Liubaa7ff42017-06-29 19:18:23 -0400227//
Jane Liu36567742017-07-06 11:13:35 -0400228// Return a handle to the object, or NULL on failure.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400229FPDF_EXPORT FPDF_PAGEOBJECT FPDF_CALLCONV
230FPDFAnnot_GetObject(FPDF_ANNOTATION annot, int index);
Jane Liubaa7ff42017-06-29 19:18:23 -0400231
Jane Liu36567742017-07-06 11:13:35 -0400232// Experimental API.
Jane Liu7a9a38b2017-07-11 13:47:37 -0400233// Remove the object in |annot| at |index|.
234//
235// annot - handle to an annotation.
236// index - the index of the object to be removed.
237//
238// Return true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400239FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
240FPDFAnnot_RemoveObject(FPDF_ANNOTATION annot, int index);
Jane Liu7a9a38b2017-07-11 13:47:37 -0400241
242// Experimental API.
Jane Liu06462752017-06-27 16:41:14 -0400243// Set the color of an annotation. Fails when called on annotations with
244// appearance streams already defined; instead use
245// FPDFPath_Set{Stroke|Fill}Color().
Jane Liu20eafda2017-06-07 10:33:24 -0400246//
247// annot - handle to an annotation.
248// type - type of the color to be set.
249// R, G, B - buffer to hold the RGB value of the color. Ranges from 0 to 255.
250// A - buffer to hold the opacity. Ranges from 0 to 255.
251//
Jane Liu8ce58f52017-06-29 13:40:22 -0400252// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400253FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetColor(FPDF_ANNOTATION annot,
254 FPDFANNOT_COLORTYPE type,
255 unsigned int R,
256 unsigned int G,
257 unsigned int B,
258 unsigned int A);
Jane Liu4fd9a472017-06-01 18:56:09 -0400259
Jane Liu36567742017-07-06 11:13:35 -0400260// Experimental API.
Jane Liu4fd9a472017-06-01 18:56:09 -0400261// Get the color of an annotation. If no color is specified, default to yellow
Jane Liu06462752017-06-27 16:41:14 -0400262// for highlight annotation, black for all else. Fails when called on
263// annotations with appearance streams already defined; instead use
264// FPDFPath_Get{Stroke|Fill}Color().
Jane Liu4fd9a472017-06-01 18:56:09 -0400265//
Jane Liu20eafda2017-06-07 10:33:24 -0400266// annot - handle to an annotation.
267// type - type of the color requested.
Jane Liu4fd9a472017-06-01 18:56:09 -0400268// R, G, B - buffer to hold the RGB value of the color. Ranges from 0 to 255.
Jane Liu20eafda2017-06-07 10:33:24 -0400269// A - buffer to hold the opacity. Ranges from 0 to 255.
Jane Liu4fd9a472017-06-01 18:56:09 -0400270//
Jane Liu8ce58f52017-06-29 13:40:22 -0400271// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400272FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetColor(FPDF_ANNOTATION annot,
273 FPDFANNOT_COLORTYPE type,
274 unsigned int* R,
275 unsigned int* G,
276 unsigned int* B,
277 unsigned int* A);
Jane Liu4fd9a472017-06-01 18:56:09 -0400278
Jane Liu36567742017-07-06 11:13:35 -0400279// Experimental API.
Jane Liu4fd9a472017-06-01 18:56:09 -0400280// Check if the annotation is of a type that has attachment points
281// (i.e. quadpoints). Quadpoints are the vertices of the rectange that
282// encompasses the texts affected by the annotation. They provide the
Jane Liu20eafda2017-06-07 10:33:24 -0400283// coordinates in the page where the annotation is attached. Only text markup
284// annotations (i.e. highlight, strikeout, squiggly, and underline) and link
285// annotations have quadpoints.
Jane Liu4fd9a472017-06-01 18:56:09 -0400286//
287// annot - handle to an annotation.
288//
289// Returns true if the annotation is of a type that has quadpoints, false
290// otherwise.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400291FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Jane Liu4fd9a472017-06-01 18:56:09 -0400292FPDFAnnot_HasAttachmentPoints(FPDF_ANNOTATION annot);
293
Jane Liu36567742017-07-06 11:13:35 -0400294// Experimental API.
Jane Liu06462752017-06-27 16:41:14 -0400295// Set the attachment points (i.e. quadpoints) of an annotation. If the
296// annotation's appearance stream is defined and this annotation is of a type
Jane Liub370e5a2017-08-16 13:24:58 -0400297// with quadpoints, then update the bounding box too if the new quadpoints
298// define a bigger one.
Jane Liu20eafda2017-06-07 10:33:24 -0400299//
300// annot - handle to an annotation.
301// quadPoints - the quadpoints to be set.
302//
Jane Liu8ce58f52017-06-29 13:40:22 -0400303// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400304FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
Jane Liu06462752017-06-27 16:41:14 -0400305FPDFAnnot_SetAttachmentPoints(FPDF_ANNOTATION annot,
306 const FS_QUADPOINTSF* quadPoints);
Jane Liu20eafda2017-06-07 10:33:24 -0400307
Jane Liu36567742017-07-06 11:13:35 -0400308// Experimental API.
Jane Liub370e5a2017-08-16 13:24:58 -0400309// Get the attachment points (i.e. quadpoints) of an annotation.
Jane Liu4fd9a472017-06-01 18:56:09 -0400310//
Jane Liu20eafda2017-06-07 10:33:24 -0400311// annot - handle to an annotation.
Jane Liu0c6b07d2017-08-15 10:50:22 -0400312// quadPoints - receives the quadpoints; must not be NULL.
Jane Liu4fd9a472017-06-01 18:56:09 -0400313//
Jane Liu0c6b07d2017-08-15 10:50:22 -0400314// Returns true if successful.
315FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
316FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot,
317 FS_QUADPOINTSF* quadPoints);
Jane Liu4fd9a472017-06-01 18:56:09 -0400318
Jane Liu36567742017-07-06 11:13:35 -0400319// Experimental API.
Jane Liu06462752017-06-27 16:41:14 -0400320// Set the annotation rectangle defining the location of the annotation. If the
321// annotation's appearance stream is defined and this annotation is of a type
Jane Liub370e5a2017-08-16 13:24:58 -0400322// without quadpoints, then update the bounding box too if the new rectangle
323// defines a bigger one.
Jane Liu20eafda2017-06-07 10:33:24 -0400324//
325// annot - handle to an annotation.
326// rect - the annotation rectangle to be set.
327//
Jane Liu8ce58f52017-06-29 13:40:22 -0400328// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400329FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetRect(FPDF_ANNOTATION annot,
330 const FS_RECTF* rect);
Jane Liu20eafda2017-06-07 10:33:24 -0400331
Jane Liu36567742017-07-06 11:13:35 -0400332// Experimental API.
Jane Liub370e5a2017-08-16 13:24:58 -0400333// Get the annotation rectangle defining the location of the annotation.
Jane Liu4fd9a472017-06-01 18:56:09 -0400334//
335// annot - handle to an annotation.
Jane Liu0c6b07d2017-08-15 10:50:22 -0400336// rect - receives the rectangle; must not be NULL.
Jane Liu4fd9a472017-06-01 18:56:09 -0400337//
Jane Liu0c6b07d2017-08-15 10:50:22 -0400338// Returns true if successful.
339FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_GetRect(FPDF_ANNOTATION annot,
340 FS_RECTF* rect);
Jane Liu4fd9a472017-06-01 18:56:09 -0400341
Jane Liu36567742017-07-06 11:13:35 -0400342// Experimental API.
Jane Liu2e1a32b2017-07-06 12:01:25 -0400343// Check if |annot|'s dictionary has |key| as a key.
Jane Liu20eafda2017-06-07 10:33:24 -0400344//
345// annot - handle to an annotation.
Lei Zhangba14c0a2017-09-22 16:43:01 -0700346// key - the key to look for, encoded in UTF-8.
Jane Liu20eafda2017-06-07 10:33:24 -0400347//
Jane Liu2e1a32b2017-07-06 12:01:25 -0400348// Returns true if |key| exists.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400349FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_HasKey(FPDF_ANNOTATION annot,
Lei Zhangdf064df2017-08-31 02:33:27 -0700350 FPDF_BYTESTRING key);
Jane Liu4fd9a472017-06-01 18:56:09 -0400351
Jane Liu36567742017-07-06 11:13:35 -0400352// Experimental API.
Jane Liu57f228d2017-07-13 18:10:30 -0400353// Get the type of the value corresponding to |key| in |annot|'s dictionary.
Jane Liu4fd9a472017-06-01 18:56:09 -0400354//
355// annot - handle to an annotation.
Lei Zhangba14c0a2017-09-22 16:43:01 -0700356// key - the key to look for, encoded in UTF-8.
Jane Liu2e1a32b2017-07-06 12:01:25 -0400357//
358// Returns the type of the dictionary value.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400359FPDF_EXPORT FPDF_OBJECT_TYPE FPDF_CALLCONV
Lei Zhangdf064df2017-08-31 02:33:27 -0700360FPDFAnnot_GetValueType(FPDF_ANNOTATION annot, FPDF_BYTESTRING key);
Jane Liu2e1a32b2017-07-06 12:01:25 -0400361
362// Experimental API.
363// Set the string value corresponding to |key| in |annot|'s dictionary,
364// overwriting the existing value if any. The value type would be
Jane Liu57f228d2017-07-13 18:10:30 -0400365// FPDF_OBJECT_STRING after this function call succeeds.
Jane Liu2e1a32b2017-07-06 12:01:25 -0400366//
367// annot - handle to an annotation.
Lei Zhangba14c0a2017-09-22 16:43:01 -0700368// key - the key to the dictionary entry to be set, encoded in UTF-8.
Jane Liu2e1a32b2017-07-06 12:01:25 -0400369// value - the string value to be set, encoded in UTF16-LE.
370//
371// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400372FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
373FPDFAnnot_SetStringValue(FPDF_ANNOTATION annot,
Lei Zhangdf064df2017-08-31 02:33:27 -0700374 FPDF_BYTESTRING key,
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400375 FPDF_WIDESTRING value);
Jane Liu2e1a32b2017-07-06 12:01:25 -0400376
377// Experimental API.
378// Get the string value corresponding to |key| in |annot|'s dictionary. |buffer|
379// is only modified if |buflen| is longer than the length of contents. Note that
380// if |key| does not exist in the dictionary or if |key|'s corresponding value
381// in the dictionary is not a string (i.e. the value is not of type
382// FPDF_OBJECT_STRING or FPDF_OBJECT_NAME), then an empty string would be copied
383// to |buffer| and the return value would be 2. On other errors, nothing would
384// be added to |buffer| and the return value would be 0.
385//
386// annot - handle to an annotation.
Lei Zhangba14c0a2017-09-22 16:43:01 -0700387// key - the key to the requested dictionary entry, encoded in UTF-8.
Jane Liu2e1a32b2017-07-06 12:01:25 -0400388// buffer - buffer for holding the value string, encoded in UTF16-LE.
Jane Liu4fd9a472017-06-01 18:56:09 -0400389// buflen - length of the buffer.
390//
Jane Liu2e1a32b2017-07-06 12:01:25 -0400391// Returns the length of the string value.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400392FPDF_EXPORT unsigned long FPDF_CALLCONV
393FPDFAnnot_GetStringValue(FPDF_ANNOTATION annot,
Lei Zhangdf064df2017-08-31 02:33:27 -0700394 FPDF_BYTESTRING key,
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400395 void* buffer,
396 unsigned long buflen);
Jane Liu4fd9a472017-06-01 18:56:09 -0400397
Jane Liub137e752017-07-05 15:04:33 -0400398// Experimental API.
Jane Liu300bb272017-08-21 14:37:53 -0400399// Get the annotation corresponding to |key| in |annot|'s dictionary. Common
400// keys for linking annotations include "IRT" and "Popup". Must call
401// FPDFPage_CloseAnnot() when the annotation returned by this function is no
402// longer needed.
403//
404// annot - handle to an annotation.
Lei Zhangba14c0a2017-09-22 16:43:01 -0700405// key - the key to the requested dictionary entry, encoded in UTF-8.
Jane Liu300bb272017-08-21 14:37:53 -0400406//
407// Returns a handle to the linked annotation object, or NULL on failure.
408FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV
Lei Zhangdf064df2017-08-31 02:33:27 -0700409FPDFAnnot_GetLinkedAnnot(FPDF_ANNOTATION annot, FPDF_BYTESTRING key);
Jane Liu300bb272017-08-21 14:37:53 -0400410
411// Experimental API.
Jane Liub137e752017-07-05 15:04:33 -0400412// Get the annotation flags of |annot|.
413//
414// annot - handle to an annotation.
415//
416// Returns the annotation flags.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400417FPDF_EXPORT int FPDF_CALLCONV FPDFAnnot_GetFlags(FPDF_ANNOTATION annot);
Jane Liub137e752017-07-05 15:04:33 -0400418
419// Experimental API.
420// Set the |annot|'s flags to be of the value |flags|.
421//
422// annot - handle to an annotation.
423// flags - the flag values to be set.
424//
425// Returns true if successful.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400426FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFAnnot_SetFlags(FPDF_ANNOTATION annot,
427 int flags);
Jane Liub137e752017-07-05 15:04:33 -0400428
Diana Gage7e0c05d2017-07-19 17:33:33 -0700429// Experimental API.
430// Get the annotation flags of |annot|, which is an interactive form
431// annotation in |page|.
432//
433// page - handle to a page.
434// annot - handle to an interactive form annotation.
435//
436// Returns the annotation flags specific to interactive forms.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400437FPDF_EXPORT int FPDF_CALLCONV
438FPDFAnnot_GetFormFieldFlags(FPDF_PAGE page, FPDF_ANNOTATION annot);
Diana Gage7e0c05d2017-07-19 17:33:33 -0700439
Diana Gage40870db2017-07-19 18:16:03 -0700440// Experimental API.
441// Retrieves an interactive form annotation whose rectangle contains a given
442// point on a page. Must call FPDFPage_CloseAnnot() when the annotation returned
443// is no longer needed.
444//
445//
446// hHandle - handle to the form fill module, returned by
447// FPDFDOC_InitFormFillEnvironment.
448// page - handle to the page, returned by FPDF_LoadPage function.
449// page_x - X position in PDF "user space".
450// page_y - Y position in PDF "user space".
451//
452// Returns the interactive form annotation whose rectangle contains the given
453// coordinates on the page. If there is no such annotation, return NULL.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400454FPDF_EXPORT FPDF_ANNOTATION FPDF_CALLCONV
Diana Gage40870db2017-07-19 18:16:03 -0700455FPDFAnnot_GetFormFieldAtPoint(FPDF_FORMHANDLE hHandle,
456 FPDF_PAGE page,
457 double page_x,
458 double page_y);
459
Jane Liu4fd9a472017-06-01 18:56:09 -0400460#ifdef __cplusplus
461} // extern "C"
462#endif // __cplusplus
463
464#endif // PUBLIC_FPDF_ANNOT_H_