blob: 0f87361b38b814323eae6d8b701d33fe5aaf5cc6 [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.
Dan Sinclair00d2ad12017-08-10 14:13:02 -040047FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV
dsinclair5f597db2016-03-25 09:04:54 -070048FPDFBookmark_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.
Dan Sinclair00d2ad12017-08-10 14:13:02 -040057FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV
dsinclair5f597db2016-03-25 09:04:54 -070058FPDFBookmark_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.
Dan Sinclair00d2ad12017-08-10 14:13:02 -040073FPDF_EXPORT unsigned long FPDF_CALLCONV
74FPDFBookmark_GetTitle(FPDF_BOOKMARK bookmark,
75 void* buffer,
76 unsigned long buflen);
dsinclair5f597db2016-03-25 09:04:54 -070077
78// Find the bookmark with |title| in |document|.
79//
80// document - handle to the document.
81// title - the UTF-16LE encoded Unicode title for which to search.
82//
83// Returns the handle to the bookmark, or NULL if |title| can't be found.
84//
85// |FPDFBookmark_Find| will always return the first bookmark found even if
86// multiple bookmarks have the same |title|.
Dan Sinclair00d2ad12017-08-10 14:13:02 -040087FPDF_EXPORT FPDF_BOOKMARK FPDF_CALLCONV
88FPDFBookmark_Find(FPDF_DOCUMENT document, FPDF_WIDESTRING title);
dsinclair5f597db2016-03-25 09:04:54 -070089
90// Get the destination associated with |bookmark|.
91//
92// document - handle to the document.
93// bookmark - handle to the bookmark.
94//
95// Returns the handle to the destination data, NULL if no destination is
96// associated with |bookmark|.
Dan Sinclair00d2ad12017-08-10 14:13:02 -040097FPDF_EXPORT FPDF_DEST FPDF_CALLCONV
98FPDFBookmark_GetDest(FPDF_DOCUMENT document, FPDF_BOOKMARK bookmark);
dsinclair5f597db2016-03-25 09:04:54 -070099
100// Get the action associated with |bookmark|.
101//
102// bookmark - handle to the bookmark.
103//
104// Returns the handle to the action data, or NULL if no action is associated
105// with |bookmark|. When NULL is returned, |FPDFBookmark_GetDest| should be
106// called to get the |bookmark| destination data.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400107FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV
108FPDFBookmark_GetAction(FPDF_BOOKMARK bookmark);
dsinclair5f597db2016-03-25 09:04:54 -0700109
110// Get the type of |action|.
111//
112// action - handle to the action.
113//
114// Returns one of:
115// PDFACTION_UNSUPPORTED
116// PDFACTION_GOTO
117// PDFACTION_REMOTEGOTO
118// PDFACTION_URI
119// PDFACTION_LAUNCH
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400120FPDF_EXPORT unsigned long FPDF_CALLCONV FPDFAction_GetType(FPDF_ACTION action);
dsinclair5f597db2016-03-25 09:04:54 -0700121
122// Get the destination of |action|.
123//
124// document - handle to the document.
125// action - handle to the action. |action| must be a |PDFACTION_GOTO| or
126// |PDFACTION_REMOTEGOTO|.
127//
128// Returns a handle to the destination data.
129//
130// In the case of |PDFACTION_REMOTEGOTO|, you should first call
131// |FPDFAction_GetFilePath| then load that document, the document handle from
132// that document should pass as |document| to |FPDFAction_GetDest|.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400133FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDFAction_GetDest(FPDF_DOCUMENT document,
134 FPDF_ACTION action);
dsinclair5f597db2016-03-25 09:04:54 -0700135
136// Get file path of a |PDFACTION_REMOTEGOTO| |action|.
137//
138// action - handle to the action. |action| must be a |PDFACTION_LAUNCH| or
139// |PDFACTION_REMOTEGOTO|
140// buffer - a buffer for output the path string. May be NULL.
141// buflen - the length of the buffer, in bytes. May be 0.
142//
Lei Zhangd3b90ac2017-06-08 18:48:10 -0700143// Returns the number of bytes in the file path, including the trailing NUL
144// character.
dsinclair5f597db2016-03-25 09:04:54 -0700145//
Lei Zhangd3b90ac2017-06-08 18:48:10 -0700146// Regardless of the platform, the |buffer| is always in UTF-8 encoding.
thestig9067fd62016-11-23 14:10:06 -0800147// If |buflen| is less than the returned length, or |buffer| is NULL, |buffer|
dsinclair5f597db2016-03-25 09:04:54 -0700148// will not be modified.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400149FPDF_EXPORT unsigned long FPDF_CALLCONV
dsinclair5f597db2016-03-25 09:04:54 -0700150FPDFAction_GetFilePath(FPDF_ACTION action, void* buffer, unsigned long buflen);
151
152// Get the URI path of a |PDFACTION_URI| |action|.
153//
154// document - handle to the document.
155// action - handle to the action. Must be a |PDFACTION_URI|.
156// buffer - a buffer for the path string. May be NULL.
157// buflen - the length of the buffer, in bytes. May be 0.
158//
159// Returns the number of bytes in the URI path, including trailing zeros.
160//
thestig9067fd62016-11-23 14:10:06 -0800161// The |buffer| is always encoded in 7-bit ASCII. If |buflen| is less than the
dsinclair5f597db2016-03-25 09:04:54 -0700162// returned length, or |buffer| is NULL, |buffer| will not be modified.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400163FPDF_EXPORT unsigned long FPDF_CALLCONV
164FPDFAction_GetURIPath(FPDF_DOCUMENT document,
165 FPDF_ACTION action,
166 void* buffer,
167 unsigned long buflen);
dsinclair5f597db2016-03-25 09:04:54 -0700168
169// Get the page index of |dest|.
170//
171// document - handle to the document.
172// dest - handle to the destination.
173//
174// Returns the page index containing |dest|. Page indices start from 0.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400175FPDF_EXPORT unsigned long FPDF_CALLCONV
176FPDFDest_GetPageIndex(FPDF_DOCUMENT document, FPDF_DEST dest);
dsinclair5f597db2016-03-25 09:04:54 -0700177
dsinclairc59fa882016-11-08 06:55:40 -0800178// Get the (x, y, zoom) location of |dest| in the destination page, if the
179// destination is in [page /XYZ x y zoom] syntax.
180//
181// dest - handle to the destination.
182// hasXVal - out parameter; true if the x value is not null
183// hasYVal - out parameter; true if the y value is not null
184// hasZoomVal - out parameter; true if the zoom value is not null
185// x - out parameter; the x coordinate, in page coordinates.
186// y - out parameter; the y coordinate, in page coordinates.
187// zoom - out parameter; the zoom value.
188// Returns TRUE on successfully reading the /XYZ value.
189//
190// Note the [x, y, zoom] values are only set if the corresponding hasXVal,
191// hasYVal or hasZoomVal flags are true.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400192FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
193FPDFDest_GetLocationInPage(FPDF_DEST dest,
194 FPDF_BOOL* hasXCoord,
195 FPDF_BOOL* hasYCoord,
196 FPDF_BOOL* hasZoom,
197 FS_FLOAT* x,
198 FS_FLOAT* y,
199 FS_FLOAT* zoom);
dsinclairc59fa882016-11-08 06:55:40 -0800200
dsinclair5f597db2016-03-25 09:04:54 -0700201// Find a link at point (|x|,|y|) on |page|.
202//
203// page - handle to the document page.
204// x - the x coordinate, in the page coordinate system.
205// y - the y coordinate, in the page coordinate system.
206//
207// Returns a handle to the link, or NULL if no link found at the given point.
208//
209// You can convert coordinates from screen coordinates to page coordinates using
210// |FPDF_DeviceToPage|.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400211FPDF_EXPORT FPDF_LINK FPDF_CALLCONV FPDFLink_GetLinkAtPoint(FPDF_PAGE page,
212 double x,
213 double y);
dsinclair5f597db2016-03-25 09:04:54 -0700214
215// Find the Z-order of link at point (|x|,|y|) on |page|.
216//
217// page - handle to the document page.
218// x - the x coordinate, in the page coordinate system.
219// y - the y coordinate, in the page coordinate system.
220//
221// Returns the Z-order of the link, or -1 if no link found at the given point.
222// Larger Z-order numbers are closer to the front.
223//
224// You can convert coordinates from screen coordinates to page coordinates using
225// |FPDF_DeviceToPage|.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400226FPDF_EXPORT int FPDF_CALLCONV FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page,
227 double x,
228 double y);
dsinclair5f597db2016-03-25 09:04:54 -0700229
230// Get destination info for |link|.
231//
232// document - handle to the document.
233// link - handle to the link.
234//
235// Returns a handle to the destination, or NULL if there is no destination
236// associated with the link. In this case, you should call |FPDFLink_GetAction|
237// to retrieve the action associated with |link|.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400238FPDF_EXPORT FPDF_DEST FPDF_CALLCONV FPDFLink_GetDest(FPDF_DOCUMENT document,
239 FPDF_LINK link);
dsinclair5f597db2016-03-25 09:04:54 -0700240
241// Get action info for |link|.
242//
243// link - handle to the link.
244//
245// Returns a handle to the action associated to |link|, or NULL if no action.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400246FPDF_EXPORT FPDF_ACTION FPDF_CALLCONV FPDFLink_GetAction(FPDF_LINK link);
dsinclair5f597db2016-03-25 09:04:54 -0700247
248// Enumerates all the link annotations in |page|.
249//
250// page - handle to the page.
251// startPos - the start position, should initially be 0 and is updated with
252// the next start position on return.
253// linkAnnot - the link handle for |startPos|.
254//
255// Returns TRUE on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400256FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFLink_Enumerate(FPDF_PAGE page,
257 int* startPos,
258 FPDF_LINK* linkAnnot);
dsinclair5f597db2016-03-25 09:04:54 -0700259
260// Get the rectangle for |linkAnnot|.
261//
262// linkAnnot - handle to the link annotation.
263// rect - the annotation rectangle.
264//
265// Returns true on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400266FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot,
267 FS_RECTF* rect);
dsinclair5f597db2016-03-25 09:04:54 -0700268
269// Get the count of quadrilateral points to the |linkAnnot|.
270//
271// linkAnnot - handle to the link annotation.
272//
273// Returns the count of quadrilateral points.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400274FPDF_EXPORT int FPDF_CALLCONV FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot);
dsinclair5f597db2016-03-25 09:04:54 -0700275
276// Get the quadrilateral points for the specified |quadIndex| in |linkAnnot|.
277//
278// linkAnnot - handle to the link annotation.
279// quadIndex - the specified quad point index.
280// quadPoints - receives the quadrilateral points.
281//
282// Returns true on success.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400283FPDF_EXPORT FPDF_BOOL FPDF_CALLCONV
284FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot,
285 int quadIndex,
286 FS_QUADPOINTSF* quadPoints);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700287
dsinclair5f597db2016-03-25 09:04:54 -0700288// Get meta-data |tag| content from |document|.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700289//
thestig733e0682016-11-23 05:52:39 -0800290// document - handle to the document.
291// tag - the tag to retrieve. The tag can be one of:
292// Title, Author, Subject, Keywords, Creator, Producer,
293// CreationDate, or ModDate.
294// For detailed explanations of these tags and their respective
295// values, please refer to PDF Reference 1.6, section 10.2.1,
296// 'Document Information Dictionary'.
297// buffer - a buffer for the tag. May be NULL.
298// buflen - the length of the buffer, in bytes. May be 0.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700299//
thestig733e0682016-11-23 05:52:39 -0800300// Returns the number of bytes in the tag, including trailing zeros.
dsinclair5f597db2016-03-25 09:04:54 -0700301//
302// The |buffer| is always encoded in UTF-16LE. The |buffer| is followed by two
thestig04bebfe2016-11-04 16:07:25 -0700303// bytes of zeros indicating the end of the string. If |buflen| is less than
dsinclair5f597db2016-03-25 09:04:54 -0700304// the returned length, or |buffer| is NULL, |buffer| will not be modified.
Henrique Nakashima10e02fa2017-06-22 16:14:09 -0400305//
306// For linearized files, FPDFAvail_IsFormAvail must be called before this, and
307// it must have returned PDF_FORM_AVAIL or PDF_FORM_NOTEXIST. Before that, there
308// is no guarantee the metadata has been loaded.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400309FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetMetaText(FPDF_DOCUMENT document,
310 FPDF_BYTESTRING tag,
311 void* buffer,
312 unsigned long buflen);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700313
thestig733e0682016-11-23 05:52:39 -0800314// Get the page label for |page_index| from |document|.
315//
316// document - handle to the document.
317// page_index - the 0-based index of the page.
318// buffer - a buffer for the page label. May be NULL.
319// buflen - the length of the buffer, in bytes. May be 0.
320//
321// Returns the number of bytes in the page label, including trailing zeros.
322//
323// The |buffer| is always encoded in UTF-16LE. The |buffer| is followed by two
324// bytes of zeros indicating the end of the string. If |buflen| is less than
325// the returned length, or |buffer| is NULL, |buffer| will not be modified.
Dan Sinclair00d2ad12017-08-10 14:13:02 -0400326FPDF_EXPORT unsigned long FPDF_CALLCONV
327FPDF_GetPageLabel(FPDF_DOCUMENT document,
328 int page_index,
329 void* buffer,
330 unsigned long buflen);
thestig733e0682016-11-23 05:52:39 -0800331
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700332#ifdef __cplusplus
dsinclair5f597db2016-03-25 09:04:54 -0700333} // extern "C"
334#endif // __cplusplus
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700335
Tom Sepez9857e202015-05-13 17:09:26 -0700336#endif // PUBLIC_FPDF_DOC_H_