Before you start - checklist
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
Sorry this is a duplicate issue. Closing it. Thanks
OK, so duplicate. Where is the answered or original?
I am also facing same problem... where is the original post?
This issue is not described well enough for me to point out a specific issue to seek help. I suggest either creating a new ticket describing exactly what happens, or seek for the issue on your own.
when I try to load file from a URL (external pdf url like for eg. : http://www.pdf995.com/samples/pdf.pdf )
error "Failed to load PDF file". PDF is not rendered as expected.
syntax
url: 'http://example.com/sample.pdf',
httpHeaders: { 'X-CustomHeader': '40359820958024350238508234' },
withCredentials: true
}
}
// onLoadSuccess={this.onDocumentLoadSuccess}
/>
Anyone found a solution?
Anyone found solution ?
Most helpful comment
OK, so duplicate. Where is the answered or original?