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

Load more than 1 pdf pages #98

Closed
iamrkcheers opened this issue Nov 10, 2017 · 6 comments
Closed

Load more than 1 pdf pages #98

iamrkcheers opened this issue Nov 10, 2017 · 6 comments
Assignees
Labels
question Further information is requested

Comments

@iamrkcheers
Copy link

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.

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.

@wojtekmaj
Copy link
Owner

Well, you've put one <Page> inside <Document>. Therefore, you got one page. ;) Please see ./sample directory for a simplest possible example of dynamic rendering of multiple pages.

@wojtekmaj wojtekmaj self-assigned this Nov 10, 2017
@wojtekmaj wojtekmaj added the question Further information is requested label Nov 10, 2017
@iamrkcheers
Copy link
Author

Yup, silly me !
Anyway, thanks for the help.

@wojtekmaj
Copy link
Owner

Pleasure! If you need help with anything else, let me know.

@hosseinmp76
Copy link

Well, you've put one <Page> inside <Document>. Therefore, you got one page. ;) Please see ./sample directory for a simplest possible example of dynamic rendering of multiple pages.

as I saw in sample I have to add all the pages handy to see all pages. is there other way to load all pdf? I think there should be a way that pdf-react handle this. for example load all pages if we don;t use <page as its child.

@wojtekmaj
Copy link
Owner

That would be a breaking change. A non-breaking solution would be to create <AllPages /> component or something similar. Which is not a bad idea :)

@hosseinmp76
Copy link

That would be a breaking change. A non-breaking solution would be to create <AllPages /> component or something similar. Which is not a bad idea :)

may you make a new issue for it?

alexandernanberg pushed a commit to alexandernanberg/react-pdf that referenced this issue Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants