file parse
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m40s
All checks were successful
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 1m40s
This commit is contained in:
parent
18dd726fb3
commit
a1f8b1b50b
@ -1,8 +1,5 @@
|
||||
import mammoth from 'mammoth';
|
||||
import { getDocument, GlobalWorkerOptions } from 'pdfjs-dist';
|
||||
import pdfWorker from 'pdfjs-dist/build/pdf.worker.mjs?url';
|
||||
|
||||
GlobalWorkerOptions.workerSrc = pdfWorker;
|
||||
import { getDocument } from 'pdfjs-dist';
|
||||
|
||||
const SUPPORTED_EXTENSIONS = ['docx', 'txt', 'pdf', 'md'] as const;
|
||||
export type SupportedUploadExtension = typeof SUPPORTED_EXTENSIONS[number];
|
||||
@ -22,7 +19,7 @@ function getExtension(fileName: string): SupportedUploadExtension | null {
|
||||
|
||||
async function parsePdf(file: File): Promise<string> {
|
||||
const data = new Uint8Array(await file.arrayBuffer());
|
||||
const pdf = await getDocument({ data }).promise;
|
||||
const pdf = await getDocument({ data, disableWorker: true as unknown as boolean }).promise;
|
||||
const pages: string[] = [];
|
||||
|
||||
for (let pageNumber = 1; pageNumber <= pdf.numPages; pageNumber += 1) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user