Vue3 Vue Pdf

Posted on  by admin

vue.js pdf viewer.

Browser support

Example - basic

Note

TBD: fix the demo.

Credits

Same browser support as Vue.js 2.

Examples

since v2.x, the script is exported as esm.

API

Demo

Events

The url of the pdf file. src may also be a string|TypedArray|DocumentInitParameters|PDFDataRangeTransport for more details, see PDFJS.getDocument(). The page number to display.

Props

The page rotation in degrees, only multiple of 90 are valid.

Public methods

updatePassword: The function to call with the pdf password.

Install

Public static methods

  • reason: the reason why this function is called 'NEED_PASSWORD' or 'INCORRECT_PASSWORD'.
  • Document loading progress. Triggered when the document is loaded. Triggered when a page is loaded. The total number of pages of the pdf.

@error Object

Triggered when an error occurred.

@link-clicked Number

Triggered when an internal link is clicked.

:page Number - default: 1

dpi: the print resolution of the document (try 100).

@loaded

pageList: the list (array) of pages to print.

:src String / Object - default: ''

src: see :src prop. options: an object of options.This function creates a PDFJS loading task that can be used and reused as :src property.The loading task is a promise that resolves with the PDFJS pdf document that exposes the numPages property (see example below).

:rotate Number - default: 0

beware: when the component is destroyed, the object returned by createLoadingTask() become invalid.

Public methods

@page-loaded Number

  • Supported options:. onPassword: Callback that's called when a password protected PDF is being opened.
  • onProgress: Callback return loading progress.

Public static methods

@num-pages Number

  • withCredentials: Wheter or not to send cookies in the fetch request.
  • options: an object of options.This function creates a PDFJS loading task that can be used and reused as :src property.
    The loading task is a promise that resolves with the PDFJS pdf document that exposes the numPages property (see example below).

beware: when the component is destroyed, the object returned by createLoadingTask() become invalid.

Supported options:

  • onPassword: Callback that's called when a password protected PDF is being opened.
  • onProgress: Callback return loading progress.
  • withCredentials: Wheter or not to send cookies in the fetch request.

Examples

@password (updatePassword, reason)
createLoadingTask(src[, options])
@progress Number
print(dpi, pageList) * experimental *
Example - display multiple pages of the same pdf document
Example - get text content

Credits

Current Tags

  • 4.2.6... latest (a year ago)

6 Versions

  • 4.2.1... a year ago
  • 4.2.2... a year ago
  • 4.2.3... a year ago
  • 4.2.4... a year ago
  • 4.2.5... a year ago
  • 4.2.6... a year ago