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

Images not rendered / Unsupported predictors 132 & 255 #8895

Closed
omicron81 opened this issue Sep 11, 2017 · 2 comments
Closed

Images not rendered / Unsupported predictors 132 & 255 #8895

omicron81 opened this issue Sep 11, 2017 · 2 comments
Assignees
Labels

Comments

@omicron81
Copy link

Link to PDF file (or attach file here):
http://www-eu.apache.org/dist/lucene/solr/ref-guide/apache-solr-ref-guide-6.6.pdf

Configuration:

  • Web browser and its version: Firefox 55.0.3
  • Operating system and its version: Windows 7
  • PDF.js version: 1.8.439
  • Is an extension: No

Steps to reproduce the problem:

  1. Open linked PDF file
  2. Scroll down to page 11 (16)

What is the expected behavior? (add screenshot)
Images are rendered:
grafik
grafik

What went wrong? (add screenshot)
Images are not rendered:
grafik
grafik

Error console:

PDF ad557cf1f10fc51f55a5f8fdb17f6669 [1.4 Written by the Apache Lucene/Solr Project / Asciidoctor PDF 1.5.0.alpha.15, based on Prawn 2.2.2] (PDF.js: 1.8.439)  viewer.js:1503:7
Error: Unsupported predictor: 255  pdf.worker.js:352:5
predictorStreamReadBlockPng@resource://pdf.js/build/pdf.worker.js:2322:10
DecodeStream_getBytes@resource://pdf.js/build/pdf.worker.js:1830:11
PDFImage_getImageBytes@resource://pdf.js/build/pdf.worker.js:33012:14
PDFImage_createImageData@resource://pdf.js/build/pdf.worker.js:32948:18
PartialEvaluator_buildPaintImageXObject/<@resource://pdf.js/build/pdf.worker.js:16907:23
  pdf.worker.js:353:5
Warning: Unable to decode image: Error: Unsupported predictor: 255  pdf.worker.js:344:5
Warning: Dependent image isn't ready yet  pdf.js:344:5
Error: Unsupported predictor: 255  pdf.worker.js:352:5
predictorStreamReadBlockPng@resource://pdf.js/build/pdf.worker.js:2322:10
DecodeStream_getBytes@resource://pdf.js/build/pdf.worker.js:1830:11
PDFImage_getImageBytes@resource://pdf.js/build/pdf.worker.js:33012:14
PDFImage_createImageData@resource://pdf.js/build/pdf.worker.js:32948:18
PartialEvaluator_buildPaintImageXObject/<@resource://pdf.js/build/pdf.worker.js:16907:23
  pdf.worker.js:353:5
Warning: Unable to decode image: Error: Unsupported predictor: 255  pdf.worker.js:344:5
Warning: Dependent image isn't ready yet  pdf.js:344:5
Error: Unsupported predictor: 132  pdf.worker.js:352:5
predictorStreamReadBlockPng@resource://pdf.js/build/pdf.worker.js:2322:10
DecodeStream_getBytes@resource://pdf.js/build/pdf.worker.js:1830:11
PDFImage_getImageBytes@resource://pdf.js/build/pdf.worker.js:33012:14
PDFImage_createImageData@resource://pdf.js/build/pdf.worker.js:32948:18
PartialEvaluator_buildPaintImageXObject/<@resource://pdf.js/build/pdf.worker.js:16907:23
  pdf.worker.js:353:5
Warning: Unable to decode image: Error: Unsupported predictor: 132  pdf.worker.js:344:5
Warning: Dependent image isn't ready yet  pdf.js:344:5
@THausherr
Copy link
Contributor

THausherr commented Sep 15, 2017

Apache PDFBox has the same problem and here's my 2ct on this:

In this file, /DecodeParms has an array with 1 element. The filter is a name object.

clipboard01

When I removed the predictor (overwrite "/Predictor 15" with blanks) from the PDF then it was rendered properly.

The PDF specification has this about /DecodeParms :

A parameter dictionary or an array of such dictionaries, used by the filters specified by Filter. If there is only one filter and that filter has parameters, DecodeParms shall be set to the filter’s parameter dictionary unless all the filter’s parameters have their default values, in which case the DecodeParms entry may be omitted. If there are multiple filters and any of the filters has parameters set to nondefault values, DecodeParms shall be an array with one entry for each filter: either the parameter dictionary for that filter, or the null object if that filter has no parameters (or if all of its parameters have their default values). If none of the filters have parameters, or if all their parameters have default values, the DecodeParms entry may be omitted.

Currently PDFBox takes "whatever is there" from the DecodeParms array / dictionary.

So now I tried to implement the specification literally in PDFBox ("If there is only one filter and that filter has parameters, DecodeParms shall be set to the filter’s parameter dictionary") and that failed, there are files that have a filter array with 1 element and have a /DecodeParms array with 1 element and these render properly with Adobe Reader, but no longer in PDFBox. So that "incorrect" DecodeParms array element must be used or it will look bad. The PDF specification should read "If there is only one filter as a name object and..."

Then I tried to implement that a dictionary would be expected when the filter was only a name, and that worked, i.e. no regressions, and the SOLR file renders too.

in parser.js you have this today:

      if (isName(filter)) {
        if (Array.isArray(params)) {
          params = this.xref.fetchIfRef(params[0]);
        }
        return this.makeFilter(stream, filter.name, length, params); 
      }

In an older version that I saved years ago the code was like this:

      if (isName(filter)) {
        return this.makeFilter(stream, filter.name, length, params);
      }

This logic was changed in commit c8f83d6 but I could not find a PR nor did I understand whether it solved a problem with a specific file.

Btw the very first page of the PDF has the same issue.

@timvandermeij
Copy link
Contributor

Fixed by the pull request above.

@THausherr Thank you for providing your analysis!

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

No branches or pull requests

4 participants