Global

Members

(constant) animationStarted

Promise that is resolved when DOM window becomes visible.
Source:

(constant) defaultOptions

PLEASE NOTE: To avoid introducing unnecessary dependencies, we specify the values below *explicitly* rather than relying on imported types.
Source:

(constant) NullL10n

No-op implementation of the localization service.
Implements:
Source:

Methods

apiPageLayoutToSpreadMode(mode) → {number}

Converts API PageLayout values to the format used by `PDFViewer`. 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.
Source:
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.
Source:
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.
Source:
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
Source:
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.
Source:
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`.
Source:

getCharacterType()

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

getOutputScale() → {Object}

Returns scale factor for the canvas. It makes sense for the HiDPI displays.
Source:
Returns:
The object with horizontal (sx) and vertical (sy) scales. The scaled property is set to false if scaling is not required, true otherwise.
Type
Object

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

getPDFFileNameFromURL(url, defaultFilename) → {string}

Returns the filename or guessed filename from the url (see issue 3455).
Parameters:
Name Type Description
url string The original PDF location.
defaultFilename string The value returned if the filename is unknown, or the protocol is unsupported.
Source:
Returns:
Guessed PDF filename.
Type
string

getVisibleElements(scrollEl, views, sortByVisibility, horizontal) → {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:
Name Type Default Description
scrollEl HTMLElement a container that can possibly scroll
views Array objects with a `div` property that contains an HTMLElement, which should all be descendents of `scrollEl` satisfying the above layout assumptions
sortByVisibility boolean false if true, the returned elements are sorted in descending order of the percent of their padding box that is visible
horizontal boolean false if true, the elements are assumed to be laid out horizontally instead of vertically
Source:
Returns:
`{ first, last, views: [{ id, x, y, view, percent }] }`
Type
Object

GrabToPan()

Construct a GrabToPan instance for a given HTML element.
Parameters:
Name Type Description
options.element Element
options.ignoreTarget function optional. See `ignoreTarget(node)`
options.onActiveChanged function optional. Called when grab-to-pan is (de)activated. The first argument is a boolean that shows whether grab-to-pan is activated.
Source:

isLeftMouseReleased(event) → {boolean}

Whether the left mouse is not pressed.
Parameters:
Name Type Description
event MouseEvent
Source:
Returns:
True if the left mouse button is not pressed, False if unsure or if the left mouse button is pressed.
Type
boolean

moveToEndOfArray()

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

noContextMenuHandler()

Event handler to suppress context menu.
Source:

parseQueryString()

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

resize()

After calling resize, the size of the buffer will be newSize. The optional parameter pagesToKeep is, if present, an array of pages to push to the back of the buffer, delaying their destruction. The size of pagesToKeep has no impact on the final size of the buffer; if pagesToKeep has length larger than newSize, some of those pages will be destroyed anyway.
Source:

scrollIntoView(element, spot, skipOverflowHiddenElements)

Scrolls specified element into view of its parent.
Parameters:
Name Type Default Description
element Object The element to be visible.
spot Object An object with optional top and left properties, specifying the offset from the top left edge.
skipOverflowHiddenElements boolean false Ignore elements that have the CSS rule `overflow: hidden;` set. The default is false.
Source:

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
Source:
Returns:
A promise that is resolved with a {WaitOnType} value.
Type
Promise

watchScroll()

Helper function to start monitoring the scroll event and converting them into PDF.js friendly one: with scroll debounce and scroll direction.
Source:

Type Definitions

AnnotationLayerBuilderOptions

Type:
  • Object
Properties:
Name Type Attributes Description
pageDiv HTMLDivElement
pdfPage PDFPage
annotationStorage AnnotationStorage <optional>
imageResourcesPath string <optional>
Path for image resources, mainly for annotation icons. Include trailing slash.
renderInteractiveForms boolean
linkService IPDFLinkService
downloadManager DownloadManager
l10n IL10n Localization service.
Source:

InitializeParameters

Type:
  • Object
Properties:
Name Type Attributes Description
fingerprint string The PDF document's unique fingerprint.
resetHistory boolean <optional>
Reset the browsing history.
updateUrl boolean <optional>
Attempt to update the document URL, with the current hash, when pushing/replacing browser history entries.
Source:

PasswordPromptOptions

Type:
  • Object
Properties:
Name Type Description
overlayName string Name of the overlay for the overlay manager.
container HTMLDivElement Div container for the overlay.
label HTMLParagraphElement Label containing instructions for entering the password.
input HTMLInputElement Input field for entering the password.
submitButton HTMLButtonElement Button for submitting the password.
cancelButton HTMLButtonElement Button for cancelling password entry.
Source:

PDFAttachmentViewerOptions

Type:
  • Object
Properties:
Name Type Description
container HTMLDivElement The viewer element.
eventBus EventBus The application event bus.
downloadManager DownloadManager The download manager.
Source:

PDFAttachmentViewerRenderParameters

Type:
  • Object
Properties:
Name Type Description
attachments Object | null A lookup table of attachment objects.
Source:

PDFCursorToolsOptions

Type:
  • Object
Properties:
Name Type Attributes Description
container HTMLDivElement The document container.
eventBus EventBus The application event bus.
cursorToolOnLoad number <optional>
The cursor tool that will be enabled on load; the constants from {CursorTool} should be used. The default value is `CursorTool.SELECT`.
Source:

PDFDocumentPropertiesOptions

Type:
  • Object
Properties:
Name Type Description
overlayName string Name/identifier for the overlay.
fields Object Names and elements of the overlay's fields.
container HTMLDivElement Div container for the overlay.
closeButton HTMLButtonElement Button for closing the overlay.
Source:

PDFFindControllerOptions

Type:
  • Object
Properties:
Name Type Description
linkService IPDFLinkService The navigation/linking service.
eventBus EventBus The application event bus.
Source:

PDFHistoryOptions

Type:
  • Object
Properties:
Name Type Description
linkService IPDFLinkService The navigation/linking service.
eventBus EventBus The application event bus.
Source:

PDFLayerViewerOptions

Type:
  • Object
Properties:
Name Type Description
container HTMLDivElement The viewer element.
eventBus EventBus The application event bus.
l10n IL10n Localization service.
Source:

PDFLayerViewerRenderParameters

Type:
  • Object
Properties:
Name Type Description
optionalContentConfig OptionalContentConfig | null An {OptionalContentConfig} instance.
pdfDocument PDFDocument A {PDFDocument} instance.
Source:

PDFLinkServiceOptions

Type:
  • Object
Properties:
Name Type Attributes Description
eventBus EventBus The application event bus.
externalLinkTarget number <optional>
Specifies the `target` attribute for external links. Must use one of the values from {LinkTarget}. Defaults to using no target.
externalLinkRel string <optional>
Specifies the `rel` attribute for external links. Defaults to stripping the referrer.
ignoreDestinationZoom boolean <optional>
Ignores the zoom argument, thus preserving the current zoom level in the viewer, when navigating to internal destinations. The default value is `false`.
Source:

PDFOutlineViewerOptions

Type:
  • Object
Properties:
Name Type Description
container HTMLDivElement The viewer element.
linkService IPDFLinkService The navigation/linking service.
eventBus EventBus The application event bus.
Source:

PDFOutlineViewerRenderParameters

Type:
  • Object
Properties:
Name Type Description
outline Array | null An array of outline objects.
Source:

PDFPageViewOptions

Type:
  • Object
Properties:
Name Type Attributes Description
container HTMLDivElement The viewer element.
eventBus EventBus The application event bus.
id number The page unique ID (normally its number).
scale number The page scale display.
defaultViewport PageViewport The page viewport.
annotationStorage AnnotationStorage <optional>
Storage for annotation data in forms. The default value is `null`.
optionalContentConfigPromise Promise.<OptionalContentConfig> <optional>
A promise that is resolved with an OptionalContentConfig instance. The default value is `null`.
renderingQueue PDFRenderingQueue The rendering queue object.
textLayerFactory IPDFTextLayerFactory
textLayerMode number <optional>
Controls if the text layer used for selection and searching is created, and if the improved text selection behaviour is enabled. The constants from {TextLayerMode} should be used. The default value is `TextLayerMode.ENABLE`.
annotationLayerFactory IPDFAnnotationLayerFactory
imageResourcesPath string <optional>
Path for image resources, mainly for annotation icons. Include trailing slash.
renderInteractiveForms boolean Turns on rendering of interactive form elements. The default value is `true`.
renderer string 'canvas' or 'svg'. The default is 'canvas'.
enableWebGL boolean <optional>
Enables WebGL accelerated rendering for some operations. The default value is `false`.
useOnlyCssZoom boolean <optional>
Enables CSS only zooming. The default value is `false`.
maxCanvasPixels number <optional>
The maximum supported canvas size in total pixels, i.e. width * height. Use -1 for no limit. The default value is 4096 * 4096 (16 mega-pixels).
l10n IL10n Localization service.
Source:

PDFPresentationModeOptions

Type:
  • Object
Properties:
Name Type Attributes Description
container HTMLDivElement The container for the viewer element.
pdfViewer PDFViewer The document viewer.
eventBus EventBus The application event bus.
contextMenuItems Array <optional>
The menu items that are added to the context menu in Presentation Mode.
Source:

PDFSidebarElements

Type:
  • Object
Properties:
Name Type Description
outerContainer HTMLDivElement The outer container (encasing both the viewer and sidebar elements).
viewerContainer HTMLDivElement The viewer container (in which the viewer element is placed).
toggleButton HTMLButtonElement The button used for opening/closing the sidebar.
thumbnailButton HTMLButtonElement The button used to show the thumbnail view.
outlineButton HTMLButtonElement The button used to show the outline view.
attachmentsButton HTMLButtonElement The button used to show the attachments view.
layersButton HTMLButtonElement The button used to show the layers view.
thumbnailView HTMLDivElement The container in which the thumbnails are placed.
outlineView HTMLDivElement The container in which the outline is placed.
attachmentsView HTMLDivElement The container in which the attachments are placed.
layersView HTMLDivElement The container in which the layers are placed.
Source:

PDFSidebarOptions

Type:
  • Object
Properties:
Name Type Attributes Description
elements PDFSidebarElements The DOM elements.
pdfViewer PDFViewer The document viewer.
pdfThumbnailViewer PDFThumbnailViewer The thumbnail viewer.
eventBus EventBus The application event bus.
l10n IL10n The localization service.
disableNotification boolean <optional>
Disable the notification for documents containing outline/attachments. The default value is `false`.
Source:

PDFSidebarResizerOptions

Type:
  • Object
Properties:
Name Type Description
outerContainer HTMLDivElement The outer container (encasing both the viewer and sidebar elements).
resizer HTMLDivElement The DOM element that can be dragged in order to adjust the width of the sidebar.
Source:

PDFThumbnailViewerOptions

Type:
  • Object
Properties:
Name Type Description
container HTMLDivElement The container for the thumbnail elements.
eventBus EventBus The application event bus.
linkService IPDFLinkService The navigation/linking service.
renderingQueue PDFRenderingQueue The rendering queue object.
l10n IL10n Localization service.
Source:

PDFThumbnailViewOptions

Type:
  • Object
Properties:
Name Type Attributes Description
container HTMLDivElement The viewer element.
id number The thumbnail's unique ID (normally its number).
defaultViewport PageViewport The page viewport.
optionalContentConfigPromise Promise.<OptionalContentConfig> <optional>
A promise that is resolved with an OptionalContentConfig instance. The default value is `null`.
linkService IPDFLinkService The navigation/linking service.
renderingQueue PDFRenderingQueue The rendering queue object.
checkSetImageDisabled function
disableCanvasToImageConversion boolean <optional>
Don't convert the canvas thumbnails to images. This prevents `toDataURL` calls, but increases the overall memory usage. The default value is `false`.
l10n IL10n Localization service.
Source:

PDFViewerOptions

Type:
  • Object
Properties:
Name Type Attributes Description
container HTMLDivElement The container for the viewer element.
viewer HTMLDivElement <optional>
The viewer element.
eventBus EventBus The application event bus.
linkService IPDFLinkService The navigation/linking service.
downloadManager DownloadManager <optional>
The download manager component.
findController PDFFindController <optional>
The find controller component.
renderingQueue PDFRenderingQueue <optional>
The rendering queue object.
removePageBorders boolean <optional>
Removes the border shadow around the pages. The default value is `false`.
textLayerMode number <optional>
Controls if the text layer used for selection and searching is created, and if the improved text selection behaviour is enabled. The constants from {TextLayerMode} should be used. The default value is `TextLayerMode.ENABLE`.
imageResourcesPath string <optional>
Path for image resources, mainly mainly for annotation icons. Include trailing slash.
renderInteractiveForms boolean <optional>
Enables rendering of interactive form elements. The default value is `true`.
enablePrintAutoRotate boolean <optional>
Enables automatic rotation of landscape pages upon printing. The default is `false`.
renderer string 'canvas' or 'svg'. The default is 'canvas'.
enableWebGL boolean <optional>
Enables WebGL accelerated rendering for some operations. The default value is `false`.
useOnlyCssZoom boolean <optional>
Enables CSS only zooming. The default value is `false`.
maxCanvasPixels number <optional>
The maximum supported canvas size in total pixels, i.e. width * height. Use -1 for no limit. The default value is 4096 * 4096 (16 mega-pixels).
l10n IL10n Localization service.
Source:

PushParameters

Type:
  • Object
Properties:
Name Type Attributes Description
namedDest string <optional>
The named destination. If absent, a stringified version of `explicitDest` is used.
explicitDest Array The explicit destination array.
pageNumber number The page to which the destination points.
Source:

ScrollPageIntoViewParameters

Properties:
Name Type Attributes Description
pageNumber number The page number.
destArray Array <optional>
The original PDF destination array, in the format:
allowNegativeOffset boolean <optional>
Allow negative page offsets. The default value is `false`.
ignoreDestinationZoom boolean <optional>
Ignore the zoom argument in the destination array. The default value is `false`.
Source:

SecondaryToolbarOptions

Type:
  • Object
Properties:
Name Type Description
toolbar HTMLDivElement Container for the secondary toolbar.
toggleButton HTMLButtonElement Button to toggle the visibility of the secondary toolbar.
toolbarButtonContainer HTMLDivElement Container where all the toolbar buttons are placed. The maximum height of the toolbar is controlled dynamically by adjusting the 'max-height' CSS property of this DOM element.
presentationModeButton HTMLButtonElement Button for entering presentation mode.
openFileButton HTMLButtonElement Button to open a file.
printButton HTMLButtonElement Button to print the document.
downloadButton HTMLButtonElement Button to download the document.
viewBookmarkButton HTMLLinkElement Button to obtain a bookmark link to the current location in the document.
firstPageButton HTMLButtonElement Button to go to the first page in the document.
lastPageButton HTMLButtonElement Button to go to the last page in the document.
pageRotateCwButton HTMLButtonElement Button to rotate the pages clockwise.
pageRotateCcwButton HTMLButtonElement Button to rotate the pages counterclockwise.
cursorSelectToolButton HTMLButtonElement Button to enable the select tool.
cursorHandToolButton HTMLButtonElement Button to enable the hand tool.
documentPropertiesButton HTMLButtonElement Button for opening the document properties dialog.
Source:

TextLayerBuilderOptions

Type:
  • Object
Properties:
Name Type Description
textLayerDiv HTMLDivElement The text layer container.
eventBus EventBus The application event bus.
pageIndex number The page index.
viewport PageViewport The viewport of the text layer.
findController PDFFindController
enhanceTextSelection boolean Option to turn on improved text selection.
Source:

ToolbarOptions

Type:
  • Object
Properties:
Name Type Description
container HTMLDivElement Container for the secondary toolbar.
numPages HTMLSpanElement Label that contains number of pages.
pageNumber HTMLInputElement Control for display and user input of the current page number.
scaleSelectContainer HTMLSpanElement Container where scale controls are placed. The width is adjusted on UI initialization.
scaleSelect HTMLSelectElement Scale selection control.
customScaleOption HTMLOptionElement The item used to display a non-predefined scale.
previous HTMLButtonElement Button to go to the previous page.
next HTMLButtonElement Button to go to the next page.
zoomIn HTMLButtonElement Button to zoom in the pages.
zoomOut HTMLButtonElement Button to zoom out the pages.
viewFind HTMLButtonElement Button to open find bar.
openFile HTMLButtonElement Button to open a new document.
presentationModeButton HTMLButtonElement Button to switch to presentation mode.
download HTMLButtonElement Button to download the document.
viewBookmark HTMLAElement Element to link current url of the page view.
Source:

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).
Source: