mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
39 lines
936 B
TypeScript
39 lines
936 B
TypeScript
import * as React from 'react';
|
|
import { Document, Page } from 'react-pdf';
|
|
import { PDFDocumentProxy } from 'pdfjs-dist';
|
|
|
|
interface State {
|
|
numPages: number | null;
|
|
pageNumber: number;
|
|
}
|
|
|
|
export class MyApp extends React.Component<{}, State> {
|
|
constructor(props: {}) {
|
|
super(props);
|
|
this.state = {
|
|
numPages: null,
|
|
pageNumber: 1,
|
|
};
|
|
}
|
|
|
|
onDocumentLoadSuccess = ({ numPages }: PDFDocumentProxy) => {
|
|
this.setState({ numPages });
|
|
}
|
|
|
|
render() {
|
|
const { pageNumber, numPages } = this.state;
|
|
|
|
return (
|
|
<div>
|
|
<Document
|
|
file="somefile.pdf"
|
|
onLoadSuccess={this.onDocumentLoadSuccess}
|
|
>
|
|
<Page pageNumber={pageNumber} />
|
|
</Document>
|
|
<p>Page {pageNumber} of {numPages}</p>
|
|
</div>
|
|
);
|
|
}
|
|
}
|