aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStanley Yip <33562077+yipstanley@users.noreply.github.com>2019-06-28 15:26:51 -0400
committerGitHub <noreply@github.com>2019-06-28 15:26:51 -0400
commit71d5df7a31cec09a021c47034ac5aa6d6559af6a (patch)
tree88c5662fe7999426ec816a18e4c54272ada21b15 /src
parentb02ce1a10d89fbf8768b93bf9d68c13cc0fb2752 (diff)
parent8891c0763fd86882d9e1d40c4fa4713aa14cac86 (diff)
Merge pull request #176 from browngraphicslab/pdf_fixes
small fix
Diffstat (limited to 'src')
-rw-r--r--src/client/views/pdf/PDFViewer.tsx8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/client/views/pdf/PDFViewer.tsx b/src/client/views/pdf/PDFViewer.tsx
index 0cc81d469..63a103aa2 100644
--- a/src/client/views/pdf/PDFViewer.tsx
+++ b/src/client/views/pdf/PDFViewer.tsx
@@ -192,9 +192,10 @@ class Viewer extends React.Component<IViewerProps> {
let pageSizes = Array<{ width: number, height: number }>(this.props.pdf.numPages);
this._isPage = Array<string>(this.props.pdf.numPages);
// this._textContent = Array<Pdfjs.TextContent>(this.props.pdf.numPages);
+ const proms: Pdfjs.PDFPromise<any>[] = [];
for (let i = 0; i < this.props.pdf.numPages; i++) {
- await this.props.pdf.getPage(i + 1).then(page => runInAction(() => {
- pageSizes[i] = { width: page.view[2] * scale, height: page.view[3] * scale };
+ proms.push(this.props.pdf.getPage(i + 1).then(page => runInAction(() => {
+ pageSizes[i] = { width: page.view[page.rotate === 0 ? 2 : 3] * scale, height: page.view[page.rotate === 0 ? 3 : 2] * scale };
// let x = page.getViewport(scale);
// page.getTextContent().then((text: Pdfjs.TextContent) => {
// // let tc = new Pdfjs.TextContentItem()
@@ -205,8 +206,9 @@ class Viewer extends React.Component<IViewerProps> {
// // })
// });
// pageSizes[i] = { width: x.width, height: x.height };
- }));
+ })));
}
+ await Promise.all(proms);
runInAction(() =>
Array.from(Array((this._pageSizes = pageSizes).length).keys()).map(this.getPlaceholderPage));
this.props.loaded(Math.max(...pageSizes.map(i => i.width)), pageSizes[0].height, this.props.pdf.numPages);