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 🙏

© 2026 – Pkg Stats / Ryan Hefner

iframe-capture

v1.0.1

Published

一个强大的 iframe 截图工具包,支持截图、PDF 生成和图片下载

Readme

iframe-capture

一个强大的 iframe 截图工具包,支持网页截图、PDF 生成和图片下载。

特性

  • 支持将 iframe 内容导出为图片或 PDF
  • 支持自定义截图尺寸、缩放、背景色等参数
  • 简单易用,TypeScript 支持
  • 基于 html2canvas-pro 和 jsPDF

安装

npm install iframe-capture
# 或
pnpm add iframe-capture

快速上手

import { IframeCapture } from "iframe-capture";

const capturer = new IframeCapture();
const iframe = document.getElementById("your-iframe-id") as HTMLIFrameElement;

// 截图并生成 PDF
await capturer.captureIframeToPDF(iframe, "output.pdf");

// 截图并生成图片
await capturer.captureIframeToImage(iframe, "output.jpg");

API 说明

IframeCapture

  • captureIframe(iframe: HTMLIFrameElement, options?: IframeCaptureOptions): Promise<IframeCaptureResult>
  • captureIframeToPDF(iframe: HTMLIFrameElement, filename?: string, options?: IframeCaptureOptions): Promise<void>
  • captureIframeToImage(iframe: HTMLIFrameElement, filename?: string, options?: IframeCaptureOptions): Promise<void>

IframeCaptureOptions

| 参数 | 类型 | 默认值 | 说明 | | --------------- | ------- | ------- | ---------------- | | width | number | 1280 | 截图宽度 | | height | number | 720 | 截图高度 | | scale | number | 2 | 缩放倍数 | | backgroundColor | string | #ffffff | 背景色 | | logging | boolean | false | 是否日志输出 | | allowTaint | boolean | true | 是否允许跨域内容 | | useCORS | boolean | true | 是否使用 CORS | | waitTime | number | 1000 | 等待渲染时间(ms) |

常见问题

  • 跨域 iframe 无法截图?
    需要目标 iframe 支持 CORS,或设置 allowTaint 为 true,但部分浏览器安全策略可能仍有限制。

  • 图片/字体未加载完成就截图?
    可适当增加 waitTime 参数,确保资源加载完毕。

贡献

欢迎提 issue 或 PR 参与贡献!

  1. Fork 本仓库
  2. 新建分支进行开发
  3. 提交 PR

发布

  1. 确认 dist 目录下有 index.js 和 index.d.ts
  2. 更新 package.json 版本号
  3. 登录 npm:npm login
  4. 一键发布:npm run publish:all