Link to PDF file (or attach file here): PDF file
Configuration:
Steps to reproduce the problem:
What went wrong? (add screenshot)
this file have many content, but in viewer, is no content to display.
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.
@janpe2 it works, thanks so much.
@janpe2 Could you open a pull request for that bugfix ?
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?
@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 :-)
@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.
Thank you very much. It worked. Actually, for me, the function decodeRefinement() is in pdf.worker.js
Most helpful comment
The problem may be in function decodeRefinement() (jbig2.js) in the following lines:
As the JBIG2 standard says, offsetX and offsetY should be subtracted, not added. So the lines should be like this:
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.