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