Skip to content

Commit

Permalink
chore: change setup of workerSrc
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Mattos <vitor@php.rio>
  • Loading branch information
vitormattos committed Oct 28, 2024
1 parent b6f6f15 commit 42144e1
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ https://www.npmjs.com/package/@libresign/vue-pdf-editor
:init-image-scale = "0.2" <!--The zoom level of the initialized picture defaults to 0.2 times the original size-->
:seal-image-show="true" <!--Whether to show the signed example of the default FALSE-->
:seal-image-hidden-on-save="true" <!--Whether the signed example is hidden by the default FALSE when saving-->
:worker-src=null <!-- URL of pdf.worker -->
@onSave2Upload="【save callback】" <!--Save the callback load: PDFBYTES and FILENAME-->
/>
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@libresign/vue-pdf-editor",
"description": "vue2 pdf editor component",
"version": "1.3.5",
"version": "1.3.6",
"author": "LibreCode",
"private": false,
"main": "dist/vue-pdf-editor.umd.js",
Expand Down
9 changes: 1 addition & 8 deletions src/VuePdfEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ import ImageItem from './Components/Image.vue'
import TextItem from './Components/TextItem.vue'
import Drawing from './Components/Drawing.vue'
import DrawingCanvas from './Components/DrawingCanvas.vue'
import { configurePDFWorkerSrc, readAsImage, readAsPDF, readAsDataURL } from './utils/asyncReader.js'
import { readAsImage, readAsPDF, readAsDataURL } from './utils/asyncReader.js'
import { save } from './utils/PDF.js'
import ImageIcon from 'vue-material-design-icons/Image.vue'
import TextIcon from 'vue-material-design-icons/Text.vue'
Expand Down Expand Up @@ -311,10 +311,6 @@ export default {
type: Boolean,
default: false,
},
workerSrc: {
type: String,
default: null
},
},
data() {
return {
Expand Down Expand Up @@ -497,9 +493,6 @@ export default {
file = await blob.arrayBuffer();
}
if (this.workerSrc) {
configurePDFWorkerSrc(this.workerSrc)
}
this.pdfDocument = await readAsPDF(file)
if (this.pdfDocument) {
this.numPages = this.pdfDocument.numPages
Expand Down
4 changes: 2 additions & 2 deletions src/utils/asyncReader.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getDocument, GlobalWorkerOptions } from 'pdfjs-dist'
import pdfWorkerCode from 'pdfjs-dist/legacy/build/pdf.worker.min.mjs'

export function configurePDFWorkerSrc(customWorkerSrc) {
GlobalWorkerOptions.workerSrc = customWorkerSrc || pdfWorkerCode
if (!GlobalWorkerOptions.workerSrc) {
GlobalWorkerOptions.workerSrc = pdfWorkerCode
}

/**
Expand Down

0 comments on commit 42144e1

Please sign in to comment.