aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorab <abdullah_ahmed@brown.edu>2019-06-28 15:25:39 -0400
committerab <abdullah_ahmed@brown.edu>2019-06-28 15:25:39 -0400
commit8891c0763fd86882d9e1d40c4fa4713aa14cac86 (patch)
tree88c5662fe7999426ec816a18e4c54272ada21b15
parentb02ce1a10d89fbf8768b93bf9d68c13cc0fb2752 (diff)
small fix
-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);