blob: 8e272238f88aa3651c1a63f65f182a469dd2e0c9 [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// Copyright 2014 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.
Tom Sepez9857e202015-05-13 17:09:26 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
Tom Sepez9857e202015-05-13 17:09:26 -07007#ifndef PUBLIC_FPDF_DOC_H_
8#define PUBLIC_FPDF_DOC_H_
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07009
Dan Sinclair85c8e7f2016-11-21 13:50:32 -050010// NOLINTNEXTLINE(build/include)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070011#include "fpdfview.h"
12
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070013#ifdef __cplusplus
14extern "C" {
dsinclair5f597db2016-03-25 09:04:54 -070015#endif // __cplusplus
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070016
dsinclair5f597db2016-03-25 09:04:54 -070017// Unsupported action type.
18#define PDFACTION_UNSUPPORTED 0
19// Go to a destination within current document.
20#define PDFACTION_GOTO 1
21// Go to a destination within another document.
22#define PDFACTION_REMOTEGOTO 2
23// URI, including web pages and other Internet resources.
24#define PDFACTION_URI 3
25// Launch an application or open a file.
26#define PDFACTION_LAUNCH 4
Bo Xu4d62b6b2015-01-10 22:52:59 -080027
Nico Weber9d8ec5a2015-08-04 13:00:21 -070028typedef struct _FS_QUADPOINTSF {
29 FS_FLOAT x1;
30 FS_FLOAT y1;
31 FS_FLOAT x2;
32 FS_FLOAT y2;
33 FS_FLOAT x3;
34 FS_FLOAT y3;
35 FS_FLOAT x4;
36 FS_FLOAT y4;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070037} FS_QUADPOINTSF;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070038
dsinclair5f597db2016-03-25 09:04:54 -070039// Get the first child of |bookmark|, or the first top-level bookmark item.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070040//
dsinclair5f597db2016-03-25 09:04:54 -070041// document - handle to the document.
42// bookmark - handle to the current bookmark. Pass NULL for the first top
43// level item.
44//
45// Returns a handle to the first child of |bookmark| or the first top-level
46// bookmark item. NULL if no child or top-level bookmark found.
47DLLEXPORT FPDF_BOOKMARK STDCALL
48FPDFBookmark_GetFirstChild(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark);
49
50// Get the next sibling of |bookmark|.
51//
52// document - handle to the document.
53// bookmark - handle to the current bookmark.
54//
55// Returns a handle to the next sibling of |bookmark|, or NULL if this is the
56// last bookmark at this level.
57DLLEXPORT FPDF_BOOKMARK STDCALL
58FPDFBookmark_GetNextSibling(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark);
59
60// Get the title of |bookmark|.
61//
62// bookmark - handle to the bookmark.
63// buffer - buffer for the title. May be NULL.
64// buflen - the length of the buffer in bytes. May be 0.
65//
66// Returns the number of bytes in the title, including the terminating NUL
67// character. The number of bytes is returned regardless of the |buffer| and
68// |buflen| parameters.
69//
70// Regardless of the platform, the |buffer| is always in UTF-16LE encoding. The
thestig9067fd62016-11-23 14:10:06 -080071// string is terminated by a UTF16 NUL character. If |buflen| is less than the
dsinclair5f597db2016-03-25 09:04:54 -070072// required length, or |buffer| is NULL, |buffer| will not be modified.
73DLLEXPORT unsigned long STDCALL FPDFBookmark_GetTitle(FPDF_BOOKMARK bookmark,
74 void* buffer,
75 unsigned long buflen);
76
77// Find the bookmark with |title| in |document|.
78//
79// document - handle to the document.
80// title - the UTF-16LE encoded Unicode title for which to search.
81//
82// Returns the handle to the bookmark, or NULL if |title| can't be found.
83//
84// |FPDFBookmark_Find| will always return the first bookmark found even if
85// multiple bookmarks have the same |title|.
86DLLEXPORT FPDF_BOOKMARK STDCALL FPDFBookmark_Find(FPDF_DOCUMENT document,
87 FPDF_WIDESTRING title);
88
89// Get the destination associated with |bookmark|.
90//
91// document - handle to the document.
92// bookmark - handle to the bookmark.
93//
94// Returns the handle to the destination data, NULL if no destination is
95// associated with |bookmark|.
96DLLEXPORT FPDF_DEST STDCALL FPDFBookmark_GetDest(FPDF_DOCUMENT document,
97 FPDF_BOOKMARK bookmark);
98
99// Get the action associated with |bookmark|.
100//
101// bookmark - handle to the bookmark.
102//
103// Returns the handle to the action data, or NULL if no action is associated
104// with |bookmark|. When NULL is returned, |FPDFBookmark_GetDest| should be
105// called to get the |bookmark| destination data.
106DLLEXPORT FPDF_ACTION STDCALL FPDFBookmark_GetAction(FPDF_BOOKMARK bookmark);
107
108// Get the type of |action|.
109//
110// action - handle to the action.
111//
112// Returns one of:
113// PDFACTION_UNSUPPORTED
114// PDFACTION_GOTO
115// PDFACTION_REMOTEGOTO
116// PDFACTION_URI
117// PDFACTION_LAUNCH
118DLLEXPORT unsigned long STDCALL FPDFAction_GetType(FPDF_ACTION action);
119
120// Get the destination of |action|.
121//
122// document - handle to the document.
123// action - handle to the action. |action| must be a |PDFACTION_GOTO| or
124// |PDFACTION_REMOTEGOTO|.
125//
126// Returns a handle to the destination data.
127//
128// In the case of |PDFACTION_REMOTEGOTO|, you should first call
129// |FPDFAction_GetFilePath| then load that document, the document handle from
130// that document should pass as |document| to |FPDFAction_GetDest|.
131DLLEXPORT FPDF_DEST STDCALL FPDFAction_GetDest(FPDF_DOCUMENT document,
132 FPDF_ACTION action);
133
134// Get file path of a |PDFACTION_REMOTEGOTO| |action|.
135//
136// action - handle to the action. |action| must be a |PDFACTION_LAUNCH| or
137// |PDFACTION_REMOTEGOTO|
138// buffer - a buffer for output the path string. May be NULL.
139// buflen - the length of the buffer, in bytes. May be 0.
140//
Lei Zhangd3b90ac2017-06-08 18:48:10 -0700141// Returns the number of bytes in the file path, including the trailing NUL
142// character.
dsinclair5f597db2016-03-25 09:04:54 -0700143//
Lei Zhangd3b90ac2017-06-08 18:48:10 -0700144// Regardless of the platform, the |buffer| is always in UTF-8 encoding.
thestig9067fd62016-11-23 14:10:06 -0800145// If |buflen| is less than the returned length, or |buffer| is NULL, |buffer|
dsinclair5f597db2016-03-25 09:04:54 -0700146// will not be modified.
147DLLEXPORT unsigned long STDCALL
148FPDFAction_GetFilePath(FPDF_ACTION action, void* buffer, unsigned long buflen);
149
150// Get the URI path of a |PDFACTION_URI| |action|.
151//
152// document - handle to the document.
153// action - handle to the action. Must be a |PDFACTION_URI|.
154// buffer - a buffer for the path string. May be NULL.
155// buflen - the length of the buffer, in bytes. May be 0.
156//
157// Returns the number of bytes in the URI path, including trailing zeros.
158//
thestig9067fd62016-11-23 14:10:06 -0800159// The |buffer| is always encoded in 7-bit ASCII. If |buflen| is less than the
dsinclair5f597db2016-03-25 09:04:54 -0700160// returned length, or |buffer| is NULL, |buffer| will not be modified.
161DLLEXPORT unsigned long STDCALL FPDFAction_GetURIPath(FPDF_DOCUMENT document,
162 FPDF_ACTION action,
163 void* buffer,
164 unsigned long buflen);
165
166// Get the page index of |dest|.
167//
168// document - handle to the document.
169// dest - handle to the destination.
170//
171// Returns the page index containing |dest|. Page indices start from 0.
172DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document,
173 FPDF_DEST dest);
174
dsinclairc59fa882016-11-08 06:55:40 -0800175// Get the (x, y, zoom) location of |dest| in the destination page, if the
176// destination is in [page /XYZ x y zoom] syntax.
177//
178// dest - handle to the destination.
179// hasXVal - out parameter; true if the x value is not null
180// hasYVal - out parameter; true if the y value is not null
181// hasZoomVal - out parameter; true if the zoom value is not null
182// x - out parameter; the x coordinate, in page coordinates.
183// y - out parameter; the y coordinate, in page coordinates.
184// zoom - out parameter; the zoom value.
185// Returns TRUE on successfully reading the /XYZ value.
186//
187// Note the [x, y, zoom] values are only set if the corresponding hasXVal,
188// hasYVal or hasZoomVal flags are true.
189DLLEXPORT FPDF_BOOL STDCALL FPDFDest_GetLocationInPage(FPDF_DEST dest,
190 FPDF_BOOL* hasXCoord,
191 FPDF_BOOL* hasYCoord,
192 FPDF_BOOL* hasZoom,
193 FS_FLOAT* x,
194 FS_FLOAT* y,
195 FS_FLOAT* zoom);
196
dsinclair5f597db2016-03-25 09:04:54 -0700197// Find a link at point (|x|,|y|) on |page|.
198//
199// page - handle to the document page.
200// x - the x coordinate, in the page coordinate system.
201// y - the y coordinate, in the page coordinate system.
202//
203// Returns a handle to the link, or NULL if no link found at the given point.
204//
205// You can convert coordinates from screen coordinates to page coordinates using
206// |FPDF_DeviceToPage|.
207DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page,
208 double x,
209 double y);
210
211// Find the Z-order of link at point (|x|,|y|) on |page|.
212//
213// page - handle to the document page.
214// x - the x coordinate, in the page coordinate system.
215// y - the y coordinate, in the page coordinate system.
216//
217// Returns the Z-order of the link, or -1 if no link found at the given point.
218// Larger Z-order numbers are closer to the front.
219//
220// You can convert coordinates from screen coordinates to page coordinates using
221// |FPDF_DeviceToPage|.
222DLLEXPORT int STDCALL
223FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, double x, double y);
224
225// Get destination info for |link|.
226//
227// document - handle to the document.
228// link - handle to the link.
229//
230// Returns a handle to the destination, or NULL if there is no destination
231// associated with the link. In this case, you should call |FPDFLink_GetAction|
232// to retrieve the action associated with |link|.
233DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document,
234 FPDF_LINK link);
235
236// Get action info for |link|.
237//
238// link - handle to the link.
239//
240// Returns a handle to the action associated to |link|, or NULL if no action.
241DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK link);
242
243// Enumerates all the link annotations in |page|.
244//
245// page - handle to the page.
246// startPos - the start position, should initially be 0 and is updated with
247// the next start position on return.
248// linkAnnot - the link handle for |startPos|.
249//
250// Returns TRUE on success.
251DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page,
252 int* startPos,
253 FPDF_LINK* linkAnnot);
254
255// Get the rectangle for |linkAnnot|.
256//
257// linkAnnot - handle to the link annotation.
258// rect - the annotation rectangle.
259//
260// Returns true on success.
261DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot,
262 FS_RECTF* rect);
263
264// Get the count of quadrilateral points to the |linkAnnot|.
265//
266// linkAnnot - handle to the link annotation.
267//
268// Returns the count of quadrilateral points.
269DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot);
270
271// Get the quadrilateral points for the specified |quadIndex| in |linkAnnot|.
272//
273// linkAnnot - handle to the link annotation.
274// quadIndex - the specified quad point index.
275// quadPoints - receives the quadrilateral points.
276//
277// Returns true on success.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700278DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot,
279 int quadIndex,
280 FS_QUADPOINTSF* quadPoints);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700281
dsinclair5f597db2016-03-25 09:04:54 -0700282// Get meta-data |tag| content from |document|.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700283//
thestig733e0682016-11-23 05:52:39 -0800284// document - handle to the document.
285// tag - the tag to retrieve. The tag can be one of:
286// Title, Author, Subject, Keywords, Creator, Producer,
287// CreationDate, or ModDate.
288// For detailed explanations of these tags and their respective
289// values, please refer to PDF Reference 1.6, section 10.2.1,
290// 'Document Information Dictionary'.
291// buffer - a buffer for the tag. May be NULL.
292// buflen - the length of the buffer, in bytes. May be 0.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700293//
thestig733e0682016-11-23 05:52:39 -0800294// Returns the number of bytes in the tag, including trailing zeros.
dsinclair5f597db2016-03-25 09:04:54 -0700295//
296// The |buffer| is always encoded in UTF-16LE. The |buffer| is followed by two
thestig04bebfe2016-11-04 16:07:25 -0700297// bytes of zeros indicating the end of the string. If |buflen| is less than
dsinclair5f597db2016-03-25 09:04:54 -0700298// the returned length, or |buffer| is NULL, |buffer| will not be modified.
thestig733e0682016-11-23 05:52:39 -0800299DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT document,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700300 FPDF_BYTESTRING tag,
301 void* buffer,
302 unsigned long buflen);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700303
thestig733e0682016-11-23 05:52:39 -0800304// Get the page label for |page_index| from |document|.
305//
306// document - handle to the document.
307// page_index - the 0-based index of the page.
308// buffer - a buffer for the page label. May be NULL.
309// buflen - the length of the buffer, in bytes. May be 0.
310//
311// Returns the number of bytes in the page label, including trailing zeros.
312//
313// The |buffer| is always encoded in UTF-16LE. The |buffer| is followed by two
314// bytes of zeros indicating the end of the string. If |buflen| is less than
315// the returned length, or |buffer| is NULL, |buffer| will not be modified.
dsinclair6bdb56c2016-12-06 09:53:27 -0800316DLLEXPORT unsigned long STDCALL FPDF_GetPageLabel(FPDF_DOCUMENT document,
317 int page_index,
318 void* buffer,
319 unsigned long buflen);
thestig733e0682016-11-23 05:52:39 -0800320
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700321#ifdef __cplusplus
dsinclair5f597db2016-03-25 09:04:54 -0700322} // extern "C"
323#endif // __cplusplus
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700324
Tom Sepez9857e202015-05-13 17:09:26 -0700325#endif // PUBLIC_FPDF_DOC_H_