@tato30/vue-pdf
Advanced tools
Comparing version 1.0.3 to 1.1.0-beta.0
@@ -212,4 +212,6 @@ 'use strict'; | ||
// for any change in pdf proxy, rework all | ||
clearLayers(); | ||
initDoc(pdf); | ||
if (pdf !== undefined) { | ||
clearLayers(); | ||
initDoc(pdf); | ||
} | ||
}); | ||
@@ -237,3 +239,4 @@ | ||
// When scale change rework render task | ||
clearLayers(); | ||
if (TextLayerLoaded && AnnotationLayerLoaded) | ||
clearLayers(); | ||
renderPage(props.page); | ||
@@ -244,3 +247,4 @@ }); | ||
// When page change rework render task | ||
clearLayers(); | ||
if (TextLayerLoaded && AnnotationLayerLoaded) | ||
clearLayers(); | ||
renderPage(page); | ||
@@ -304,9 +308,15 @@ }); | ||
* Can be a URL where a PDF file is located, a typed array (Uint8Array) already populated with data, or a parameter object. | ||
* @param {function} onProgress | ||
* @param {string} options.password | ||
* Document password to unlock content | ||
* @param {function} options.onProgress | ||
* Callback to request a password if a wrong or no password was provided. The callback receives two parameters: a function that should be called with the new password, and a reason (see PasswordResponses). | ||
* @param {function} onPassword | ||
* Callback to be able to monitor the loading progress of the PDF file (necessary to implement e.g. a loading bar). The callback receives an OnProgressParameters argument. | ||
* @param {function} options.onPassword | ||
* Callback to be able to monitor the loading progress of the PDF file (necessary to implement e.g. a loading bar). The callback receives an OnProgressParameters argument. if this function is used option.password is ignored | ||
* @returns | ||
*/ | ||
function VuePDF(src, onProgress, onPassword) { | ||
function VuePDF(src, options = { | ||
onProgress: undefined, | ||
onPassword: undefined, | ||
password: '' | ||
}) { | ||
const pdf = vue.ref(); | ||
@@ -317,4 +327,8 @@ const pages = vue.ref(0); | ||
const loadingTask = PDFJSLib__namespace.getDocument(src); | ||
loadingTask.onProgress = onProgress; | ||
loadingTask.onPassword = onPassword; | ||
loadingTask.onProgress = options?.onProgress; | ||
loadingTask.onPassword = options?.onPassword | ||
? options.onPassword : options.password | ||
? (updatePassword, _) => { | ||
updatePassword(options.password); | ||
} : undefined; | ||
@@ -321,0 +335,0 @@ loadingTask.promise.then((doc) => { |
@@ -185,4 +185,6 @@ import * as PDFJSLib from 'pdfjs-dist/build/pdf'; | ||
// for any change in pdf proxy, rework all | ||
clearLayers(); | ||
initDoc(pdf); | ||
if (pdf !== undefined) { | ||
clearLayers(); | ||
initDoc(pdf); | ||
} | ||
}); | ||
@@ -210,3 +212,4 @@ | ||
// When scale change rework render task | ||
clearLayers(); | ||
if (TextLayerLoaded && AnnotationLayerLoaded) | ||
clearLayers(); | ||
renderPage(props.page); | ||
@@ -217,3 +220,4 @@ }); | ||
// When page change rework render task | ||
clearLayers(); | ||
if (TextLayerLoaded && AnnotationLayerLoaded) | ||
clearLayers(); | ||
renderPage(page); | ||
@@ -277,9 +281,15 @@ }); | ||
* Can be a URL where a PDF file is located, a typed array (Uint8Array) already populated with data, or a parameter object. | ||
* @param {function} onProgress | ||
* @param {string} options.password | ||
* Document password to unlock content | ||
* @param {function} options.onProgress | ||
* Callback to request a password if a wrong or no password was provided. The callback receives two parameters: a function that should be called with the new password, and a reason (see PasswordResponses). | ||
* @param {function} onPassword | ||
* Callback to be able to monitor the loading progress of the PDF file (necessary to implement e.g. a loading bar). The callback receives an OnProgressParameters argument. | ||
* @param {function} options.onPassword | ||
* Callback to be able to monitor the loading progress of the PDF file (necessary to implement e.g. a loading bar). The callback receives an OnProgressParameters argument. if this function is used option.password is ignored | ||
* @returns | ||
*/ | ||
function VuePDF(src, onProgress, onPassword) { | ||
function VuePDF(src, options = { | ||
onProgress: undefined, | ||
onPassword: undefined, | ||
password: '' | ||
}) { | ||
const pdf = ref(); | ||
@@ -290,4 +300,8 @@ const pages = ref(0); | ||
const loadingTask = PDFJSLib.getDocument(src); | ||
loadingTask.onProgress = onProgress; | ||
loadingTask.onPassword = onPassword; | ||
loadingTask.onProgress = options?.onProgress; | ||
loadingTask.onPassword = options?.onPassword | ||
? options.onPassword : options.password | ||
? (updatePassword, _) => { | ||
updatePassword(options.password); | ||
} : undefined; | ||
@@ -294,0 +308,0 @@ loadingTask.promise.then((doc) => { |
{ | ||
"name": "@tato30/vue-pdf", | ||
"description": "A vue 3 PDFJS wrapper", | ||
"version": "1.0.3", | ||
"version": "1.1.0-beta.0", | ||
"license": "MIT", | ||
@@ -35,2 +35,3 @@ "main": "cjs/index.js", | ||
"devDependencies": { | ||
"vue": "^3.2.33", | ||
"@rushstack/eslint-patch": "^1.1.0", | ||
@@ -37,0 +38,0 @@ "@vitejs/plugin-vue": "^2.3.1", |
@@ -12,9 +12,15 @@ import { ref } from "vue"; | ||
* Can be a URL where a PDF file is located, a typed array (Uint8Array) already populated with data, or a parameter object. | ||
* @param {function} onProgress | ||
* @param {string} options.password | ||
* Document password to unlock content | ||
* @param {function} options.onProgress | ||
* Callback to request a password if a wrong or no password was provided. The callback receives two parameters: a function that should be called with the new password, and a reason (see PasswordResponses). | ||
* @param {function} onPassword | ||
* Callback to be able to monitor the loading progress of the PDF file (necessary to implement e.g. a loading bar). The callback receives an OnProgressParameters argument. | ||
* @param {function} options.onPassword | ||
* Callback to be able to monitor the loading progress of the PDF file (necessary to implement e.g. a loading bar). The callback receives an OnProgressParameters argument. if this function is used option.password is ignored | ||
* @returns | ||
*/ | ||
export default function VuePDF(src, onProgress, onPassword) { | ||
export default function VuePDF(src, options = { | ||
onProgress: undefined, | ||
onPassword: undefined, | ||
password: '' | ||
}) { | ||
const pdf = ref(); | ||
@@ -25,4 +31,8 @@ const pages = ref(0); | ||
const loadingTask = PDFJSlib.getDocument(src) | ||
loadingTask.onProgress = onProgress | ||
loadingTask.onPassword = onPassword | ||
loadingTask.onProgress = options?.onProgress | ||
loadingTask.onPassword = options?.onPassword | ||
? options.onPassword : options.password | ||
? (updatePassword, _) => { | ||
updatePassword(options.password) | ||
} : undefined | ||
@@ -29,0 +39,0 @@ loadingTask.promise.then((doc) => { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38625
712
13
1