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

@zhtx2026/dsh-pdf

v0.1.1

Published

DSH PDF 解析插件: 为 agent 提供 pdf_info / pdf_extract_text / pdf_render_page 三个工具。基于 pdfjs-dist + @napi-rs/canvas; 对未内嵌字体的 PDF (如嘉立创EDA导出) 自动改用系统字体渲染文字。热插拔 — 通过 cordis.patch.yml + profile node_modules 软链接挂载, 无需改动 dsh 源码。

Readme

@zhtx2026/dsh-pdf

DeepSeek Harness 的 PDF 解析工具集 — 提供 pdf_info / pdf_extract_text / pdf_render_page 三个模型可见工具,双引擎架构,未内嵌中文字体的 PDF(如嘉立创 EDA / EasyEDA 导出的原理图)自动切换系统字体渲染。

English | 中文

标签: dsh-plugin · pdf · pdfjs · canvas · schematic · tools

安装

dsh plugin --profile web add @zhtx2026/dsh-pdf

开发期可从本地源码安装:

dsh plugin --profile web add link:<路径>

重启 DSH(或开新会话)后生效,同时注入中文协作公告。

工具

| 工具 | 能力 | |---|---| | pdf_info | 页数、页面尺寸(pt)、文档元数据、字体列表及每项 embedded 内嵌标记。 | | pdf_extract_text | 按页提取文字;可选 pagewithPosition(每行 x/y 坐标 + 字号)。 | | pdf_render_page | 把一页渲染为本地 PNG;scale/outDir 可配;渲染引擎自动选择。 |

为什么需要自研渲染器

pdfjs-dist 无法渲染「字体未内嵌且无 ToUnicode 映射」的 PDF 文字 —— 典型就是 嘉立创 EDA / EasyEDA 导出的原理图(SimSun/SimHei Type0 字体、 UniGB-UCS2-H 编码):pdfjs 会报 translateFont failed 并丢字。

dsh-pdf 用双引擎解决:

  • pdfjs 引擎 — 字体全部内嵌时使用(常规 PDF)。
  • sysfont 引擎 — 自研内容流渲染器:自己解析文本算子 (BT/ETTfTmTdTjTJ),把 UniGB-UCS2-H/UTF-16BE 串解码为 Unicode,再经 @napi-rs/canvas系统字体(宋体、黑体、 微软雅黑……)绘制。

文字提取同样自动选择:字体全内嵌 → pdfjs 文本层;存在未内嵌字体 → 自研解码器(正确还原 pdfjs 会丢失的中文)。

示例

pdf_info("D:/Downloads/SCH_SA-V11A.pdf")
→ 3 页、A3 横向、jsPDF 生成、6 个字体(全部未内嵌)

pdf_extract_text("D:/Downloads/SCH_SA-V11A.pdf", { page: 1 })
→ 网络名、引脚号、中文标签("主控板"、"嘉立创"……)

pdf_render_page("D:/Downloads/SCH_SA-V11A.pdf", { page: 1, scale: 2 })
→ D:/Downloads/SCH_SA-V11A-pages/page-1.png (2396×1698,engine: sysfont)

架构

  • lib/index.js — cordis 插件入口(nameinjectapply);以原生工具 对象注册三个工具(标准 JSON-Schema parameters/output,无需依赖 @deepseek-ai/dsh-tools),并注入中文协作公告(systemPrompt.section, order 160)。
  • lib/pdf-core.js — 自包含引擎:PDF 对象解析器、字体扫描、基于 fs 的 CMapReaderFactory/StandardFontDataFactory 加载 pdfjs(Node 24 全局 fetch 不支持 file://)、自研文本提取器、sysfont 渲染器。
  • cordis.patch.ymldsh.bundle.patch 插入行。

限制

  • 扫描件/纯图片 PDF 无文字层,提取不到文字(渲染仍可用,等同原图)。
  • sysfont 渲染器假设 Type0 的 CID 即 Unicode 码点(UniGB-UCS2-H 导出 成立);特殊 CID 字体回退 pdfjs。
  • 大文件整份读入内存解析。

许可证

MIT