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.

Failed to load PDF file from URL

See original GitHub issue

Before you start - checklist

  • I have read documentation in README
  • I have checked sample and test suites to see real life basic implementation
  • I have checked if this question is not already asked

What are you trying to achieve? Please describe. Unable to render pdf (url)

Describe what are you trying to achieve Ex. I’d like to display multiple pages of my PDF. I’m trying to render pdf from url , but I get the following error in the browser

failed to load pdf file pages of

Describe solutions you’ve tried SamplePdf.jsx

 import React, {Component} from "react";
   import {Document, Page} from 'react-pdf';

class Sample extends Component {
    constructor(props) {
        super(props);
        this.state = {
            numPages: null,
            pageNumber: 1
        };
    }
 onDocumentLoad({numPages}) {
        this.setState({numPages});
    }
render() {
const {pageNumber, numPages} = this.setState;
        return (
            <div>
                <Document
                    file={{url: 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf'}}
                    onLoadSuccess={this.onDocumentLoad}>
                    <Page pageNumber={pageNumber}/>
                </Document>
                <p>Page {pageNumber} of {numPages}</p>
            </div>
        );
    }
}

export default Sample; 

index.jsx

import React from 'react';
import { storiesOf } from '@storybook/react';
import Sample from '../Sample';

const storyPath = 'TrialComponents/reactpdf';

storiesOf(storyPath, module)
  .add('Static', () => <Sample />);

Additional information

Environment

  • Browser (if applicable) [e.g. Chrome 57, Firefox 59]:
  • React-PDF version [e.g. 3.0.4]:
  • React version [e.g. 16.3.0]:
  • Webpack version (if applicable) [e.g. 4.16.2]:

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

25reactions
dev-chrcommented, Feb 24, 2019

OK, so duplicate. Where is the answered or original?

13reactions
aparna1413commented, Feb 5, 2019

Sorry this is a duplicate issue. Closing it. Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

8 Ways to Fix Failed to Load PDF Document Error
How do I fix a PDF failed to load? · 1. Download the latest Adobe Reader version · 2. Change PDF settings in...
Read more >
Fix: Error Failed to Load PDF Document in Chrome - Appuals
Visit this link (here) and click on Add to Chrome to install the PDF Viewer Extension. Then click Add Extension to confirm the...
Read more >
How to Fix Error Failed to Load PDF Document in Chrome
Fix 1: Update Google Chrome to the Latest Version ... Sometimes PDF won't load in Chrome due to the old version of this...
Read more >
Failed to load PDF document in Chrome - Stack Overflow
Opening Google Chrome (obviously) · In the top right, click More Untitled. · At the bottom, click Show Advanced Settings. · Under Privacy,...
Read more >
Error: Failed to load PDF document - ShiftCare Help Center
The error message "failed to load pdf document" means the web browser is having difficulty opening the file. The problem might be your...
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