1 // Copyright 2016 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_STRUCTTREE_H_ 8 #define PUBLIC_FPDF_STRUCTTREE_H_ 9 10 // NOLINTNEXTLINE(build/include) 11 #include "fpdfview.h" 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 // Function: FPDF_StructTree_GetForPage 18 // Get the structure tree for a page. 19 // Parameters: 20 // page - Handle to the page. Returned by FPDF_LoadPage 21 // function. 22 // Return value: 23 // A handle to the structure tree or NULL on error. 24 FPDF_EXPORT FPDF_STRUCTTREE FPDF_CALLCONV 25 FPDF_StructTree_GetForPage(FPDF_PAGE page); 26 27 // Function: FPDF_StructTree_Close 28 // Release the resource allocate by FPDF_StructTree_GetForPage. 29 // Parameters: 30 // struct_tree - Handle to the struct tree. Returned by 31 // FPDF_StructTree_LoadPage function. 32 // Return value: 33 // NULL 34 FPDF_EXPORT void FPDF_CALLCONV 35 FPDF_StructTree_Close(FPDF_STRUCTTREE struct_tree); 36 37 // Function: FPDF_StructTree_CountChildren 38 // Count the number of children for the structure tree. 39 // Parameters: 40 // struct_tree - Handle to the struct tree. Returned by 41 // FPDF_StructTree_LoadPage function. 42 // Return value: 43 // The number of children, or -1 on error. 44 FPDF_EXPORT int FPDF_CALLCONV 45 FPDF_StructTree_CountChildren(FPDF_STRUCTTREE struct_tree); 46 47 // Function: FPDF_StructTree_GetChildAtIndex 48 // Get a child in the structure tree. 49 // Parameters: 50 // struct_tree - Handle to the struct tree. Returned by 51 // FPDF_StructTree_LoadPage function. 52 // index - The index for the child, 0-based. 53 // Return value: 54 // The child at the n-th index or NULL on error. 55 FPDF_EXPORT FPDF_STRUCTELEMENT FPDF_CALLCONV 56 FPDF_StructTree_GetChildAtIndex(FPDF_STRUCTTREE struct_tree, int index); 57 58 // Function: FPDF_StructElement_GetAltText 59 // Get the alt text for a given element. 60 // Parameters: 61 // struct_element - Handle to the struct element. 62 // buffer - A buffer for output the alt text. May be NULL. 63 // buflen - The length of the buffer, in bytes. May be 0. 64 // Return value: 65 // The number of bytes in the title, including the terminating NUL 66 // character. The number of bytes is returned regardless of the 67 // |buffer| and |buflen| parameters. 68 // Comments: 69 // Regardless of the platform, the |buffer| is always in UTF-16LE 70 // encoding. The string is terminated by a UTF16 NUL character. If 71 // |buflen| is less than the required length, or |buffer| is NULL, 72 // |buffer| will not be modified. 73 FPDF_EXPORT unsigned long FPDF_CALLCONV 74 FPDF_StructElement_GetAltText(FPDF_STRUCTELEMENT struct_element, 75 void* buffer, 76 unsigned long buflen); 77 78 // Function: FPDF_StructElement_GetMarkedContentID 79 // Get the marked content ID for a given element. 80 // Parameters: 81 // struct_element - Handle to the struct element. 82 // Return value: 83 // The marked content ID of the element. If no ID exists, returns 84 // -1. 85 FPDF_EXPORT int FPDF_CALLCONV 86 FPDF_StructElement_GetMarkedContentID(FPDF_STRUCTELEMENT struct_element); 87 88 // Function: FPDF_StructElement_GetType 89 // Get the type (/S) for a given element. 90 // Parameters: 91 // struct_element - Handle to the struct element. 92 // buffer - A buffer for output. May be NULL. 93 // buflen - The length of the buffer, in bytes. May be 0. 94 // Return value: 95 // The number of bytes in the type, including the terminating NUL 96 // character. The number of bytes is returned regardless of the 97 // |buffer| and |buflen| parameters. 98 // Comments: 99 // Regardless of the platform, the |buffer| is always in UTF-16LE 100 // encoding. The string is terminated by a UTF16 NUL character. If 101 // |buflen| is less than the required length, or |buffer| is NULL, 102 // |buffer| will not be modified. 103 FPDF_EXPORT unsigned long FPDF_CALLCONV 104 FPDF_StructElement_GetType(FPDF_STRUCTELEMENT struct_element, 105 void* buffer, 106 unsigned long buflen); 107 108 // Function: FPDF_StructElement_GetTitle 109 // Get the title (/T) for a given element. 110 // Parameters: 111 // struct_element - Handle to the struct element. 112 // buffer - A buffer for output. May be NULL. 113 // buflen - The length of the buffer, in bytes. May be 0. 114 // Return value: 115 // The number of bytes in the title, including the terminating NUL 116 // character. The number of bytes is returned regardless of the 117 // |buffer| and |buflen| parameters. 118 // Comments: 119 // Regardless of the platform, the |buffer| is always in UTF-16LE 120 // encoding. The string is terminated by a UTF16 NUL character. If 121 // |buflen| is less than the required length, or |buffer| is NULL, 122 // |buffer| will not be modified. 123 FPDF_EXPORT unsigned long FPDF_CALLCONV 124 FPDF_StructElement_GetTitle(FPDF_STRUCTELEMENT struct_element, 125 void* buffer, 126 unsigned long buflen); 127 128 // Function: FPDF_StructElement_CountChildren 129 // Count the number of children for the structure element. 130 // Parameters: 131 // struct_element - Handle to the struct element. 132 // Return value: 133 // The number of children, or -1 on error. 134 FPDF_EXPORT int FPDF_CALLCONV 135 FPDF_StructElement_CountChildren(FPDF_STRUCTELEMENT struct_element); 136 137 // Function: FPDF_StructElement_GetChildAtIndex 138 // Get a child in the structure element. 139 // Parameters: 140 // struct_tree - Handle to the struct element. 141 // index - The index for the child, 0-based. 142 // Return value: 143 // The child at the n-th index or NULL on error. 144 // Comments: 145 // If the child exists but is not an element, then this function will 146 // return NULL. This will also return NULL for out of bounds indices. 147 FPDF_EXPORT FPDF_STRUCTELEMENT FPDF_CALLCONV 148 FPDF_StructElement_GetChildAtIndex(FPDF_STRUCTELEMENT struct_element, 149 int index); 150 151 #ifdef __cplusplus 152 } // extern "C" 153 #endif 154 155 #endif // PUBLIC_FPDF_STRUCTTREE_H_ 156