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 🙏

© 2025 – Pkg Stats / Ryan Hefner

opdf

v0.0.56

Published

> 基于pdfjs实现的功能强大的pdf框架, 基于pdfjs/web/viewer.html, 可以用来开发pdf应用.

Readme

O-Pdfjs

基于pdfjs实现的功能强大的pdf框架, 基于pdfjs/web/viewer.html, 可以用来开发pdf应用.

使用

// vite
import worker from '../../assets/files/pdf.worker.min.js?url';

import {createViewerInstance} from 'opdf';

// 初始化
const [pdfState, setPdfState] = useState<{
  loading: boolean;
  thumbnailUrl?: string;
}>();

const instance = createViewerInstance(PDF_VIEWER_ID, {
  pdf_url: pdfUrl,
  worker_url: worker,
  default_match: [...activeMatch],
  hasThumbnail: true,
});

instance.then((res: any) => {
  setPdfState({loading: res?.loading, thumbnailUrl: res?.thumbnailUrl});
});

// 左右联动
import {scrollView} from 'opdf';

// 滚动到指定位置
const scrollTo = (to: string) => {
  console.log('to', document.getElementById(PDF_VIEWER_CONTAINER_ID));
  scrollView({
    to,
    // scrollContainer未指定则默认为window
    scrollContainer:
        document.getElementById(PDF_VIEWER_CONTAINER_ID) || undefined,

  });
};
// Tsx
return (
    <div onClick={() => {scrollTo(`${list.text}_${list?.index}`)}}>
      {list?.text}
    </div>
)

功能

渲染等基础功能

  • [x] 支持pdf渲染
  • [x] 支持pdf文档缩放
  • [ ] 支持pdf文档翻页
  • [ ] 支持pdf文档搜索
  • [ ] 支持pdf文档全屏
  • [x] 支持pdf文档缩略图
  • [x] 加载进度条
  • [ ] ....

选中文字的功能

  • [x] 支持选中文字后进行回调功能

鼠标悬浮后框选周边的文字

  • [ ] 支持鼠标悬浮后框选周边的文字
  • [ ] 生成图片提供下载、分享

高亮的联动和配置

  • [x] 支持高亮的联动和配置

重要说明

M1相关无法本地启动的问题

pdfjs目前使用的node-canvas版本为有问题,但是在M1芯片的mac上,node-canvas无法正常启动,所以需要手动安装node-canvas,安装方法如下:

安装依赖

brew install pkg-config cairo pango libpng jpeg giflib librsvg pixman

brew cleanup

rm -r node_modules/

npm install