-
-
Notifications
You must be signed in to change notification settings - Fork 878
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
Make it easier to display all pages #346
Comments
Hello @wojtekmaj , Any chance with this component to display all pages ? thanks. |
@qaisershehzad Not right now. Busy in private life, and with budget of $0 I need to prioritize to make a living :) |
This comment has been minimized.
This comment has been minimized.
After consideration I've decided not to put this AllPages component into core React-PDF. Here's why: Including well built, performant AllPages component would require building a solution using third party tools like React-Window. This would likely cause developers to use AllPages instead of whatever solutions they are already using for lazy loading components. Building AllPages component that would work well with React-Window and other similar libraries would be super hard, if not impossible to do. I'll be more than happy to see React-PDF based extensions, which use Here's import React, { PureComponent } from 'react';
import DocumentContext from 'react-pdf/dist/DocumentContext';
import { PageInternal } from 'react-pdf/dist/Page';
export class AllPagesInternal extends PureComponent {
componentDidMount() {
const { pdf } = this.props;
if (!pdf) {
throw new Error('Attempted to load a page, but no document was specified.');
}
}
render() {
const { pdf } = this.props;
const { numPages } = pdf;
return (
Array.from(
new Array(numPages),
(el, index) => (
<PageInternal
{...this.props}
key={`page_${index + 1}`}
pageNumber={index + 1}
/>
),
)
);
}
}
const { pageIndex, pageNumber, ...allPagesInternalPropTypes } = PageInternal.propTypes;
AllPagesInternal.propTypes = {
...allPagesInternalPropTypes,
};
const AllPages = props => (
<DocumentContext.Consumer>
{context => (
<AllPagesInternal
{...context}
{...props}
// For backwards compatibility
renderAnnotationLayer={
typeof props.renderAnnotationLayer !== 'undefined'
? props.renderAnnotationLayer
: props.renderAnnotations
}
/>
)}
</DocumentContext.Consumer>
);
export default AllPages; As you can see, render function is just an array based on |
I think AllPages is quite necessary, many other file like ppt,excel can be transffed to be pdf, they should be display multi pages. |
This comment has been minimized.
This comment has been minimized.
How to link pdf file? It is throwing an Error: Attempted to load a page, but no document was specified. |
@ashnakumar Looks like you may have not wrapped your AllPages component in Document component. |
I didnt understand
|
I tried AllPages with react-window but my console log in componentDidMount was infinity re-render. Can you demo an example of how to use AllPages with react-window or react-virtualize or check where is code wrong? @wojtekmaj |
Before you start - checklist
Is your feature request related to a problem? Please describe.
It should be easy to display all PDF pages at once, as suggested in #98.
Describe the solution you'd like
<AllPages />
component? Better documentation? Optional render props that allows to iterate through all pages?The text was updated successfully, but these errors were encountered: