blob: 9cf46cc30656dd51b51baca454680d8aeebd1d6f [file] [log] [blame]
thestig9067fd62016-11-23 14:10:06 -08001// 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
14extern "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.
24DLLEXPORT FPDF_STRUCTTREE STDCALL FPDF_StructTree_GetForPage(FPDF_PAGE page);
25
26// Function: FPDF_StructTree_Close
27// Release the resource allocate by FPDF_StructTree_GetForPage.
28// Parameters:
29// struct_tree - Handle to the struct tree. Returned by
30// FPDF_StructTree_LoadPage function.
31// Return value:
32// NULL
33DLLEXPORT void STDCALL FPDF_StructTree_Close(FPDF_STRUCTTREE struct_tree);
34
35// Function: FPDF_StructTree_CountChildren
36// Count the number of children for the structure tree.
37// Parameters:
38// struct_tree - Handle to the struct tree. Returned by
39// FPDF_StructTree_LoadPage function.
40// Return value:
41// The number of children, or -1 on error.
42DLLEXPORT int STDCALL
43FPDF_StructTree_CountChildren(FPDF_STRUCTTREE struct_tree);
44
45// Function: FPDF_StructTree_GetChildAtIndex
46// Get a child in the structure tree.
47// Parameters:
48// struct_tree - Handle to the struct tree. Returned by
49// FPDF_StructTree_LoadPage function.
50// index - The index for the child, 0-based.
51// Return value:
52// The child at the n-th index or NULL on error.
53DLLEXPORT FPDF_STRUCTELEMENT STDCALL
54FPDF_StructTree_GetChildAtIndex(FPDF_STRUCTTREE struct_tree, int index);
55
56// Function: FPDF_StructElement_GetAltText
57// Get the alt text for a given element.
58// Parameters:
59// struct_element - Handle to the struct element.
60// buffer - A buffer for output the alt text. May be NULL.
61// buflen - The length of the buffer, in bytes. May be 0.
62// Return value:
63// The number of bytes in the title, including the terminating NUL
64// character. The number of bytes is returned regardless of the
65// |buffer| and |buflen| parameters.
66// Comments:
67// Regardless of the platform, the |buffer| is always in UTF-16LE
68// encoding. The string is terminated by a UTF16 NUL character. If
69// |buflen| is less than the required length, or |buffer| is NULL,
70// |buffer| will not be modified.
71DLLEXPORT unsigned long STDCALL
72FPDF_StructElement_GetAltText(FPDF_STRUCTELEMENT struct_element,
73 void* buffer,
74 unsigned long buflen);
75
Dan Sinclair29479f62017-04-04 10:48:19 -040076// Function: FPDF_StructElement_GetType
77// Get the type (/S) for a given element.
78// Parameters:
79// struct_element - Handle to the struct element.
80// buffer - A buffer for output. May be NULL.
81// buflen - The length of the buffer, in bytes. May be 0.
82// Return value:
83// The number of bytes in the type, including the terminating NUL
84// character. The number of bytes is returned regardless of the
85// |buffer| and |buflen| parameters.
86// Comments:
87// Regardless of the platform, the |buffer| is always in UTF-16LE
88// encoding. The string is terminated by a UTF16 NUL character. If
89// |buflen| is less than the required length, or |buffer| is NULL,
90// |buffer| will not be modified.
91DLLEXPORT unsigned long STDCALL
92FPDF_StructElement_GetType(FPDF_STRUCTELEMENT struct_element,
93 void* buffer,
94 unsigned long buflen);
95
dan sinclaird9dad3a2017-04-06 14:44:02 -040096// Function: FPDF_StructElement_GetTitle
97// Get the title (/T) for a given element.
98// Parameters:
99// struct_element - Handle to the struct element.
100// buffer - A buffer for output. May be NULL.
101// buflen - The length of the buffer, in bytes. May be 0.
102// Return value:
103// The number of bytes in the title, including the terminating NUL
104// character. The number of bytes is returned regardless of the
105// |buffer| and |buflen| parameters.
106// Comments:
107// Regardless of the platform, the |buffer| is always in UTF-16LE
108// encoding. The string is terminated by a UTF16 NUL character. If
109// |buflen| is less than the required length, or |buffer| is NULL,
110// |buffer| will not be modified.
111DLLEXPORT unsigned long STDCALL
112FPDF_StructElement_GetTitle(FPDF_STRUCTELEMENT struct_element,
113 void* buffer,
114 unsigned long buflen);
115
thestig9067fd62016-11-23 14:10:06 -0800116// Function: FPDF_StructElement_CountChildren
117// Count the number of children for the structure element.
118// Parameters:
119// struct_element - Handle to the struct element.
120// Return value:
121// The number of children, or -1 on error.
122DLLEXPORT int STDCALL
123FPDF_StructElement_CountChildren(FPDF_STRUCTELEMENT struct_element);
124
125// Function: FPDF_StructElement_GetChildAtIndex
126// Get a child in the structure element.
127// Parameters:
128// struct_tree - Handle to the struct element.
129// index - The index for the child, 0-based.
130// Return value:
131// The child at the n-th index or NULL on error.
132// Comments:
133// If the child exists but is not an element, then this function will
134// return NULL. This will also return NULL for out of bounds indices.
135DLLEXPORT FPDF_STRUCTELEMENT STDCALL
136FPDF_StructElement_GetChildAtIndex(FPDF_STRUCTELEMENT struct_element,
137 int index);
138
139#ifdef __cplusplus
Dan Sinclairddcb6e72017-04-05 10:30:33 -0400140} // extern "C"
thestig9067fd62016-11-23 14:10:06 -0800141#endif
142
143#endif // PUBLIC_FPDF_STRUCTTREE_H_