51
rated 0 times
[
58]
[
7]
/ answers: 1 / hits: 18561
/ 7 Years ago, fri, november 10, 2017, 12:00:00
I am building a project in React that has a functionality of displaying pdfs.
I am using the basic minimal code provided in the example (in the repo) itself.
However, the code displays only the first page of the pdf and the rest are ignored. am using 'react-pdf' for this.
I
Following is my code ..
import React, {Component} from 'react';
import './DocumentationPage.css';
import HeaderComponent from '../../components/Header/Header.js';
import { Document, Page } from 'react-pdf/build/entry.webpack';
import data from './data.pdf';
// import { Document, Page } from 'react-pdf';
export default class DocumentationPage extends Component {
state = {
numPages: 12,
pageNumber: 1,
}
render() {
const { pageNumber, numPages } = this.state;
return (
<div>
<HeaderComponent id='header' location={this.props.location} />
<div>
<h1>Documentation</h1>
</div>
<div id='contentDiv'>
<Document
file={data}
onLoadSuccess={this.onDocumentLoad}>
<Page pageNumber={pageNumber} />
</Document>
<p>Page {pageNumber} of {numPages}</p>
</div>
</div>
);
}
}
Please help.
Thank You.
More From » reactjs