Commit fb03287d authored by 李苏's avatar 李苏 💬

多页预览pdf

parent b407e6b5
......@@ -7,7 +7,7 @@
width="100%"
>
<div ref='show' v-if="show" style="height: 85vh;width: 100%">
<pdf v-if="showType=='pdf'" :src="url" ></pdf>
<pdf ref="show" v-if="showType=='pdf'" v-for="i in numPages" :key="i" :src="url" :page="i" ></pdf>
<!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> -->
<img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" >
</div>
......@@ -115,6 +115,7 @@
},
data() {
return{
numPages:1,
show:false,
isupLoad:false,
treeTitle: '文档目录',
......@@ -158,6 +159,15 @@
}
},
methods:{
getNumPages(url) {
var loadingTask = pdf.createLoadingTask(url)
loadingTask.promise.then(pdf => {
this.url = loadingTask
this.numPages = pdf.numPages
}).catch((err) => {
console.error('pdf加载失败')
})
},
/* 预览 */
preview(row){
console.log(row)
......@@ -176,6 +186,7 @@
type: 'application/'+row.fileType+';charset=UTF-8',
});
this.url=URL.createObjectURL(blob)
this.getNumPages(this.url)
this.show=true
this.$nextTick(()=>{
this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
......
......@@ -7,7 +7,7 @@
width="100%"
>
<div ref='show' v-if="show" style="height: 85vh;width: 100%">
<pdf v-if="showType=='pdf'" :src="url" ></pdf>
<pdf ref="show" v-if="showType=='pdf'" v-for="i in numPages" :key="i" :src="url" :page="i" ></pdf>
<!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> -->
<img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" >
</div>
......@@ -116,6 +116,7 @@
},
data() {
return{
numPages:1,
show:false,
isupLoad:false,
treeTitle: '文档目录',
......@@ -156,6 +157,15 @@
}
},
methods:{
getNumPages(url) {
var loadingTask = pdf.createLoadingTask(url)
loadingTask.promise.then(pdf => {
this.url = loadingTask
this.numPages = pdf.numPages
}).catch((err) => {
console.error('pdf加载失败')
})
},
/* 预览 */
preview(row){
console.log(row)
......@@ -174,6 +184,7 @@
type: 'application/'+row.fileType+';charset=UTF-8',
});
this.url=URL.createObjectURL(blob)
this.getNumPages(this.url)
this.show=true
this.$nextTick(()=>{
this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
......
......@@ -8,7 +8,7 @@
>
<div v-if="show" style="height: 85vh;width: 100%">
<!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> -->
<pdf ref="show" v-if="showType=='pdf'" :src="url" ></pdf>
<pdf ref="show" v-if="showType=='pdf'" v-for="i in numPages" :key="i" :src="url" :page="i" ></pdf>
<img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" >
</div>
</el-dialog>
......@@ -113,6 +113,7 @@
},
data() {
return{
numPages:1,
show:false,
isupLoad:false,
treeTitle: '目录',
......@@ -156,6 +157,16 @@
}
},
methods:{
getNumPages(url) {
var loadingTask = pdf.createLoadingTask(url)
loadingTask.promise.then(pdf => {
this.url = loadingTask
this.numPages = pdf.numPages
}).catch((err) => {
console.error('pdf加载失败')
})
},
/* 预览 */
preview(row){
console.log(row)
......@@ -174,6 +185,7 @@
type: 'application/'+row.fileType+';charset=UTF-8',
});
this.url=URL.createObjectURL(blob)
this.getNumPages(this.url)
this.show=true
this.$nextTick(()=>{
this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
......
......@@ -7,7 +7,7 @@
width="100%"
>
<div ref="show" v-if="show" style="height: 85vh;width: 100%">
<pdf v-if="showType=='pdf'" :src="url" ></pdf>
<pdf ref="show" v-if="showType=='pdf'" v-for="i in numPages" :key="i" :src="url" :page="i" ></pdf>
<!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> -->
<img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" >
</div>
......@@ -115,6 +115,7 @@
},
data() {
return{
numPages:1,
show:false,
isupLoad:false,
treeTitle: '目录',
......@@ -158,6 +159,15 @@
}
},
methods:{
getNumPages(url) {
var loadingTask = pdf.createLoadingTask(url)
loadingTask.promise.then(pdf => {
this.url = loadingTask
this.numPages = pdf.numPages
}).catch((err) => {
console.error('pdf加载失败')
})
},
/* 预览 */
preview(row){
console.log(row)
......@@ -176,6 +186,7 @@
type: 'application/'+row.fileType+';charset=UTF-8',
});
this.url=URL.createObjectURL(blob)
this.getNumPages(this.url)
this.show=true
this.$nextTick(()=>{
this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
......
......@@ -7,7 +7,7 @@
width="100%"
>
<div ref='show' v-if="show" style="height: 85vh;width: 100%">
<pdf v-if="showType=='pdf'" :src="url" ></pdf>
<pdf ref="show" v-if="showType=='pdf'" v-for="i in numPages" :key="i" :src="url" :page="i" ></pdf>
<!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> -->
<img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" >
</div>
......@@ -114,6 +114,7 @@
},
data() {
return{
numPages:1,
show:false,
isupLoad:false,
treeTitle: '目录',
......@@ -157,6 +158,15 @@
}
},
methods:{
getNumPages(url) {
var loadingTask = pdf.createLoadingTask(url)
loadingTask.promise.then(pdf => {
this.url = loadingTask
this.numPages = pdf.numPages
}).catch((err) => {
console.error('pdf加载失败')
})
},
/* 预览 */
preview(row){
console.log(row)
......@@ -175,6 +185,7 @@
type: 'application/'+row.fileType+';charset=UTF-8',
});
this.url=URL.createObjectURL(blob)
this.getNumPages(this.url)
this.show=true
this.$nextTick(()=>{
this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
......
......@@ -9,7 +9,7 @@
<div v-if="show" style="height: 85vh;width: 100%">
<!-- <iframe v-if="showType=='pdf'" :src="url" width="100%" height="100%" border="0"></iframe> -->
<pdf ref="show" v-if="showType=='pdf'" :src="url" ></pdf>
<pdf ref="show" v-if="showType=='pdf'" v-for="i in numPages" :key="i" :src="url" :page="i" ></pdf>
<img v-if="['gif','jpg','jpeg','png','bmp'].indexOf(showType)!=-1" :src="url" width="100%" height="100%" border="0" >
</div>
</el-dialog>
......@@ -116,6 +116,7 @@
},
data() {
return{
numPages:1,
show:false,
isupLoad:false,
treeTitle: '目录',
......@@ -159,6 +160,15 @@
}
},
methods:{
getNumPages(url) {
var loadingTask = pdf.createLoadingTask(url)
loadingTask.promise.then(pdf => {
this.url = loadingTask
this.numPages = pdf.numPages
}).catch((err) => {
console.error('pdf加载失败')
})
},
/* 预览 */
preview(row){
console.log(row)
......@@ -177,6 +187,7 @@
type: 'application/'+row.fileType+';charset=UTF-8',
});
this.url=URL.createObjectURL(blob)
this.getNumPages(this.url)
this.show=true
this.$nextTick(()=>{
this.$refs.show.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
......
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