Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pdf file decode success but not show anything #8270

Closed
tomoyuen opened this issue Apr 11, 2017 · 7 comments
Closed

pdf file decode success but not show anything #8270

tomoyuen opened this issue Apr 11, 2017 · 7 comments

Comments

@tomoyuen
Copy link

tomoyuen commented Apr 11, 2017

Link to PDF file (or attach file here): PDF file

Configuration:

  • Web browser and its version: Chrome 57.0
  • Operating system and its version: macOS Sierra 10.12.3
  • PDF.js version: 1.7.416

Steps to reproduce the problem:

  1. open the example url https://mozilla.github.io/pdf.js/web/viewer.html
  2. upload this file, decode success but this viewer is all blank.

What went wrong? (add screenshot)
this file have many content, but in viewer, is no content to display.
error screenshot

@janpe2
Copy link
Contributor

janpe2 commented Apr 25, 2017

The problem may be in function decodeRefinement() (jbig2.js) in the following lines:

          i0 = i + referenceTemplateY[k] + offsetY;
          j0 = j + referenceTemplateX[k] + offsetX;

As the JBIG2 standard says, offsetX and offsetY should be subtracted, not added. So the lines should be like this:

          i0 = i + referenceTemplateY[k] - offsetY;
          j0 = j + referenceTemplateX[k] - offsetX;

See page 21 in standard ITU T.88, in which the offsets are called GRREFERENCEDX and GRREFERENCEDY.

The JBIG2 images in the PDF use decodeRefinement() to refine symbol bitmaps. Because of this bug, wrong contextLabel bits are fed to the arithmetic decoder. The decoder gets "confused" and it no longer returns valid decoding results.

@tomoyuen
Copy link
Author

@janpe2 it works, thanks so much.

@SamyCookie
Copy link

@janpe2 Could you open a pull request for that bugfix ?

@janpe2
Copy link
Contributor

janpe2 commented Apr 26, 2017

I'm not exactly familiar with the pull request process in GitHub. Could somebody make a pull request on my behalf? Someone who is more experienced...

BTW, my fix may resolve also issues #7850 , #7308 and #7145. Maybe also #7401?

@Snuffleupagus
Copy link
Collaborator

@janpe2 Very nice debugging, thank you!

It seems that this has been broken ever since JBIG2 support was first added, all the way back in PR #1837. Interestingly, in the test-case added in that PR all offsets are 0, which probably explains why this bug managed to creep into the code.

I'm not exactly familiar with the pull request process in GitHub. Could somebody make a pull request on my behalf? Someone who is more experienced...

The contribution work-flow is described in https://github.com/mozilla/pdf.js/wiki/Contributing, if you feel like trying it yourself.
If not, I suppose that I can help you with the creation of a patch[1]. However, since you should obviously be credited as the author (it's your patch after all), please tell me what name (and optionally what e-mail address) you'd want to appear in the patch!


[1] I just ran the PDF.js test-suite (locally) with your changes, and everything seemed to work just fine :-)

@janpe2
Copy link
Contributor

janpe2 commented Apr 26, 2017

@Snuffleupagus I would be happy if you could create the patch, please. I think I don't have enough skills to follow the contribution work-flow. In the credits you can mention my name Jani Pehkonen.

@IdelCoder
Copy link

Thank you very much. It worked. Actually, for me, the function decodeRefinement() is in pdf.worker.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants