Members
AbortException
Error used to indicate task cancellation.
- Source:
createPDFNetworkStream :IPDFStreamFactory
Type:
- Source:
FormatError
Error caused during parsing PDF data.
- Source:
Methods
arrayByteLength(arr) → {number}
Gets length of the array (Array, Uint8Array, or string) in bytes.
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array | Uint8Array | string |
- Source:
Returns:
- Type
- number
arraysToBytes(arr) → {Uint8Array}
Combines array items (arrays) into single Uint8Array object.
Parameters:
Name | Type | Description |
---|---|---|
arr |
Array | the array of the arrays (Array, Uint8Array, or string). |
- Source:
Returns:
- Type
- Uint8Array
createPromiseCapability() → {PromiseCapability}
Creates a promise capability object.
- Source:
Returns:
A capability object contains:
- a Promise, resolve and reject methods.
- Type
- PromiseCapability
createValidAbsoluteUrl(url, baseUrl) → {URL}
Attempts to create a valid absolute URL.
Parameters:
Name | Type | Description |
---|---|---|
url |
URL | string | An absolute, or relative, URL. |
baseUrl |
URL | string | An absolute URL. |
- Source:
Returns:
Either a valid , or `null` otherwise.
- Type
- URL
getDocument(src) → {PDFDocumentLoadingTask}
This is the main entry point for loading a PDF and interacting with it.
NOTE: If a URL is used to fetch the PDF data a standard XMLHttpRequest(XHR)
is used, which means it must follow the same origin rules that any XHR does
e.g. No cross domain requests without CORS.
Parameters:
Name | Type | Description |
---|---|---|
src |
string | TypedArray | DocumentInitParameters | PDFDataRangeTransport | Can be a url to where a PDF is located, a typed array (Uint8Array) already populated with data or parameter object. |
- Source:
Returns:
getInheritableProperty(dict, key, getArray, stopWhenFound)
Get the value of an inheritable property.
If the PDF specification explicitly lists a property in a dictionary as
inheritable, then the value of the property may be present in the dictionary
itself or in one or more parents of the dictionary.
If the key is not found in the tree, `undefined` is returned. Otherwise,
the value for the key is returned or, if `stopWhenFound` is `false`, a list
of values is returned. To avoid infinite loops, the traversal is stopped when
the loop limit is reached.
Parameters:
Name | Type | Description |
---|---|---|
dict |
Dict | Dictionary from where to start the traversal. |
key |
string | The key of the property to find the value for. |
getArray |
boolean | Whether or not the value should be fetched as an array. The default value is `false`. |
stopWhenFound |
boolean | Whether or not to stop the traversal when the key is found. If set to `false`, we always walk up the entire parent chain, for example to be able to find `\Resources` placed on multiple levels of the tree. The default value is `true`. |
- Source:
setPDFNetworkStreamFactory(pdfNetworkStreamFactory)
Sets the function that instantiates a IPDFStream as an alternative PDF data
transport.
Parameters:
Name | Type | Description |
---|---|---|
pdfNetworkStreamFactory |
IPDFStreamFactory | the factory function that takes document initialization parameters (including a "url") and returns an instance of IPDFStream. |
- Source:
toRomanNumerals(number, lowerCase) → {string}
Converts positive integers to (upper case) Roman numerals.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
number |
integer | The number that should be converted. | |
lowerCase |
boolean | false | Indicates if the result should be converted to lower case letters. The default value is `false`. |
- Source:
Returns:
The resulting Roman number.
- Type
- string
Type Definitions
DocumentInitParameters
Document initialization / loading parameters object.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
url |
string | The URL of the PDF. |
data |
TypedArray | Array | string | Binary PDF data. Use typed arrays (Uint8Array) to improve the memory usage. If PDF data is BASE64-encoded, use atob() to convert it to a binary string first. |
httpHeaders |
Object | Basic authentication headers. |
withCredentials |
boolean | Indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies or authorization headers. The default is false. |
password |
string | For decrypting password-protected PDFs. |
initialData |
TypedArray | A typed array with the first portion or all of the pdf data. Used by the extension since some data is already loaded before the switch to range requests. |
length |
number | The PDF file length. It's used for progress reports and range requests operations. |
range |
PDFDataRangeTransport | |
rangeChunkSize |
number | Optional parameter to specify maximum number of bytes fetched per range request. The default value is 2^16 = 65536. |
worker |
PDFWorker | (optional) The worker that will be used for the loading and parsing of the PDF data. |
postMessageTransfers |
boolean | (optional) Enables transfer usage in postMessage for ArrayBuffers. The default value is `true`. |
verbosity |
number | (optional) Controls the logging level; the constants from {VerbosityLevel} should be used. |
docBaseUrl |
string | (optional) The base URL of the document, used when attempting to recover valid absolute URLs for annotations, and outline items, that (incorrectly) only specify relative URLs. |
nativeImageDecoderSupport |
string | (optional) Strategy for decoding certain (simple) JPEG images in the browser. This is useful for environments without DOM image and canvas support, such as e.g. Node.js. Valid values are 'decode', 'display' or 'none'; where 'decode' is intended for browsers with full image/canvas support, 'display' for environments with limited image support through stubs (useful for SVG conversion), and 'none' where JPEG images will be decoded entirely by PDF.js. The default value is 'decode'. |
cMapUrl |
string | (optional) The URL where the predefined Adobe CMaps are located. Include trailing slash. |
cMapPacked |
boolean | (optional) Specifies if the Adobe CMaps are binary packed. |
CMapReaderFactory |
Object | (optional) The factory that will be used when reading built-in CMap files. Providing a custom factory is useful for environments without `XMLHttpRequest` support, such as e.g. Node.js. The default value is {DOMCMapReaderFactory}. |
stopAtErrors |
boolean | (optional) Reject certain promises, e.g. `getOperatorList`, `getTextContent`, and `RenderTask`, when the associated PDF data cannot be successfully parsed, instead of attempting to recover whatever possible of the data. The default value is `false`. |
maxImageSize |
number | (optional) The maximum allowed image size in total pixels, i.e. width * height. Images above this value will not be rendered. Use -1 for no limit, which is also the default value. |
isEvalSupported |
boolean | (optional) Determines if we can eval strings as JS. Primarily used to improve performance of font rendering, and when parsing PDF functions. The default value is `true`. |
disableFontFace |
boolean | (optional) By default fonts are converted to OpenType fonts and loaded via font face rules. If disabled, fonts will be rendered using a built-in font renderer that constructs the glyphs with primitive path commands. The default value is `false`. |
disableRange |
boolean | (optional) Disable range request loading of PDF files. When enabled, and if the server supports partial content requests, then the PDF will be fetched in chunks. The default value is `false`. |
disableStream |
boolean | (optional) Disable streaming of PDF file data. By default PDF.js attempts to load PDFs in chunks. The default value is `false`. |
disableAutoFetch |
boolean | (optional) Disable pre-fetching of PDF file data. When range requests are enabled PDF.js will automatically keep fetching more data even if it isn't needed to display the current page. The default value is `false`. NOTE: It is also necessary to disable streaming, see above, in order for disabling of pre-fetching to work correctly. |
disableCreateObjectURL |
boolean | (optional) Disable the use of `URL.createObjectURL`, for compatibility with older browsers. The default value is `false`. |
pdfBug |
boolean | (optional) Enables special hooks for debugging PDF.js (see `web/debugger.js`). The default value is `false`. |
- Source:
GetAnnotationsParameters
Page annotation parameters.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
intent |
string | Determines the annotations that will be fetched, can be either 'display' (viewable annotations) or 'print' (printable annotations). If the parameter is omitted, all annotations are fetched. |
- Source:
getTextContentParameters
Page getTextContent parameters.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
normalizeWhitespace |
boolean | replaces all occurrences of whitespace with standard spaces (0x20). The default value is `false`. |
disableCombineTextItems |
boolean | do not attempt to combine same line TextItem's. The default value is `false`. |
- Source:
IPDFStreamFactory(params) → {IPDFStream}
Parameters:
Name | Type | Description |
---|---|---|
params |
DocumentInitParameters | The document initialization parameters. The "url" key is always present. |
- Source:
Returns:
- Type
- IPDFStream
PDFDocumentStats
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
streamTypes |
Array | Used stream types in the document (an item is set to true if specific stream ID was used in the document). |
fontTypes |
Array | Used font type in the document (an item is set to true if specific font ID was used in the document). |
- Source:
PDFOperatorList
PDF page operator list.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
fnArray |
Array | Array containing the operator functions. |
argsArray |
Array | Array containing the arguments of the functions. |
- Source:
PDFWorkerParameters
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
name |
string | (optional) The name of the worker. |
port |
Object | (optional) The `workerPort`. |
postMessageTransfers |
boolean | (optional) Enables transfer usage in postMessage for ArrayBuffers. The default value is `true`. |
verbosity |
number | (optional) Controls the logging level; the constants from {VerbosityLevel} should be used. |
- Source:
PromiseCapability
Promise Capability object.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
promise |
Promise | A promise object. |
resolve |
function | Fulfills the promise. |
reject |
function | Rejects the promise. |
- Source:
RenderParameters
Page render parameters.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
canvasContext |
Object | A 2D context of a DOM Canvas object. |
viewport |
PageViewport | Rendering viewport obtained by calling of PDFPage.getViewport method. |
intent |
string | Rendering intent, can be 'display' or 'print' (default value is 'display'). |
enableWebGL |
boolean | (optional) Enables WebGL accelerated rendering for some operations. The default value is `false`. |
renderInteractiveForms |
boolean | (optional) Whether or not interactive form elements are rendered in the display layer. If so, we do not render them on canvas as well. |
transform |
Array | (optional) Additional transform, applied just before viewport transform. |
imageLayer |
Object | (optional) An object that has beginLayout, endLayout and appendImage functions. |
canvasFactory |
Object | (optional) The factory that will be used when creating canvases. The default value is {DOMCanvasFactory}. |
background |
Object | (optional) Background to use for the canvas.
Can use any valid canvas.fillStyle: A DOMString parsed as
CSS |
- Source:
TextContent
Page text content.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
items |
array | array of TextItem |
styles |
Object | TextStyles objects, indexed by font name. |
- Source:
TextItem
Page text content part.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
str |
string | text content. |
dir |
string | text direction: 'ttb', 'ltr' or 'rtl'. |
transform |
array | transformation matrix. |
width |
number | width in device space. |
height |
number | height in device space. |
fontName |
string | font name used by pdf.js for converted font. |
- Source:
TextStyle
Text style.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
ascent |
number | font ascent. |
descent |
number | font descent. |
vertical |
boolean | text is in vertical mode. |
fontFamily |
string | possible font family |
- Source: