npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ofd_dev.js

v1.3.2

Published

ofd渲染

Downloads

4

Readme

ofd.js

- license

目前方案采用wasm实现ofd解析、渲染、验签,不支持IE

examples已增加原生js、reactjs的demo

效果: 示例

体验地址

pc安装包

Usage with npm

npm i ofd.js

Usage with CDN

引入 https://cdn.jsdelivr.net/npm/ofd_parser.js 以及 https://cdn.jsdelivr.net/npm/ofd.js

<script src="https://cdn.jsdelivr.net/npm/ofd_parser.js"></script>
<script src="https://cdn.jsdelivr.net/npm/ofd.js"></script>

相关接口说明

webassembly加载回调,必须调用

Browser <script>:

ofd.onWebassemblyRuntimeInitialized(()=>{
    //后续接口
})  

Webpack:

import {onWebassemblyRuntimeInitialized} from './ofd.js'
onWebassemblyRuntimeInitialized(()=>{
    //后续接口
}) 

解析OFD文件

此方法需要在webassembly回调后使用

| 参数 | 说明 | 是否必填 | | ----------- | ------------------------------------------------------------ | -------- | | ofdFile | OFD文件。支持File、ArrayBuffer及url | 是 | | secret | 校验码,demo提供的校验码有时间限制 | 是 | | haaders | 如果url需要headers传入此参数,如{key1:value1, key2:value2} | 否 |

parseOfdDocument({
        ofd: ofdFile,
        secret: '6wsz1zH2NHnRKuvH',
        success(core) {
            console.log(core)
        },
        fail(error){
            console.log(error)
        }
    })

获取OFD文档页数

此方法需要在parseOfdDocument success回调后使用

| 参数 | 说明 | 是否必填 | | ----------- | ------------------------------------------------------------ | -------- | | documentIndex | ofd文档中document的索引,默认从0开始 | 是 |

getOFDPageCount(documentIndex)

获取OFD文档对应页的页宽

此方法需要在parseOfdDocument success回调后使用 | 参数 | 说明 | 是否必填 | | ----------- | ------------------------------------------------------------ | -------- | | documentIndex | ofd文档中document的索引,默认从0开始 | 是 | | pageIndex | ofd文档中页码,默认从0开始 | 是 |

pageWidth(documentIndex, pageIndex)

获取OFD文档对应页的页高

此方法需要在parseOfdDocument success回调后使用 | 参数 | 说明 | 是否必填 | | ----------- | ------------------------------------------------------------ | -------- | | documentIndex | ofd文档中document的索引,默认从0开始 | 是 | | pageIndex | ofd文档中页码,默认从0开始 | 是 |

pageHeight(documentIndex, pageIndex)

获取OFD文档对应页的实际size以及渲染的size

此方法需要在parseOfdDocument success回调后使用 | 参数 | 说明 | 是否必填 | | ----------- | ------------------------------------------------------------ | -------- | | documentIndex | ofd文档中document的索引,默认从0开始 | 是 | | pageIndex | ofd文档中页码,默认从0开始 | 是 | | width | 预期渲染的宽度,像素值 ,如800 | 否 |

pageSize(documentIndex, pageIndex, width)

一次性渲染OFD对应文档的所有页,适合页数少

此方法需要在parseOfdDocument success回调后使用 | 参数 | 说明 | 是否必填 | | ----------- | ------------------------------------------------------------ | -------- | | documentIndex | ofd文档中document的索引,默认从0开始 | 是 | | width | 预期渲染的宽度,像素值 ,如800 | 否 |

renderOfd(documentIndex, width).then(divs=>{
    // do something
})

渲染OFD对应文档的对应页

此方法需要在parseOfdDocument success回调后使用 | 参数 | 说明 | 是否必填 | | ----------- | ------------------------------------------------------------ | -------- | | documentIndex | ofd文档中document的索引,默认从0开始 | 是 | | pageIndex | ofd文档中页码,默认从0开始 | 是 | | width | 预期渲染的宽度,像素值 ,如800 | 否 |

renderOfdByIndex(documentIndex, pageIndex, width).then(div => {
    // do something
}})

打开一个基础的内置ofdview。适合打开大于100页的文档,具体看examples中的html例子

html需要添加一个id为xxx的div容器,其中overflow必须设置为auto,width和height必须设置

<div id="OfdView" style="overflow:auto;width:800px;height:1000px"></div>

此方法需要在webassembly回调后使用 | 参数 | 说明 | 是否必填 | | ----------- | ------------------------------------------------------------ | -------- | | ofdFile | OFD文件。支持File、ArrayBuffer及url | 是 | | secret | 校验码,demo提供的校验码有时间限制 | 是 | | contentDiv | document.getElementById('xxx') | 是 | | expectWidth | 期望渲染的每页宽度 | 否 |

openOFDBaseViewer(ofdFile, secret, contentDiv, expectWidth)

获取帮助

如需获取帮助可以扫码加微信或者知识星球

示例

示例

微信小程序体验OFD

示例

ofd推荐项目

OFD Reader & Writer

ofd.android

项目关注度

项目获得 Star曲线

Stargazers over time