HLJ 发布于
2021-06-15 17:14:53

获取滑选pdf文件上的文字的实例代码

<template>
  <div>
    <iframe id="pdf" name="pdf" 
      src="static/web/viewer.html?file=compressed.tracemonkey-pldi-09.pdf" 
      style="width:100%; height:500px"></iframe>
  </div>
</template>
  
import $ from "jquery";
export default {
  created() {
    this.$nextTick(()=>{
      this.init()
    })
  },
  methods:{
    init(){
      setTimeout(() => {
        let createWindow = window.frames['pdf']
        let pdf = window.frames['pdf'].document
        $(pdf).find("#viewer").on('mouseup',() => {
          const selection = createWindow.getSelection()
          const text = selection.toString()
          console.log(text)
        })
      },3000)
    }
  }
}
当前文章内容为原创转载请注明出处:http://www.good1230.com/detail/2021-06-15/554.html
最后生成于 2023-06-27 21:37:48
此内容有帮助 ?
0