PDF Reading · Q&A Anytime

DSH Plugin: Turn a PDF into a Full-Page Workbench for Chapter-by-Chapter Reading, Annotation, and Q&A.

Introduction

Reading a PDF in DSH usually requires juggling the reader, a notes panel, and a chat window all at once: Where am I in this chapter? Is my last annotation still there? Want to ask a question? You have to copy the book title, chapter name, and page number again. minggemofashi/dsh-pdf-workbench structures “book → chapter” as the backbone, keeping reading, annotation, bilingual view, Q&A, and output all on a single page. Sessions carry the book title, chapter name, page number, and output directory with them automatically.

Plugin Positioning

This is a PDF reading workbench plugin for DSH. It splits a PDF by chapter, creates an independent session for each chapter, and provides annotation, translation, Q&A, and export features. The plugin is maintained by minggemofashi and released under the MIT license.

Installation

Install the plugin in DSH, then restart (the client does not hot-reload):

dsh plugin add dsh-pdf-workbench

You can also select the marketplace entry or the extracted directory via Plugins → Add plugin. After installation, open the “PDF Reading” panel in the sidebar.

Usage Steps

  1. Add a library: Select a library root directory containing at least one of 分片 (chunks) or 整本 (full books).
  2. Load a sample book: If you have no books, click this to install a 10-chapter Chinese Remainder Theorem book to explore the bookshelf, reader, and splitting panel.
  3. Double-click a book → expand chapters → open the PDF, or create a new “Extract / Q&A / Exercises” session.

Library Directory Structure

<library-root>/
  分片/<book-id>/         One PDF per chapter, filename includes page range
  整本/                   Full-book PDFs, treated as "a one-chapter book"
  产物/<book-id>/<chapter>/  Notes and documents generated for that chapter
  封面/                   Custom covers
  索引.json               Metadata such as book/chapter names (optional, maintained by the plugin)
  .pdfdesk/               Annotations, questions, attachment lists, translation cache (written by the plugin—do not edit manually)

分片 and 整本 hold the PDFs; the remaining directories are plugin data. Renaming them will break the library and its index.

Why Per-Chapter

One session per chapter, reading only that chapter: small context, lower cost, precise positioning. The “Extract / Q&A / Exercises” sessions for the same chapter share a read-once prefix, then branch independently without cross-contamination. Base sessions do not appear in the sidebar.

When you don’t actively create a new session, the library, bookshelf, reading, annotation, and preview stay out of context.

Bookshelf & Splitting

  • Libraries & Bookshelves: Multiple libraries; custom bookshelves, hide books, recycle bin; after selection you can “Add to shelf,” and you can also add PDFs directly within a shelf.
  • Full-book pinning: To always show a specific full-book PDF, use “Always show full book”—the preference is remembered per book. The global “Full book” toggle only affects un-pinned books.
  • Page-based splitting: Thumbnails display 4 pages per row with vertical dashed lines + scissors between pages; range and filename preview update in real time. Split points are remembered per book; you can recover if accidentally closed.
  • Faster splitting: Thumbnails are rendered once by the Host and cached (PyMuPDF + Pillow). Even an 80 MB book opens quickly, loading as you scroll. Falls back to browser-side pdf.js when Python is not installed.
  • Two choices after splitting: Whether to remove the full-book entry, and whether to open a split session. Only the original PDF is moved—same-named chunk directories are never accidentally deleted. Split books automatically join the bookshelf where the full-book version was, as well as the bookshelf where the split was initiated.

Reading & Canvas

  • Single page / Continuous: Single-page mode focuses on one page; continuous mode scrolls through the chapter. The mode is remembered globally. Dragging the scrollbar to the bottom won’t leave a blank area—columns remount based on the viewport.
  • Shared canvas: Both modes share the same annotation layer; off-page coordinates can extend beyond the page. Only notes are drawn off-page; adjacent pages are not rendered.
  • Tools: Hand, select, pen, eraser, text, question, line, arrow, rectangle, diamond, ellipse, box-select; the toolbar is arranged vertically along the page edge.
  • Box feel: Boxes use a fixed in-page color + white stroke, remaining visible in dark themes; you can drag a new box directly over an existing one; after selecting a text box, four directional handles appear at the top, with corner scaling.
  • Shortcuts: ←/→ page navigation, Ctrl +=/- zoom, F fit width, T toggle single/continuous, G go to page, P/E/X pen/eraser/text, Q question box, Shift+Q jump to question, Esc exit; Settings → Shortcuts to customize.

