wwf
17 小时以前 4f218aac60322f6b0cd90447f8c13f6fb6ff88e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<script setup lang="ts">
import Pdfh5 from "pdfh5"
import { ref, onMounted, onUnmounted } from 'vue'
 
const container = ref<HTMLElement>()
let pdfViewer: any = null
 
const props = defineProps({
  url: {
    type: String,
    required: true
  }
})
 
onMounted(async () => {
  try {
    // 创建PDF查看器
    pdfViewer = new Pdfh5(container.value!, {
      pdfurl: props.url,
      textLayer: true,
      workerSrc: '/examination/user/pdf.worker.min.js',
      cMapUrl: '/examination/user/cmaps/',
      standardFontDataUrl: '/examination/user/standard_fonts/',
      iccUrl: '/examination/user/iccs/',
      wasmUrl: '/examination/user/wasm/'
    });
    const appElement = document.getElementById('app')
    
  } catch (error) {
    console.error('PDF初始化失败:', error);
  }
})
 
onUnmounted(() => {
  if (pdfViewer && typeof pdfViewer.destroy === 'function') {
    pdfViewer.destroy()
  }
})
</script>
 
<template>
  <div class="pdf-container" ref="container"></div>
</template>
 
<style scoped>
.pdf-container {
  width: 100%;
  height: 100%;
}
</style>