Commit c34138e0 authored by Stan Hu's avatar Stan Hu

Remove pdf.js deprecation warnings

1. `page.getViewpoint()` now takes in JSON instead of an integer.
2. Promises are returned from loading and rendering tasks.

See https://mozilla.github.io/pdf.js/examples/index.html for more
details.
parent 11f82c89
...@@ -39,7 +39,7 @@ export default { ...@@ -39,7 +39,7 @@ export default {
cMapUrl: '/assets/webpack/cmaps/', cMapUrl: '/assets/webpack/cmaps/',
cMapPacked: true, cMapPacked: true,
}) })
.then(this.renderPages) .promise.then(this.renderPages)
.then(pages => { .then(pages => {
this.pages = pages; this.pages = pages;
this.$emit('pdflabload'); this.$emit('pdflabload');
......
...@@ -18,7 +18,7 @@ export default { ...@@ -18,7 +18,7 @@ export default {
}, },
computed: { computed: {
viewport() { viewport() {
return this.page.getViewport(this.scale); return this.page.getViewport({ scale: this.scale });
}, },
context() { context() {
return this.$refs.canvas.getContext('2d'); return this.$refs.canvas.getContext('2d');
...@@ -36,7 +36,7 @@ export default { ...@@ -36,7 +36,7 @@ export default {
this.rendering = true; this.rendering = true;
this.page this.page
.render(this.renderContext) .render(this.renderContext)
.then(() => { .promise.then(() => {
this.rendering = false; this.rendering = false;
}) })
.catch(error => { .catch(error => {
......
---
title: Remove pdf.js deprecation warnings
merge_request: 31253
author:
type: fixed
...@@ -17,7 +17,7 @@ describe('Page component', () => { ...@@ -17,7 +17,7 @@ describe('Page component', () => {
pdfjsLib.GlobalWorkerOptions.workerSrc = workerSrc; pdfjsLib.GlobalWorkerOptions.workerSrc = workerSrc;
pdfjsLib pdfjsLib
.getDocument(testPDF) .getDocument(testPDF)
.then(pdf => pdf.getPage(1)) .promise.then(pdf => pdf.getPage(1))
.then(page => { .then(page => {
testPage = page; testPage = page;
}) })
...@@ -31,7 +31,8 @@ describe('Page component', () => { ...@@ -31,7 +31,8 @@ describe('Page component', () => {
it('renders the page when mounting', done => { it('renders the page when mounting', done => {
const promise = Promise.resolve(); const promise = Promise.resolve();
spyOn(testPage, 'render').and.callFake(() => promise); spyOn(testPage, 'render').and.returnValue({ promise });
vm = mountComponent(Component, { vm = mountComponent(Component, {
page: testPage, page: testPage,
number: 1, number: 1,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment