blob: adfddec56674d27f57a8a8aef484d77757474b64 [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
100// Get the subtype of an annotation.
101//
102// annot - handle to an annotation.
103//
104// Returns the annotation subtype.
105DLLEXPORT FPDF_ANNOTATION_SUBTYPE STDCALL
106FPDFAnnot_GetSubtype(FPDF_ANNOTATION annot);
107
Jane Liu20eafda2017-06-07 10:33:24 -0400108// Set the color of an annotation.
109//
110// annot - handle to an annotation.
111// type - type of the color to be set.
112// R, G, B - buffer to hold the RGB value of the color. Ranges from 0 to 255.
113// A - buffer to hold the opacity. Ranges from 0 to 255.
114//
115// Returns true if successful, false otherwise.
116DLLEXPORT FPDF_BOOL STDCALL FPDFAnnot_SetColor(FPDF_ANNOTATION annot,
117 FPDFANNOT_COLORTYPE type,
118 unsigned int R,
119 unsigned int G,
120 unsigned int B,
121 unsigned int A);
Jane Liu4fd9a472017-06-01 18:56:09 -0400122
123// Get the color of an annotation. If no color is specified, default to yellow
124// for highlight annotation, black for all else.
125//
Jane Liu20eafda2017-06-07 10:33:24 -0400126// annot - handle to an annotation.
127// type - type of the color requested.
Jane Liu4fd9a472017-06-01 18:56:09 -0400128// R, G, B - buffer to hold the RGB value of the color. Ranges from 0 to 255.
Jane Liu20eafda2017-06-07 10:33:24 -0400129// A - buffer to hold the opacity. Ranges from 0 to 255.
Jane Liu4fd9a472017-06-01 18:56:09 -0400130//
131// Returns true if successful, false otherwise.
132DLLEXPORT FPDF_BOOL STDCALL FPDFAnnot_GetColor(FPDF_ANNOTATION annot,
133 FPDFANNOT_COLORTYPE type,
134 unsigned int* R,
135 unsigned int* G,
136 unsigned int* B,
137 unsigned int* A);
138
139// Check if the annotation is of a type that has attachment points
140// (i.e. quadpoints). Quadpoints are the vertices of the rectange that
141// encompasses the texts affected by the annotation. They provide the
Jane Liu20eafda2017-06-07 10:33:24 -0400142// coordinates in the page where the annotation is attached. Only text markup
143// annotations (i.e. highlight, strikeout, squiggly, and underline) and link
144// annotations have quadpoints.
Jane Liu4fd9a472017-06-01 18:56:09 -0400145//
146// annot - handle to an annotation.
147//
148// Returns true if the annotation is of a type that has quadpoints, false
149// otherwise.
150DLLEXPORT FPDF_BOOL STDCALL
151FPDFAnnot_HasAttachmentPoints(FPDF_ANNOTATION annot);
152
Jane Liu20eafda2017-06-07 10:33:24 -0400153// Set the attachment points (i.e. quadpoints) of an annotation.
154//
155// annot - handle to an annotation.
156// quadPoints - the quadpoints to be set.
157//
158// Returns true if successful, false otherwise.
159DLLEXPORT FPDF_BOOL STDCALL
160FPDFAnnot_SetAttachmentPoints(FPDF_ANNOTATION annot, FS_QUADPOINTSF quadPoints);
161
Jane Liu4fd9a472017-06-01 18:56:09 -0400162// Get the attachment points (i.e. quadpoints) of an annotation.
163//
Jane Liu20eafda2017-06-07 10:33:24 -0400164// annot - handle to an annotation.
165// quadPoints - receives the attachment points.
Jane Liu4fd9a472017-06-01 18:56:09 -0400166//
167// Returns true if successful, false otherwise.
168DLLEXPORT FPDF_BOOL STDCALL
169FPDFAnnot_GetAttachmentPoints(FPDF_ANNOTATION annot,
170 FS_QUADPOINTSF* quadPoints);
171
Jane Liu20eafda2017-06-07 10:33:24 -0400172// Set the annotation rectangle defining the location of the annotation.
173//
174// annot - handle to an annotation.
175// rect - the annotation rectangle to be set.
176//
177// Returns true if successful, false otherwise.
178DLLEXPORT FPDF_BOOL STDCALL FPDFAnnot_SetRect(FPDF_ANNOTATION annot,
179 FS_RECTF rect);
180
Jane Liu4fd9a472017-06-01 18:56:09 -0400181// Get the annotation rectangle defining the location of the annotation.
182//
183// annot - handle to an annotation.
Jane Liu20eafda2017-06-07 10:33:24 -0400184// rect - receives the annotation rectangle.
Jane Liu4fd9a472017-06-01 18:56:09 -0400185//
186// Returns true if successful, false otherwise.
187DLLEXPORT FPDF_BOOL STDCALL FPDFAnnot_GetRect(FPDF_ANNOTATION annot,
188 FS_RECTF* rect);
189
Jane Liu20eafda2017-06-07 10:33:24 -0400190// Set the contents of an annotation.
191//
192// annot - handle to an annotation.
193// type - type of the text to be set.
194// text - the text to be set.
195//
196// Returns true if successful, false otherwise.
197DLLEXPORT FPDF_BOOL STDCALL FPDFAnnot_SetText(FPDF_ANNOTATION annot,
198 FPDFANNOT_TEXTTYPE type,
199 FPDF_WIDESTRING text);
Jane Liu4fd9a472017-06-01 18:56:09 -0400200
201// Get the contents of an annotation. |buffer| is only modified if |buflen|
202// is longer than the length of contents.
203//
204// annot - handle to an annotation.
Jane Liu20eafda2017-06-07 10:33:24 -0400205// type - type of the text requested.
Jane Liu4fd9a472017-06-01 18:56:09 -0400206// buffer - buffer for holding the contents string, encoded in UTF16-LE.
207// buflen - length of the buffer.
208//
209// Returns the length of the contents.
Jane Liu4fd9a472017-06-01 18:56:09 -0400210DLLEXPORT unsigned long STDCALL FPDFAnnot_GetText(FPDF_ANNOTATION annot,
211 FPDFANNOT_TEXTTYPE type,
Jane Liu262cf462017-06-09 11:36:37 -0400212 void* buffer,
Jane Liu4fd9a472017-06-01 18:56:09 -0400213 unsigned long buflen);
214
215#ifdef __cplusplus
216} // extern "C"
217#endif // __cplusplus
218
219#endif // PUBLIC_FPDF_ANNOT_H_