-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
all: implemented minimal workaround that works
- Loading branch information
Showing
3 changed files
with
37 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,21 @@ | ||
import * as pdfjs from 'pdfjs-dist' | ||
import * as pdfjs from 'pdfjs-dist/build/pdf.min.mjs' | ||
import { TextContent, TextItem } from 'pdfjs-dist/types/src/display/api' | ||
|
||
|
||
function mergeTextContent(textContent: TextContent) { | ||
return textContent.items.map(item => { | ||
const { str, hasEOL } = item as TextItem | ||
return str + (hasEOL ? '\n' : '') | ||
}).join('') | ||
} | ||
|
||
export default async function Home() { | ||
await import('pdfjs-dist/build/pdf.worker.min.mjs') | ||
const pdf = await pdfjs.getDocument('https://www.africau.edu/images/default/sample.pdf').promise | ||
const page = await pdf.getPage(1) | ||
const textContent = await page.getTextContent() | ||
return <> | ||
<p>pdfjs.getDocument is {typeof pdfjs.getDocument}</p> | ||
<p>(await import ('pdfjs-dist')).default is {typeof (await import('pdfjs-dist')).default}</p> | ||
<pre><code>{mergeTextContent(textContent)}</code></pre> | ||
</> | ||
} |
Oops, something went wrong.