Skip to content

Commit

Permalink
fix: OPS import from PDF.js
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Aug 12, 2023
1 parent a31e74e commit 8f9a043
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/image.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { OPS } from 'pdfjs-dist'
import { getDocumentProxy } from './utils'
import { getDocumentProxy, getPDFJSImports } from './utils'

export async function getImagesFromPage(
data: ArrayBuffer,
Expand All @@ -8,6 +7,7 @@ export async function getImagesFromPage(
const pdf = await getDocumentProxy(data)
const page = await pdf.getPage(pageNumber)
const operatorList = await page.getOperatorList()
const { OPS } = await getPDFJSImports()

const images: ArrayBuffer[] = []
for (const op of operatorList.fnArray) {
Expand Down
3 changes: 1 addition & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ export async function getDocumentProxy(data: ArrayBuffer) {
export async function getPDFJSImports() {
try {
const { default: mod } = await import('pdfjs-dist/legacy/build/pdf')
const { getDocument, version } = mod
return { getDocument, version }
return mod
}
catch (e) {
console.error(e)
Expand Down

0 comments on commit 8f9a043

Please # to comment.