Skip to content

Commit 5d4939c

Browse files
committed
correct usage of pdfjs-dist
1 parent af3847a commit 5d4939c

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/routes/conversation/[id]/upload-pdf/+server.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { uploadPdfEmbeddings } from "$lib/server/files/uploadFile";
55
import { chunk } from "$lib/utils/chunk";
66
import { error } from "@sveltejs/kit";
77
import { ObjectId } from "mongodb";
8-
import * as pdfjsLib from "pdfjs-dist/legacy/build/pdf";
8+
import { getDocument } from "pdfjs-dist";
99

1010
export async function POST({ request, params, locals }) {
1111
const conversationId = new ObjectId(params.id);
@@ -21,8 +21,7 @@ export async function POST({ request, params, locals }) {
2121
const formData = await request.formData();
2222
const file = formData.get("pdf"); // 'pdf' is the name used in FormData on the frontend
2323
const data = new Uint8Array(await file.arrayBuffer());
24-
const loadingTask = pdfjsLib.getDocument({ data });
25-
const pdf = await loadingTask.promise;
24+
const pdf = await getDocument({ data }).promise;
2625

2726
const N_MAX_PAGES = 20;
2827
let text = "";

0 commit comments

Comments
 (0)