Skip to content

"Requesting object that isn't resolved" error due to duplicate image during page.objs.get(name) #13742

Closed
@Soviut

Description

@Soviut

Attach (recommended) or Link to PDF file here:

Configuration:

  • Web browser and its version: No browser, Node 12.14.1
  • Operating system and its version: Ubuntu 20.04
  • PDF.js version: [email protected]
  • Is a browser extension: No

Steps to reproduce the problem:

  1. Create a new Adobe Illustrator file.
  2. Drag an image from your desktop onto the artboard.
  3. Duplicate the artboard by selecting the artboard tool, select the artboard, copy and paste.
  4. File > Save a Copy, choose PDF from the format dropdown
  5. Use Acrobat Pro's "Content Panel" to ensure the images have the same id number.

Here is an example PDF 2page-test.pdf

Here is what it looks like in Acrobat's Content Panel
image

What is the expected behavior? (add screenshot)

I should be able to extract the image from either page using page.objs.get(name) without an error.

I find all the image object names using the following code.

  const ops = await page.getOperatorList()
  const imageNames = ops.fnArray.reduce((acc, curr, i) => {
    if (
      [pdfjs.OPS.paintImageXObject, pdfjs.OPS.paintJpegXObject].includes(curr)
    ) {
      // console.log(ops.argsArray[i])
      acc.push(ops.argsArray[i][0])
    }
    return acc
  }, [])

I then use those names to get the image objects from the page.

  const rawImages = imageNames.map((name) => {
      return [name, page.objs.get(name)]
  })

What went wrong? (add screenshot)

I get the error

Error: Requesting object that isn't resolved yet g_d0_img_p1_1

I logged out the page.objs for each page and noticed this...

img_p0_1 PDFObjects {
  _objs: [Object: null prototype] {
    img_p0_1: {
      capability: [Object: null prototype],
      data: [Object],
      resolved: true
    }
  }
}
g_d0_img_p1_1 PDFObjects {
  _objs: [Object: null prototype] {}
}

The second page doesn't have a g_d0_img_p1_1 key in its page.objs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions