857-dsh-pdf-patched: PDF Parsing and Non-embedded CJK Font Rendering for DSH

Introduction

In DeepSeek Harness (DSH), a common approach to let agents read PDFs is to wire up pdfjs-dist: page count, metadata, text layer, and full-page raster rendering are all possible. However, schematic PDFs exported by JLC EDA / EasyEDA often use Type0 fonts such as SimSun and SimHei, with fonts not embedded and encoding set to UniGB-UCS2-H; pdfjs will produce translateFont failed, dropping characters during rendering, and text extraction will also be incomplete. 857-dsh-pdf-patched is a DSH plugin published by maintainer RCYD857. It exposes three native tools on the agent side and automatically selects an engine between “fully embedded fonts” and “non-embedded CJK” documents, making extraction and PNG output for schematic-type PDFs usable.

What Is This

857-dsh-pdf-patched (npm package name @RCYD857/dsh-pdf-patched, current version 0.1.1) is a PDF parsing toolkit for DeepSeek Harness. The plugin registers pdf_info, pdf_extract_text, and pdf_render_page through the cordis entry point, and injects an agent guidance block; it does not depend on @deepseek-ai/dsh-tools, and parameters and outputs are plain JSON Schema. At runtime it requires Node ^22.19.0 || >=24.0.0, depends on pdfjs-dist 4.10.38 and @napi-rs/canvas 0.1.68, and is licensed under MIT.

Core Features

Three Agent Tools

Tool Purpose
pdf_info Page count, per-page dimensions (pt), document metadata, font list, and the embedded flag for each font
pdf_extract_text Extract text page by page; optional page, withPosition (line-level x/y and font size)
pdf_render_page Render a single page to a local PNG; configurable scale, outDir; engine selection is automatic

Dual-Engine Design

  • pdfjs engine: Used when all fonts in the document are embedded; suitable for regular PDFs.
  • sysfont engine: A built-in content stream parser that decodes operators such as BT/ET, Tf, Tm, Td, Tj, TJ, maps UniGB-UCS2-H / UTF-16BE to Unicode, and then draws via system fonts (SimSun, SimHei, Microsoft YaHei, etc.) through @napi-rs/canvas.

Text extraction also selects its engine automatically: embedded fonts go through the pdfjs text layer; non-embedded fonts go through the built-in decoder to recover CJK text that pdfjs loses.

Implementation Notes (for reading the source code again)

  • lib/index.js: cordis plugin entry, registers the three tools and injects systemPrompt.section (order 160).
  • lib/pdf-core.js: A self-contained engine (object parsing, font scanning, a CMap/StandardFont factory with fs, built-in extraction, and sysfont rendering).
  • cordis.patch.yml: A dsh.bundle.patch insert line; mounted via a node_modules symlink under the profile, without modifying dsh source code.

Installation and Activation

Install from GitHub under the web profile:

dsh plugin --profile web add github:RCYD857/857-dsh-pdf-patched

For local development, you can use a checkout path instead:

dsh plugin --profile web add link:<path-to-repo>

After installation, restart DSH or start a new session, and the three tools and the agent guidance block will be available.

Typical Usage

The README demonstrates with a JLC EDA-exported sample SCH_SA-V11A.pdf (adjust paths for your machine):

pdf_info("D:/Downloads/SCH_SA-V11A.pdf")
→ 3 pages, A3 landscape, jsPDF producer, 6 fonts (all non-embedded)

pdf_extract_text("D:/Downloads/SCH_SA-V11A.pdf", { page: 1 })
→ net names, pin numbers, and Chinese labels ("主控板", "嘉立创", …)

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)

Following the steps above, the agent can first call pdf_info to determine whether fonts are embedded, and then extract netlist annotations or render the full page for visual understanding as needed.

Use Cases and Caveats

Who it’s for: Developers who need to parse PDFs in DSH, especially schematics or documents from JLC EDA / EasyEDA and similar tools with non-embedded CJK fonts; similar scenarios tagged with pdf, schematic, and tools can also be referenced.

Limitations (from the original documentation):

  • Pure scanned / image-only PDFs have no text layer, so extraction returns empty; rendering can still output them as ordinary images.
  • The sysfont engine assumes Type0 CID codes equal Unicode code points (true for UniGB-UCS2-H exports); non-standard CID fonts fall back to pdfjs.
  • Large files are loaded entirely into memory.

Security and permissions: The plugin reads local paths and writes PNGs under the permissions of the current dsh process; please read the source code and the MIT license on the GitHub repository before installing. The DSH community plugin directory entry on SkillHub is an independent site with no official affiliation with DeepSeek / High-Flyer; in the ecosystem, DSH emphasizes “everything is a plugin,” and this plugin is one such implementation of PDF capabilities.

Conclusion

857-dsh-pdf-patched consolidates PDF metadata, text extraction, and single-page PNG rendering into three agent tools, and uses a hybrid pdfjs + sysfont engine to fill the gap for PDFs with non-embedded CJK fonts. To integrate it, use the installation command above and restart your session.

  • Directory page: https://www.skillhub.cn/plugins/RCYD857/857-dsh-pdf-patched
  • GitHub: https://github.com/RCYD857/857-dsh-pdf-patched
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye