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. 4 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 6 7 #ifndef PUBLIC_FPDF_DOC_H_ 8 #define PUBLIC_FPDF_DOC_H_ 9 10 // NOLINTNEXTLINE(build/include) 11 #include "fpdfview.h" 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif // __cplusplus 16 17 // 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 27 28 typedef 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; 37 } FS_QUADPOINTSF; 38 39 // Get the first child of |bookmark|, or the first top-level bookmark item. 40 // 41 // 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. 47 DLLEXPORT FPDF_BOOKMARK STDCALL 48 FPDFBookmark_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. 57 DLLEXPORT FPDF_BOOKMARK STDCALL 58 FPDFBookmark_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 71 // string is terminated by a UTF16 NUL character. If |buflen| is less than the 72 // required length, or |buffer| is NULL, |buffer| will not be modified. 73 DLLEXPORT 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|. 86 DLLEXPORT 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|. 96 DLLEXPORT 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. 106 DLLEXPORT 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 118 DLLEXPORT 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|. 131 DLLEXPORT 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 // 141 // Returns the number of bytes in the file path, including the trailing UTF16 142 // NUL character. 143 // 144 // Regardless of the platform, the |buffer| is always in UTF-16LE encoding. 145 // If |buflen| is less than the returned length, or |buffer| is NULL, |buffer| 146 // will not be modified. 147 DLLEXPORT unsigned long STDCALL 148 FPDFAction_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 // 159 // The |buffer| is always encoded in 7-bit ASCII. If |buflen| is less than the 160 // returned length, or |buffer| is NULL, |buffer| will not be modified. 161 DLLEXPORT 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. 172 DLLEXPORT unsigned long STDCALL FPDFDest_GetPageIndex(FPDF_DOCUMENT document, 173 FPDF_DEST dest); 174 175 // 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. 189 DLLEXPORT 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 197 // 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|. 207 DLLEXPORT 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|. 222 DLLEXPORT int STDCALL 223 FPDFLink_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|. 233 DLLEXPORT 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. 241 DLLEXPORT 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. 251 DLLEXPORT 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. 261 DLLEXPORT 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. 269 DLLEXPORT 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. 278 DLLEXPORT FPDF_BOOL STDCALL FPDFLink_GetQuadPoints(FPDF_LINK linkAnnot, 279 int quadIndex, 280 FS_QUADPOINTSF* quadPoints); 281 282 // Get meta-data |tag| content from |document|. 283 // 284 // 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. 293 // 294 // Returns the number of bytes in the tag, including trailing zeros. 295 // 296 // The |buffer| is always encoded in UTF-16LE. The |buffer| is followed by two 297 // bytes of zeros indicating the end of the string. If |buflen| is less than 298 // the returned length, or |buffer| is NULL, |buffer| will not be modified. 299 DLLEXPORT unsigned long STDCALL FPDF_GetMetaText(FPDF_DOCUMENT document, 300 FPDF_BYTESTRING tag, 301 void* buffer, 302 unsigned long buflen); 303 304 // 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. 316 DLLEXPORT unsigned long STDCALL FPDF_GetPageLabel(FPDF_DOCUMENT document, 317 int page_index, 318 void* buffer, 319 unsigned long buflen); 320 321 #ifdef __cplusplus 322 } // extern "C" 323 #endif // __cplusplus 324 325 #endif // PUBLIC_FPDF_DOC_H_ 326