blob: 0b7874325931c8b1e0b8a8abe96b313677f1fe41 [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
174// Find a link at point (|x|,|y|) on |page|.
175//
176// page - handle to the document page.
177// x - the x coordinate, in the page coordinate system.
178// y - the y coordinate, in the page coordinate system.
179//
180// Returns a handle to the link, or NULL if no link found at the given point.
181//
182// You can convert coordinates from screen coordinates to page coordinates using
183// |FPDF_DeviceToPage|.
184DLLEXPORT FPDF_LINK STDCALL FPDFLink_GetLinkAtPoint(FPDF_PAGE page,
185 double x,
186 double y);
187
188// Find the Z-order of link at point (|x|,|y|) on |page|.
189//
190// page - handle to the document page.
191// x - the x coordinate, in the page coordinate system.
192// y - the y coordinate, in the page coordinate system.
193//
194// Returns the Z-order of the link, or -1 if no link found at the given point.
195// Larger Z-order numbers are closer to the front.
196//
197// You can convert coordinates from screen coordinates to page coordinates using
198// |FPDF_DeviceToPage|.
199DLLEXPORT int STDCALL
200FPDFLink_GetLinkZOrderAtPoint(FPDF_PAGE page, double x, double y);
201
202// Get destination info for |link|.
203//
204// document - handle to the document.
205// link - handle to the link.
206//
207// Returns a handle to the destination, or NULL if there is no destination
208// associated with the link. In this case, you should call |FPDFLink_GetAction|
209// to retrieve the action associated with |link|.
210DLLEXPORT FPDF_DEST STDCALL FPDFLink_GetDest(FPDF_DOCUMENT document,
211 FPDF_LINK link);
212
213// Get action info for |link|.
214//
215// link - handle to the link.
216//
217// Returns a handle to the action associated to |link|, or NULL if no action.
218DLLEXPORT FPDF_ACTION STDCALL FPDFLink_GetAction(FPDF_LINK link);
219
220// Enumerates all the link annotations in |page|.
221//
222// page - handle to the page.
223// startPos - the start position, should initially be 0 and is updated with
224// the next start position on return.
225// linkAnnot - the link handle for |startPos|.
226//
227// Returns TRUE on success.
228DLLEXPORT FPDF_BOOL STDCALL FPDFLink_Enumerate(FPDF_PAGE page,
229 int* startPos,
230 FPDF_LINK* linkAnnot);
231
232// Get the rectangle for |linkAnnot|.
233//
234// linkAnnot - handle to the link annotation.
235// rect - the annotation rectangle.
236//
237// Returns true on success.
238DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetAnnotRect(FPDF_LINK linkAnnot,
239 FS_RECTF* rect);
240
241// Get the count of quadrilateral points to the |linkAnnot|.
242//
243// linkAnnot - handle to the link annotation.
244//
245// Returns the count of quadrilateral points.
246DLLEXPORT int STDCALL FPDFLink_CountQuadPoints(FPDF_LINK linkAnnot);
247
248// Get the quadrilateral points for the specified |quadIndex| in |linkAnnot|.
249//
250// linkAnnot - handle to the link annotation.
251// quadIndex - the specified quad point index.
252// quadPoints - receives the quadrilateral points.
253//
254// Returns true on success.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700255DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot,
256 int quadIndex,
257 FS_QUADPOINTSF* quadPoints);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700258
dsinclair5f597db2016-03-25 09:04:54 -0700259// Get meta-data |tag| content from |document|.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700260//
dsinclair5f597db2016-03-25 09:04:54 -0700261// doc - handle to the document
262// tag - the tag to retrieve. The tag can be one of:
263// Title, Author, Subject, Keywords, Creator, Producer,
264// CreationDate, or ModDate.
265// For detailed explanations of these tags and their respective
266// values, please refer to PDF Reference 1.6, section 10.2.1,
267// 'Document Information Dictionary'.
268// buffer - a buffer for the title. May be NULL.
269// buflen - the length of the buffer, in bytes. May be 0.
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700270//
dsinclair5f597db2016-03-25 09:04:54 -0700271// Returns the number of bytes in the title, including trailing zeros.
272//
273// The |buffer| is always encoded in UTF-16LE. The |buffer| is followed by two
274// bytes of zeros indicating the end of the string. If |buflen| is less then
275// the returned length, or |buffer| is NULL, |buffer| will not be modified.
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700276DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc,
277 FPDF_BYTESTRING tag,
278 void* buffer,
279 unsigned long buflen);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700280
281#ifdef __cplusplus
dsinclair5f597db2016-03-25 09:04:54 -0700282} // extern "C"
283#endif // __cplusplus
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700284
Tom Sepez9857e202015-05-13 17:09:26 -0700285#endif // PUBLIC_FPDF_DOC_H_