Skip to content

Commit

Permalink
async import pdf-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
rwv committed Nov 17, 2023
1 parent 24bd648 commit 993ed7d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/composables/save-scanned-pdf/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { Ref } from "vue";
import { get } from "@vueuse/core";
import { ref, computed, watch } from "vue";
import { buildPDF } from "@/utils/pdf-builder/pdf-lib";

interface PDFRenderer {
renderPage(
Expand Down Expand Up @@ -94,7 +95,6 @@ export function useSaveScannedPDF(
);

// generate pdf from scan pages
const { buildPDF } = await import("@/utils/pdf-builder/pdf-lib");
const pdfDocument = await buildPDF(scanPages);

scannedPDF.value = new File([pdfDocument], outputFilename.value, {
Expand Down
3 changes: 1 addition & 2 deletions src/utils/pdf-builder/pdf-lib/build-pdf.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { PDFDocument } from "pdf-lib";

interface ImageInfo {
blob: Blob;
width: number;
Expand All @@ -8,6 +6,7 @@ interface ImageInfo {
}

export async function buildPDF(images: ImageInfo[]): Promise<Blob> {
const { PDFDocument } = await import("pdf-lib");
const pdfDoc = await PDFDocument.create();

for (const image of images) {
Expand Down

0 comments on commit 993ed7d

Please sign in to comment.