Commit f039d592 authored by Mike Greiling's avatar Mike Greiling

Merge branch 'sh-fix-pdfjs-page-ordering' into 'master'

Fix pdf.js rendering pages in the wrong order

Closes #64467

See merge request gitlab-org/gitlab-ce!31222
parents 0715febb 5246626d
......@@ -14,7 +14,6 @@ export default {
},
data() {
return {
loading: false,
pages: [],
};
},
......@@ -37,17 +36,18 @@ export default {
return pdfjsLib
.getDocument(this.document)
.then(this.renderPages)
.then(() => this.$emit('pdflabload'))
.catch(error => this.$emit('pdflaberror', error))
.then(() => {
this.loading = false;
.then(pages => {
this.pages = pages;
this.$emit('pdflabload');
})
.catch(error => {
this.$emit('pdflaberror', error);
});
},
renderPages(pdf) {
const pagePromises = [];
this.loading = true;
for (let num = 1; num <= pdf.numPages; num += 1) {
pagePromises.push(pdf.getPage(num).then(p => this.pages.push(p)));
pagePromises.push(pdf.getPage(num));
}
return Promise.all(pagePromises);
},
......@@ -59,8 +59,8 @@ export default {
<div v-if="hasPDF" class="pdf-viewer">
<page
v-for="(page, index) in pages"
v-if="page"
:key="index"
:v-if="!loading"
:page="page"
:number="index + 1"
/>
......
......@@ -39,7 +39,9 @@ export default {
.then(() => {
this.rendering = false;
})
.catch(error => this.$emit('pdflaberror', error));
.catch(error => {
this.$emit('pdflaberror', error);
});
},
};
</script>
......
---
title: Fix pdf.js rendering pages in the wrong order
merge_request: 31222
author:
type: fixed
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