Skip to content

Commit

Permalink
all: implemented minimal workaround that works
Browse files Browse the repository at this point in the history
  • Loading branch information
Luluno01 committed Nov 12, 2023
1 parent 293fa69 commit 82c4439
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 87 deletions.
16 changes: 14 additions & 2 deletions app/page.tsx
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>
</>
}
Loading

0 comments on commit 82c4439

Please sign in to comment.