Skip to content

Commit dba5b8d

Browse files
committed
Bump dependencies
Signed-off-by: Vitor Mattos <vitor@php.rio>
1 parent a0f2541 commit dba5b8d

File tree

4 files changed

+8
-13
lines changed

4 files changed

+8
-13
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
"lint:fix": "vue-cli-service lint"
1919
},
2020
"dependencies": {
21+
"@cantoo/pdf-lib": "^1.20.2",
2122
"blob-stream-i2d": "^1.0.0",
2223
"core-js": "^3.35.1",
2324
"downloadjs": "^1.4.7",
24-
"pdf-lib": "^1.17.1",
25-
"pdfjs-dist": "^2.16.105",
25+
"pdfjs-dist": "^4.0.379",
2626
"pdfkit": "^0.14.0",
2727
"vue-material-design-icons": "^5.2.0"
2828
},

src/VuePdfEditor.vue

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,6 @@
190190
</template>
191191

192192
<script>
193-
import 'pdfjs-dist/web/pdf_viewer.css'
194-
195193
import { fetchFont } from './utils/prepareAssets.js'
196194
197195
import PDFPage from './Components/PDFPage.vue'
@@ -210,8 +208,8 @@ import TextIcon from 'vue-material-design-icons/Text.vue'
210208
import GestureIcon from 'vue-material-design-icons/Gesture.vue'
211209
import PencilIcon from 'vue-material-design-icons/Pencil.vue'
212210
213-
const PDFJS = require('pdfjs-dist')
214-
PDFJS.GlobalWorkerOptions.workerSrc = require('pdfjs-dist/build/pdf.worker')
211+
import * as pdfjsLib from 'pdfjs-dist'
212+
pdfjsLib.GlobalWorkerOptions.workerSrc = require('pdfjs-dist/build/pdf.worker')
215213
216214
export default {
217215
name: 'VuePdfEditor',
@@ -494,7 +492,7 @@ export default {
494492
async getPdfDocument(file) {
495493
const blob = new Blob([file])
496494
const url = window.URL.createObjectURL(blob)
497-
return PDFJS.getDocument(url).promise
495+
return pdfjsLib.getDocument(url).promise
498496
},
499497
async addPDF(file) {
500498
try {
@@ -671,7 +669,7 @@ export default {
671669
if (this.sealImageShow) {
672670
for (let i = 0; i < this.pages.length; i++) {
673671
const seal = this.allObjects[i].find((e) => e.isSealImage === true)
674-
const page = this.pages[i]
672+
const page = await this.pages[i].then(response => response);
675673
sealInfo.push({
676674
page: page._pageIndex,
677675
pageWidth: page._pageInfo.view[2],

src/utils/PDF.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { readAsArrayBuffer } from './asyncReader.js'
22
import { fetchFont } from './prepareAssets.js'
33
import { noop } from './helper.js'
4-
import * as PDFLib from 'pdf-lib'
4+
import * as PDFLib from '@cantoo/pdf-lib'
55
import * as download from 'downloadjs'
66
import PDFDocument from 'pdfkit/js/pdfkit.standalone.js'
77
import blobStream from 'blob-stream-i2d/blob-stream.js'

src/utils/asyncReader.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import 'pdfjs-dist/build/pdf.worker.min'
1+
import * as pdfjsLib from 'pdfjs-dist'
22

33
/**
44
*
@@ -50,8 +50,5 @@ export function readAsDataURL(file) {
5050
* @param file
5151
*/
5252
export async function readAsPDF(file) {
53-
const pdfjsLib = require('pdfjs-dist')
54-
const pdfjsWorker = require('pdfjs-dist/build/pdf.worker.entry')
55-
pdfjsLib.GlobalWorkerOptions.workerSrc = pdfjsWorker
5653
return pdfjsLib.getDocument(file).promise
5754
}

0 commit comments

Comments
 (0)