Chapter Sessions & Questions

  • Sessions carry context: Book title, chapter name, PDF, reading position, and output directory—no need to repeatedly explain “which book I’m reading.”
  • Two thinking modes: Daily (conclusion first, 3–5 sentences) and High-quality (allows lengthy derivation), both read the full chapter; switching only affects new sessions. The style prompts for both modes are editable, with a one-click reset to defaults.
  • Question box screenshots for AI: The right-side preview shows framed questions; the page region inside the frame is rendered as a lossless WebP and sent to the model, so it can directly see the content in the frame rather than just a page number.
  • Question jumping: Jump directly to the corresponding page and frame from the chapter’s question list.

Bilingual View & Overlay

  • After translating a full chapter, left and right panes appear side by side, sharing page numbers with independent annotation layers. Translation is cached per page and supports resuming from a breakpoint.
  • The overlay displays translations on the original page in a framed area: a browser text layer laid out per layout.json + KaTeX formulas—crisp at any zoom level, with boxes and text sharing the same source.
  • Typesetting uses Typst, ~10 s per chapter; without Typst, falls back to TeX Live’s xelatex. If Typst is installed, TeX is not needed.

Attachments & Output

  • Attachments: Add PDFs / images in the chapter details; click to open in the reader. Duplicate names, deletions, and manually added files in the directory are all handled.
  • PPT → PDF: Prefers local PowerPoint, falls back to LibreOffice; if no converter is available, a clear message is shown instead of hanging.
  • Output: Text files under 产物/<book-id>/<chapter>/ can be previewed on the right; Markdown can be one-click converted to a print page.
  • Office files: DOCX/DOC files are opened via DSH’s document preview—not hard-rendered inside the plugin.

Import, Export & Migration

  • Import pipeline: Library “Import File,” cover “+”, book packages, and migration packages all go through the same Host pipeline—file header validation (fake PDFs, renamed shortcuts, 0-byte files, non-UTF-8 text are all rejected), streaming to a temp file followed by atomic write, deduplication by content (size + sha256), duplicate names get -2, -3… suffixes, and a unified report is returned in one go.
  • Import wizard: PDF package (subdirectories = split books, loose PDFs = full books) + optional notes package, with per-book checkboxes. Books with identical PDFs already in the library are auto-checked and greyed out; PDFs are not re-imported. Notes can be merged / overwritten / skipped per book.
  • “Split after import” can be remembered: Once saved, the prompt won’t appear every time; change back to “ask each time” in Settings → Reading.
  • Three package types: Full-machine migration package (sessions + plugin state + each library’s .pdfdesk), library package (索引.json + notes + optional output), PDF package (only the PDFs in 分片/ and 整本/)—the first two do not contain PDFs. Packaging runs in the background; results appear in “Package Log” with download, open-location, and delete options.
  • Import strategy: Migration packages validate per-file sha256 first; merge never overwrites, overwrite creates a pre-import-* snapshot first, skip skips same-name files.
  • Streaming: Library packages and migration packages—both packaging and import—do not load the entire package into memory. GB-scale packages won’t exhaust process memory, and corrupted packages are rejected before writing to disk.

Data & Privacy

  • Data location: Settings → Data → “Data Location” displays the library directory and plugin data directory in read-only form (determined by profile configuration).
  • Translation cache is per-library: <library>/.pdfdesk/translation/<book-id>/<chapter>/. Same-named books in different libraries do not cross-contaminate.
  • Annotation mirror: .pdfdesk/annotations/ inside the library; questions and attachment lists are also in .pdfdesk/.
  • Local-first: Sessions are saved locally by DSH. No telemetry is collected, no account is required, and the library is never uploaded. Page text / images are sent to your configured model only when you actively initiate Q&A, translation, or overlay.
  • Migration packages do not contain book PDFs, API Keys, or credentials.

Settings & Environment

The settings page is divided into Reading / Modes / Shortcuts / Environment / Data / AI Model / About:

  • Reading: Page width, right-side preview, hand-drawn intensity, handwriting font, page bitmap cache (2/3/5/8 pages).
  • Data: Data location, storage usage & retention cleanup, duplicate PDF report, three package types & package log, import wizard, translation cache clearing.
  • AI Model: Thinking mode, style prompts, and models for translation / session / other tasks.
  • Environment: Python, Typst / TeX, API Key status & install entry points. Missing packages trigger a copy-paste-ready py -m pip install … command instead of a raw traceback.

Environment Components

