new Header()
A class which contains header APIs.
⚠ You must NOT instantiate this yourself. Access the header instance in setHeaderItems as follows:
Example
var viewerElement = document.getElementById('viewer'); var viewer = new PDFTron.WebViewer(...); const viewerElement = document.getElementById('viewer'); var instance = viewer.getInstance(); instance.setHeaderItems(header => { // instance of Header is passed to the callback // header.someMethod(); });
Methods
-
delete( [id])
-
Delete a button.
Parameters:
Name Type Argument Description id
number | string <optional>
You can either pass an index or
data-element
of the button to delete. If you already selected a button from get, passing null would delete the selected button.Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
- Type
- CoreControls.ReaderControl.Header
-
get(dataElement)
-
Select a button from header to edit.
Parameters:
Name Type Description dataElement
string data-element of the button.
Returns:
Header object for chaining. You can call insertBefore, insertAfter and delete to perform an operation on the button.
- Type
- CoreControls.ReaderControl.Header
-
getHeader(headerGroup)
-
Select a header group to edit.
Parameters:
Name Type Description headerGroup
string Name of the header group. By default, 'default' and 'tools' are accepted.
Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
- Type
- CoreControls.ReaderControl.Header
-
getItems()
-
Get all list of header items from a group selected from getHeader. By default, it returns the items from 'default' group.
Returns:
List of header item objects. You can edit it using normal array operations and update the whole header by passing it to update.
- Type
- Array.<object>
-
insertAfter()
-
Insert a button after the selected button from get.
Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
- Type
- CoreControls.ReaderControl.Header
-
insertBefore()
-
Insert a button before the selected button from get.
Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
- Type
- CoreControls.ReaderControl.Header
-
pop()
-
Removes the last button in the header.
Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
- Type
- CoreControls.ReaderControl.Header
-
push(obj)
-
Adds a button (or buttons) to the end of the header.
Parameters:
Name Type Description obj
object | Array.<object> Either one or array of header objects. See Header items for details.
Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
- Type
- CoreControls.ReaderControl.Header
-
shift()
-
Removes the first button in the header.
Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
- Type
- CoreControls.ReaderControl.Header
-
unshift(obj)
-
Adds a button (or buttons) to the beginning of the header.
Parameters:
Name Type Description obj
object | Array.<object> Either one or array of header objects. See Header items for details.
Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
- Type
- CoreControls.ReaderControl.Header
-
update(headerObjects)
-
Updates the header with new list of header items.
Parameters:
Name Type Description headerObjects
Array.<object> List of header objects to replace the exising header. You can use getItems to refer to existing header objects.
Returns:
Header object for chaining. You can call get, getItems, shift, unshift, push, pop and update.
- Type
- CoreControls.ReaderControl.Header