目前方案采用wasm实现ofd解析、渲染、验签,不支持IE
examples已增加原生js、reactjs的demo
npm i ofd.js
目前可以通过 unpkg.com/ofd.js 获取到最新版本的资源,在页面上引入 js 文件即可开始使用。
html引用js文件
<script type="text/javascript" src="./OfdParser.js"></script>
<script src="https://unpkg.com/ofd.js"></script>
<script type="text/javascript">
ofd.onWebassemblyRuntimeInitialized(()=>{
console.log(ofd)
})
</script>
onWebassemblyRuntimeInitialized(()=>{
//do something
})
ofdFile为OFD文件。支持File、ArrayBuffer及url
secret
parseOfdDocument({
ofd: ofdFile,
secret: '6wsz1zH2NHnRKuvH',
success(res) {
console.log(res)
}
})
ofdData为解析ofd文件接口返回的OFD对象
documentIndex为ofd文档中document的索引,默认从0开始
getOFDPageCount(ofdData, documentIndex)
ofdData为解析ofd文件接口返回的OFD对象
documentIndex为ofd文档中document的索引,默认从0开始
pageIndex为ofd文档中页码,默认从0开始
pageWidth(ofdData, documentIndex, pageIndex)
ofdData为解析ofd文件接口返回的OFD对象
documentIndex为ofd文档中document的索引,默认从0开始
pageIndex为ofd文档中页码,默认从0开始
pageHeight(ofdData, documentIndex, pageIndex)
ofdData为解析ofd文件接口返回的OFD对象
documentIndex为ofd文档中document的索引,默认从0开始
renderOfd(ofdData, documentIndex, width)
pageDiv为html中div容器
ofdData为解析ofd文件接口返回的OFD对象
documentIndex为ofd文档中document的索引,默认从0开始
pageIndex为ofd文档中页码,默认从0开始
renderOfdByIndex(pageDiv, ofdData, documentIndex, pageIndex, width)
html需要添加一个id为OfdView的div容器,其中overflow必须设置为auto,height必须有值,否则不会自动渲染后面的页面
<div id="OfdView" style="overflow:auto;height:1000px"></div>
js方法
ofdFile为OFD文件。支持File、ArrayBuffer及url
openOfdBaseViewer(ofdFile)
如需获取帮助可以扫码加微信或者知识星球
项目获得 Star曲线