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