Component Purpose Required
DSH Host; version requirement see engines.dsh in package.json Yes
Python 3 + PyMuPDF + Pillow Split thumbnails, full-chapter translation, text extraction, export Needed for splitting / translation; not needed for reading only
Typst Default typesetting engine, one-click download in settings Recommended; TeX as fallback
TeX Live (xelatex + ctex) Fallback when Typst is absent Optional
PowerPoint or LibreOffice PPT → PDF Optional

Install Python packages:

py -m pip install pymupdf pillow

Update & Uninstall

  • Update: Click update in the plugin marketplace, or re-run dsh plugin add dsh-pdf-workbench, then restart DSH. The library, annotations, translation cache, and settings all live outside the plugin directory—updates won’t lose data.
  • Uninstall: Remove via DSH’s plugin manager and restart. The library and plugin data directories are not auto-deleted; manually remove them after confirming you no longer need them.

FAQ

Is it suitable for daily use? The author uses it daily with no blocking bugs; interaction polish is still ongoing.

Are bilingual view and overlay reliable? Both work well. The bilingual comparison is stable; the overlay uses a text layer + KaTeX + Typst, crisp at any zoom, and doesn’t require TeX Live.

Can a migration package serve as the sole backup? Same-machine packaging and import have been tested end-to-end. Cross-machine recovery has not yet been verified. Migration packages don’t include book PDFs—when switching machines, take 分片/ and 整本/ along, and keep an extra copy of important data.

Does it support scanned PDFs? You can open, page through, zoom, annotate, and box-select, but the plugin does not perform OCR. Text selection, translation, and Q&A quality depend on whether the model can read the page image directly.

Can it auto-split books? It does not recognize chapters. A page-based splitting tool is provided (4-page-per-row thumbnails + vertical dashed-line scissors) along with naming conventions. Manual splitting following the table of contents is recommended.

Why is the full-book session expensive? The entire book enters context at once—only suitable for small files or papers. Chapter-based splitting offers better cost and positioning.

Translation button not responding? Check Python and API Key in Settings → Environment. Missing components trigger a dialog with instructions and an install link.

Can it work without Typst? Yes, it falls back to TeX Live’s xelatex. If neither is available, a clear message is shown—no silent failure.

Does it sync to the cloud? No. No telemetry, no account required, library and sessions stay local.

Known Limitations

  • Only adapted and tested on Windows 10 / 11 (x64); macOS / Linux are not supported. Path separators and Python / TeX detection are written for Windows.
  • Split sessions and post-split dialogs depend on DSH host session APIs; host behavior changes may require corresponding updates.
  • Split thumbnail cache is stored locally by “path + size + mtime” with no automatic cleanup. After deleting a book, old cache directories remain; clean rebuildable caches in Settings → Data.
  • If an index-driven library has a split book not yet written to 索引.json, auto-adding to a bookshelf won’t find the target—a refresh or index rebuild is needed.

Development & Feedback

  • Design, data layout, module structure: docs/
  • Version changes: CHANGELOG.md
  • Installation & distribution: 安装与分发.md
  • Page screenshots: assets/screenshot-*.jpg (1600 px wide, light theme, no local paths); display order see screenshots.json
  • Feedback: GitHub Issues, or the feedback entry in the plugin’s “Settings → About” (auto-includes version and system info, no local paths)
  • This plugin is a reading, splitting, and translation tool: it does not provide, embed, or distribute any e-book content, nor does it offer book downloading, DRM cracking, or license bypassing.
  • PDFs you import, split, and translate must be files you have the right to process (own, purchased, public domain, or licensed). Comply with the copyright laws in your jurisdiction.
  • Results of splitting, translation, export, and overlay are for personal study and research only. Do not distribute, publish, or use them commercially.
  • PDFs are processed locally only; only full-chapter translation and Q&A send page content you actively initiate to your own configured AI model.
  • Plugin code is released under the MIT license. If a rights holder believes the usage instructions or example content infringe their rights, please contact us via a repository Issue.

License & Acknowledgments

  • Plugin code: MIT
  • pdf.js: Apache-2.0
  • KaTeX: MIT (formula rendering in the overlay text layer)
  • Typst: Apache-2.0 (default typesetting engine, downloaded on demand, not bundled)
  • PyMuPDF / Pillow: AGPL-3.0 / HPND (local thumbnails and translation utilities)
  • rough.js: MIT (hand-drawn shapes)
  • Excalifont: SIL OFL 1.1 (Latin handwriting)
  • Xiaolai (小赖字体): SIL OFL 1.1 (Chinese handwriting)

Font and third-party license files are bundled under vendor/.

羽毛球分组比赛记分
小程序二维码

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

Xiaoye