diff --git a/package.json b/package.json index dae0954..5c3c973 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@libresign/vue-pdf-editor", "description": "vue2 pdf editor component", - "version": "1.3.4", + "version": "1.3.5", "author": "LibreCode", "private": false, "main": "dist/vue-pdf-editor.umd.js", diff --git a/src/utils/PDF.js b/src/utils/PDF.js index 3d046db..b43f568 100644 --- a/src/utils/PDF.js +++ b/src/utils/PDF.js @@ -1,4 +1,3 @@ -import { readAsArrayBuffer } from './asyncReader.js' import { fetchFont } from './prepareAssets.js' import { noop } from './helper.js' import * as PDFLib from '@cantoo/pdf-lib' @@ -37,6 +36,16 @@ export async function makeTextPDF({ }); } +let readAsArrayBuffer = null; + +async function loadReadAsArrayBuffer() { + if (!readAsArrayBuffer) { + const asyncReaderModule = await import('./asyncReader.js'); + readAsArrayBuffer = asyncReaderModule.readAsArrayBuffer; + } + return readAsArrayBuffer; +} + /** * * @param pdfFile @@ -46,6 +55,7 @@ export async function makeTextPDF({ * @param callback */ export async function save(pdfFile, objects, name, isUpload = false, callback) { + const readAsArrayBuffer = await loadReadAsArrayBuffer(); let pdfDoc try { pdfDoc = await PDFLib.PDFDocument.load(await readAsArrayBuffer(pdfFile))