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 {
cMapUrl: '/assets/webpack/cmaps/',
cMapPacked: true,
})
.then(this.renderPages)
.promise.then(this.renderPages)
.then(pages => {
this.pages = pages;
this.$emit('pdflabload');
......
......@@ -18,7 +18,7 @@ export default {
},
computed: {
viewport() {
return this.page.getViewport(this.scale);
return this.page.getViewport({ scale: this.scale });
},
context() {
return this.$refs.canvas.getContext('2d');
......@@ -36,7 +36,7 @@ export default {
this.rendering = true;
this.page
.render(this.renderContext)
.then(() => {
.promise.then(() => {
this.rendering = false;
})
.catch(error => {
......
---
title: Remove pdf.js deprecation warnings
merge_request: 31253
author:
type: fixed
......@@ -17,7 +17,7 @@ describe('Page component', () => {
pdfjsLib.GlobalWorkerOptions.workerSrc = workerSrc;
pdfjsLib
.getDocument(testPDF)
.then(pdf => pdf.getPage(1))
.promise.then(pdf => pdf.getPage(1))
.then(page => {
testPage = page;
})
......@@ -31,7 +31,8 @@ describe('Page component', () => {
it('renders the page when mounting', done => {
const promise = Promise.resolve();
spyOn(testPage, 'render').and.callFake(() => promise);
spyOn(testPage, 'render').and.returnValue({ promise });
vm = mountComponent(Component, {
page: testPage,
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