2017-08-17 22:00:37 +05:30
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
page: {
|
|
|
|
type: Object,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
number: {
|
|
|
|
type: Number,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
scale: 4,
|
|
|
|
rendering: false,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
viewport() {
|
|
|
|
return this.page.getViewport(this.scale);
|
|
|
|
},
|
|
|
|
context() {
|
|
|
|
return this.$refs.canvas.getContext('2d');
|
|
|
|
},
|
|
|
|
renderContext() {
|
|
|
|
return {
|
|
|
|
canvasContext: this.context,
|
|
|
|
viewport: this.viewport,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
this.$refs.canvas.height = this.viewport.height;
|
|
|
|
this.$refs.canvas.width = this.viewport.width;
|
|
|
|
this.rendering = true;
|
|
|
|
this.page.render(this.renderContext)
|
|
|
|
.then(() => { this.rendering = false; })
|
|
|
|
.catch(error => this.$emit('pdflaberror', error));
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
<template>
|
|
|
|
<canvas
|
|
|
|
ref="canvas"
|
|
|
|
:data-page="number"
|
2018-11-08 19:23:39 +05:30
|
|
|
class="pdf-page"
|
2018-03-17 18:26:18 +05:30
|
|
|
>
|
|
|
|
</canvas>
|
|
|
|
</template>
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
<style>
|
2018-03-17 18:26:18 +05:30
|
|
|
.pdf-page {
|
|
|
|
margin: 8px auto 0 auto;
|
|
|
|
border-top: 1px #ddd solid;
|
|
|
|
border-bottom: 1px #ddd solid;
|
|
|
|
width: 100%;
|
|
|
|
}
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
.pdf-page:first-child {
|
|
|
|
margin-top: 0px;
|
|
|
|
border-top: 0px;
|
|
|
|
}
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
.pdf-page:last-child {
|
|
|
|
margin-bottom: 0px;
|
|
|
|
border-bottom: 0px;
|
|
|
|
}
|
2017-08-17 22:00:37 +05:30
|
|
|
</style>
|