Global

Members

# (constant) animationStarted

Promise that is resolved when DOM window becomes visible.

# file :File

PDF file

Type:
  • File

Methods

# apiPageLayoutToSpreadMode(mode) → {number}

Converts API PageLayout values to the format used by BaseViewer. NOTE: This is supported to the extent that the viewer implements the necessary Scroll/Spread modes (since SinglePage, TwoPageLeft, and TwoPageRight all suggests using non-continuous scrolling).

Parameters:
Name Type Description
mode string

The API PageLayout value.

Returns:

A value from {SpreadMode}.

Type
number

# apiPageModeToSidebarView(mode) → {number}

Converts API PageMode values to the format used by PDFSidebar. NOTE: There's also a "FullScreen" parameter which is not possible to support, since the Fullscreen API used in browsers requires that entering fullscreen mode only occurs as a result of a user-initiated event.

Parameters:
Name Type Description
mode string

The API PageMode value.

Returns:

A value from {SidebarView}.

Type
number

# approximateFraction(x) → {Array}

Approximates float number as a fraction using Farey sequence (max order of 8).

Parameters:
Name Type Description
x number

Positive float number.

Returns:

Estimated fraction: the first array item is a numerator, the second one is a denominator.

Type
Array

# backtrackBeforeAllVisibleElements(index, views, top) → {number}

Helper function for getVisibleElements.

Parameters:
Name Type Description
index number

initial guess at the first visible element

views Array

array of pages, into which index is an index

top number

the top of the scroll pane

Returns:

less than or equal to index that is definitely at or before the first visible element in views, but not by too much. (Usually, this will be the first element in the first partially visible row in views, although sometimes it goes back one row further.)

Type
number

# binarySearchFirstItem() → {number}

Use binary search to find the index of the first item in a given array which passes a given condition. The items are expected to be sorted in the sense that if the condition is true for one item in the array, then it is also true for all following items.

Returns:

Index of the first array element to pass the test, or |items.length| if no such element exists.

Type
number

# dispatchDOMEvent()

NOTE: Only used to support various PDF viewer tests in mozilla-central.

# getActiveOrFocusedElement() → {Element}

Get the active or focused element in current DOM.

Recursively search for the truly active or focused element in case there are shadow DOMs.

Returns:

the truly active or focused element.

Type
Element

# getCharacterType()

This function is based on the word-break detection implemented in: https://hg.mozilla.org/mozilla-central/file/tip/intl/lwbrk/WordBreaker.cpp

# getFileById(id) → {File}

Retrieves a single file by id.

Parameters:
Name Type Description
id string

File identifier.

Source:
Returns:

File object.

Type
File

# getPageSizeInches(An) → {Object}

Gets the size of the specified page, converted from PDF units to inches.

Parameters:
Name Type Description
An Object

Object containing the properties: {Array} view, {number} userUnit, and {number} rotate.

Returns:

An Object containing the properties: {number} width and {number} height, given in inches.

Type
Object

# getVisibleElements() → {Object}

Generic helper to find out what elements are visible within a scroll pane.

Well, pretty generic. There are some assumptions placed on the elements referenced by views:

  • If horizontal, no left of any earlier element is to the right of the left of any later element.
  • Otherwise, views can be split into contiguous rows where, within a row, no top of any element is below the bottom of any other element, and between rows, no bottom of any element in an earlier row is below the top of any element in a later row.

(Here, top, left, etc. all refer to the padding edge of the element in question. For pages, that ends up being equivalent to the bounding box of the rendering canvas. Earlier and later refer to index in views, not page layout.)

Parameters:
Type Description
GetVisibleElementsParameters
Returns:

{ first, last, views: [{ id, x, y, view, percent }] }

Type
Object

# moveToEndOfArray()

Moves all elements of an array that satisfy condition to the end of the array, preserving the order of the rest.

# noContextMenuHandler()

Event handler to suppress context menu.

# parseQueryString()

Helper function to parse query string (e.g. ?param1=value&parm2=...).

# parseQueryString()

Helper function to parse query string (e.g. ?param1=value&parm2=...).

Source:

# tw2018func_getPageSizeInches(An) → {Object}

Gets the size of the specified page, converted from PDF units to inches.

Parameters:
Name Type Description
An Object

Object containing the properties: {Array} view, {number} userUnit, and {number} rotate.

Source:
Returns:

An Object containing the properties: {number} width and {number} height, given in inches.

Type
Object

# tw2018func_getPDFFileNameFromURL() → {String}

Returns the filename or guessed filename from the url (see issue 3455). url {String} The original PDF location.

Source:
Returns:

Guessed PDF file name.

Type
String

# waitOnEventOrTimeout() → {Promise}

Allows waiting for an event or a timeout, whichever occurs first. Can be used to ensure that an action always occurs, even when an event arrives late or not at all.

Parameters:
Type Description
WaitOnEventOrTimeoutParameters
Returns:

A promise that is resolved with a {WaitOnType} value.

Type
Promise

Type Definitions

# GetVisibleElementsParameters

Type:
  • Object
Properties
Name Type Description
scrollEl HTMLElement

A container that can possibly scroll.

views Array

Objects with a div property that contains an HTMLElement, which should all be descendants of scrollEl satisfying the relevant layout assumptions.

sortByVisibility boolean

If true, the returned elements are sorted in descending order of the percent of their padding box that is visible. The default value is false.

horizontal boolean

If true, the elements are assumed to be laid out horizontally instead of vertically. The default value is false.

rtl boolean

If true, the scrollEl container is assumed to be in right-to-left mode. The default value is false.

# WaitOnEventOrTimeoutParameters

Type:
  • Object
Properties
Name Type Description
target Object

The event target, can for example be: window, document, a DOM element, or an {EventBus} instance.

name string

The name of the event.

delay number

The delay, in milliseconds, after which the timeout occurs (if the event wasn't already dispatched).