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_parser_wx.js

v0.0.6

Published

ofd渲染

Downloads

13

Readme

ofd.js

- license

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

examples已增加原生js、reactjs的demo

效果: 示例

体验地址

Usage with npm

npm i ofd.js

Usage with CDN

目前可以通过 unpkg.com/ofd.js 获取到最新版本的资源,在页面上引入 js 文件即可开始使用。

html引用js文件
<script type="text/javascript" src="./OfdParser.js"></script>
<script type="text/javascript" src="./FreetypeKit.js"></script>
<script src="https://unpkg.com/ofd.js"></script>

<script type="text/javascript">
    ofd.onWebassemblyRuntimeInitialized(()=>{
        console.log(ofd)
    })  
</script>

相关接口说明

webassembly加载回调

onWebassemblyRuntimeInitialized(()=>{
//do something
})

解析OFD文件

ofdFile为OFD文件。支持File或者ArrayBuffer
parseOfdDocument({
        ofd: ofdFile,
        success(res) {
            console.log(res)
        }
    })

获取OFD文档页数

ofdData为解析ofd文件接口返回的OFD对象
documentIndex为ofd文档中document的索引,默认从0开始

getOFDPageCount(ofdData, documentIndex)

获取OFD文档对应页的页宽

ofdData为解析ofd文件接口返回的OFD对象
documentIndex为ofd文档中document的索引,默认从0开始
pageIndex为ofd文档中页码,默认从0开始

pageWidth(ofdData, documentIndex, pageIndex)

获取OFD文档对应页的页高

ofdData为解析ofd文件接口返回的OFD对象
documentIndex为ofd文档中document的索引,默认从0开始
pageIndex为ofd文档中页码,默认从0开始

pageHeight(ofdData, documentIndex, pageIndex)

设置渲染的DPI

dpi---对应的dpi值,默认是96

setPageDPI(dpi)

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

ofdData为解析ofd文件接口返回的OFD对象
documentIndex为ofd文档中document的索引,默认从0开始

renderOfd(ofdData, documentIndex)

渲染OFD对应文档的对应页

pageDiv为html中div容器
ofdData为解析ofd文件接口返回的OFD对象
documentIndex为ofd文档中document的索引,默认从0开始
pageIndex为ofd文档中页码,默认从0开始

renderOfdByIndex(pageDiv, ofdData, documentIndex, pageIndex)

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

html需要添加一个id为OfdView的div容器,其中overflow必须设置为auto,height必须有值,否则不会自动渲染后面的页面

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

js方法

ofdFile为OFD文件。支持File或者ArrayBuffer

openOfdView(ofdFile)

获取帮助

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

示例

示例

微信小程序体验OFD

示例

ofd推荐项目

OFD Reader & Writer

ofd.android

项目关注度

项目获得 Star曲线

Stargazers over time