John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // 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 Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 7 | #ifndef PUBLIC_FPDF_DOC_H_ |
| 8 | #define PUBLIC_FPDF_DOC_H_ |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 9 | |
| 10 | #include "fpdfview.h" |
| 11 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 12 | #ifdef __cplusplus |
| 13 | extern "C" { |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 14 | #endif // __cplusplus |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 15 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 16 | // 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 Xu | 4d62b6b | 2015-01-10 22:52:59 -0800 | [diff] [blame] | 26 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 27 | typedef 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 36 | } FS_QUADPOINTSF; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 37 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 38 | // Get the first child of |bookmark|, or the first top-level bookmark item. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 39 | // |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 40 | // 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. |
| 46 | DLLEXPORT FPDF_BOOKMARK STDCALL |
| 47 | FPDFBookmark_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. |
| 56 | DLLEXPORT FPDF_BOOKMARK STDCALL |
| 57 | FPDFBookmark_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. |
| 72 | DLLEXPORT 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|. |
| 85 | DLLEXPORT 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|. |
| 95 | DLLEXPORT 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. |
| 105 | DLLEXPORT 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 |
| 117 | DLLEXPORT 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|. |
| 130 | DLLEXPORT 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. |
| 146 | DLLEXPORT unsigned long STDCALL |
| 147 | FPDFAction_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. |
| 160 | DLLEXPORT 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. |
| 171 | DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, |
| 172 | FPDF_DEST dest); |
| 173 | |
dsinclair | c59fa88 | 2016-11-08 06:55:40 -0800 | [diff] [blame] | 174 | // 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. |
| 188 | DLLEXPORT 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 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 196 | // 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|. |
| 206 | DLLEXPORT 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|. |
| 221 | DLLEXPORT int STDCALL |
| 222 | FPDFLink_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|. |
| 232 | DLLEXPORT 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. |
| 240 | DLLEXPORT 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. |
| 250 | DLLEXPORT 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. |
| 260 | DLLEXPORT 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. |
| 268 | DLLEXPORT 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 Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 277 | DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot, |
| 278 | int quadIndex, |
| 279 | FS_QUADPOINTSF* quadPoints); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 280 | |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 281 | // Get meta-data |tag| content from |document|. |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 282 | // |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 283 | // 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 292 | // |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 293 | // 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 |
thestig | 04bebfe | 2016-11-04 16:07:25 -0700 | [diff] [blame] | 296 | // bytes of zeros indicating the end of the string. If |buflen| is less than |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 297 | // the returned length, or |buffer| is NULL, |buffer| will not be modified. |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 298 | DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT doc, |
| 299 | FPDF_BYTESTRING tag, |
| 300 | void* buffer, |
| 301 | unsigned long buflen); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 302 | |
| 303 | #ifdef __cplusplus |
dsinclair | 5f597db | 2016-03-25 09:04:54 -0700 | [diff] [blame] | 304 | } // extern "C" |
| 305 | #endif // __cplusplus |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 306 | |
Tom Sepez | 9857e20 | 2015-05-13 17:09:26 -0700 | [diff] [blame] | 307 | #endif // PUBLIC_FPDF_DOC_H_ |