Skip to content

Commit 8e92b20

Browse files
committed
fix bug missing pages
1 parent f8ed8dc commit 8e92b20

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

tools/server/public/index.html.gz

13 Bytes
Binary file not shown.

tools/server/webui/src/components/useChatExtraContext.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ async function convertPDFToText(file: File): Promise<string> {
189189
async function convertPDFToImage(file: File): Promise<string[]> {
190190
const buffer = await getFileAsBuffer(file);
191191
const doc = await pdfjs.getDocument(buffer).promise;
192-
const pages: string[] = [];
192+
const pages: Promise<string>[] = [];
193193

194194
for (let i = 1; i <= doc.numPages; i++) {
195195
const page = await doc.getPage(i);
@@ -202,12 +202,14 @@ async function convertPDFToImage(file: File): Promise<string[]> {
202202
throw new Error('Failed to get 2D context from canvas');
203203
}
204204
const task = page.render({ canvasContext: ctx, viewport: viewport });
205-
task.promise.then(() => {
206-
pages.push(canvas.toDataURL());
207-
});
205+
pages.push(
206+
task.promise.then(() => {
207+
return canvas.toDataURL();
208+
})
209+
);
208210
}
209211

210-
return pages;
212+
return await Promise.all(pages);
211213
}
212214

213215
// WARN: vibe code below

0 commit comments

Comments
 (0)