question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid Filter Algorithm

See original GitHub issue

React-pdf version: ^1.0.0-alpha.25

Description: Some PNG images throw this error when trying to view the PDF.
The PDFViewer then renders a plain white background. the browser in use makes no difference.

png-js.browser.es.js:358 Uncaught Error: Invalid filter algorithm: 181
    at png-js.browser.es.js:358
    at Inflate.onEnd (index.js:225)
    at Inflate../node_modules/events/events.js.EventEmitter.emit (events.js:96)
    at endReadableNT (_stream_readable.js:1010)
    at afterTickTwo (index.js:27)
    at Item../node_modules/node-libs-browser/node_modules/process/browser.js.Item.run (browser.js:153)
    at drainQueue (browser.js:123)

I did some digging and found that there are a couple other PDF libraries which have suffered the same thing.

here is one of the more useful links: https://github.com/MrRio/jsPDF/issues/1452

I have other PNGs that work. and one that fails. I will try to edit the photo and see if I can make it work some other way.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
AirborneEaglecommented, Nov 27, 2018

I simply opened the image in an editor and saved a copy of it. The copy works. So I am not sure how the encoding changed, but I will go a head and close this issue. If someone else runs into this, then perhaps it can be re-opened.

0reactions
avneeshrokscommented, Dec 8, 2020

I found one workaround for this! The idea is to try to render the image with react-pdf on your parent component’s componentDidMount if it is a valid image then only render it in the actual pdf.

hasValidImageForPdf = false;

componentDidMount() { this.validateImageForPdf() }

validateImageForPdf() { const tempDoc = ( <Document> <Page> <Image src={this.imgUrl}></Image> </Page> </Document>); const pdfBlobProm = pdf(TempDoc).toBlob(); pdfBlobProm.then(data => { this.hasValidImageForPdf = true }).catch(error => { console.log('ERROR rendering image') }) }

Then use hasValidImageForPdf flag to conditionally render that image in your actual PDF render/export.

This worked for me! Hope this could be helpful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Throws "Invalid filter algorithm" error on some PNG images
When attempting to generate a pdf with this image jsPDF throws an error: Uncaught Error: Invalid filter algorithm: 100 at e.
Read more >
How to Identify a View With an Invalid Filter Rule Before ... - IBM
Hi everyone,. Does anyone know of a way to identify a view with invalid filter rules before programmatically loading the view? Thanks! -Bob3....
Read more >
PNG Specification: Filter Algorithms - W3C
Filtering algorithms are applied to bytes, not to pixels, regardless of the bit depth or color type of the image. The filtering algorithms...
Read more >
Invalid filter rules and how to fix them - Anapedia
When a filter rule becomes invalid, the view of data on your page reverts to how it was before the filter rule was...
Read more >
How does Google prevent invalid activity?
When our team identifies invalid behavior, we use the data to update and improve our filters, so we can automatically stop new traffic...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found