npm install pdfh5
import React, {Component} from 'react'
import Pdfh5 from 'pdfh5'
import 'pdfh5/css/pdfh5.css'
class Index extends Component {
constructor(props) {
super(props)
}
render() {
return <div id="demo"></div>
}
componentDidMount() {
this.file = new URLSearchParams(window.location.search).get('file')
this.pdfh5 = new Pdfh5('#demo', {
pdfurl: this.file,
lazy: true,
cMapUrl: '解析pdf时,特殊情况下显示完整字体的cmaps文件夹路径,如static/XXX',
})
//监听完成事件
this.pdfh5.on('complete', function (status, msg, time) {
console.log(
'状态:' +
status +
',信息:' +
msg +
',耗时:' +
time +
'毫秒,总页数:' +
this.totalNum
)
})
}
}
export default Index