Preface¶
The DSH plugin ecosystem separates different capabilities into installable, loadable modules. dsh-pdf-edit is a community plugin for PDF documents within this ecosystem: it uses AI to modify PDF text while preserving typographic styles such as font, size, color, and position.
It is suitable for terminology unification, typo correction, batch replacement in contracts/reports, and scenarios where Markdown/notes need to be inserted as new pages after a specified page. The DSH community directory is an independent site with no official affiliation to DeepSeek / High-Flyer.
What This Is¶
dsh-pdf-edit is a DeepSeek Harness plugin, maintained by Whatsmore-nf, licensed under MIT.
It solves the problem of modifying text in PDFs without altering typographic styles such as font, size, color, and position.
Core Features¶
- AI only modifies PDF text, without changing typographic styles such as font, size, color, and position.
- When new text is longer than the original, it automatically reduces font size or truncates to avoid overflowing the layout.
- Automatically detects and embeds system Chinese fonts: SimHei, Microsoft YaHei, Noto Sans CJK.
- Supports scenarios such as terminology unification, typo correction, batch replacement in contracts/reports.
- Supports reformatting PDFs into layouts such as academic paper double-column, mobile-reading single-column, and business briefs.
- Supports inserting Markdown/notes as new pages after a specified page, without requiring an LLM.
- Provides a dsh-std Community v0.15 static manifest and standard FacetModule entry, while retaining a cordis direct connection entry.
- Provides programming interfaces, including methods such as
StyleLockedEditor,previewPage,editDocument,getExtract,openNativeDoc,drawPatchedPages,insertPages,parseMarkdownBlocks, andremoveSubheadings. - Supports configuration options such as path whitelist, browser rendering mode, model routing, patch color, tid strict mode, and overflow mode.
Installation and Enablement¶
The following command installs the plugin in the DSH web profile:
dsh plugin --profile web add dsh-pdf-edit@latest
It can also be installed directly via npm:
npm install dsh-pdf-edit
If the host supports dsh-std and you plan to load it within the standard ecosystem, first install the adapter, then the plugin:
dsh plugin --profile web add @dsh-std/adapter-dsh
dsh plugin --profile web add dsh-pdf-edit
After installation, the plugin is loaded by the DSH host; tool calls remain restricted by the allowedRoots path whitelist.
Typical Usage¶
chatFn is used for the LLM call path, and original represents the PDF byte data to be processed. The following examples demonstrate the core interfaces.
Opening a Document and Previewing Editable Units¶
First open the document, then preview the editable units on page 1 and obtain the tid list:
const editor = await StyleLockedEditor.open(original, chatFn, {
allowedRoots: ['/workspace']
});
const units = await editor.previewPage(1);
Executing Full-Text AI Modification¶
Let AI modify the full text according to instructions:
const result = await editor.editDocument('Fix typos and unify terminology');
Manually Deleting Specified Text¶
When AI returns empty text, sanitizeText rejects empty strings and falls back to the original text according to the missingTidsUseOriginal configuration. To manually delete specified text, first retrieve the extract, then modify the target unit:
const extract = await editor.getExtract(1);
// Execute on the target unit: unit.text = ''
const { doc, resolver } = await editor.openNativeDoc();
await editor.drawPatchedPages(doc, resolver, [/* Modified units for the corresponding page */]);
Deleting Matching Subheading Text¶
Delete matching subheading text:
await removeSubheadings(
'doc.pdf',
'doc-deleted.pdf',
['Chapter 1 Subheading', 'Appendix A'],
chatFn
);
Inserting Content as New Pages¶
Insert title, text blocks, formulas, and other content as new pages after a specified page in the original PDF. This pipeline does not require an LLM:
await insertPages(
original,
[
{
afterPage: 14,
title: 'Supplement One',
blocks: parseMarkdownBlocks(mdText)
}
]
);
Applicable Scenarios and Notes¶
- Suitable for PDF workflows that require preserving the original layout while only modifying text.
- Suitable for scenarios such as terminology unification, typo correction, and batch replacement in contracts/reports.
- Requires
Node >= 22. - Compatible with
dsh >= 0.1.1-rc.2via cordis direct connection, and supports dsh-std Community v0.15 hosts. - The dsh-std manifest does not declare required contracts or permissions, and is compatible by negotiation with any std host.
- The std protocol currently does not expose the host LLM inference channel to plugins. Therefore, under std hosts, AI refinement requires direct connection using a DeepSeek API Key.
- Tool calls are restricted by the
allowedRootspath whitelist; files that do not exist or are outside the allowed directories will fail. sanitizeTextrejects empty strings. When AI returns empty text, it is rejected and the original text is filled back according to themissingTidsUseOriginalconfiguration.- This project has announced a suspension of maintenance for an extended period, during which no updates will be made. The resumption of maintenance is to be determined.
- The plugin runs with the current DSH process permissions. Before installation, review the source code and license. The license is MIT.
References¶
- Directory page:
https://www.skillhub.cn/plugins/Whatsmore-nf/dsh-pdf-edit - GitHub:
https://github.com/Whatsmore-nf/dsh-pdf-edit