name: image-to-docx displayName: 图片转Word description: | Convert scanned images, screenshots, or photos of forms, documents, and text-heavy content into editable Word (.docx) files. This skill should be used when the user provides an image containing text content and asks to turn it into a Word document, or says things like "把图片搞成 word 文字版", "convert image to docx", "extract text from image to Word", or similar. slug: image-to-docx version: 1.0.0 agent_created: true
Convert images containing text and forms into properly formatted Word documents. Read the image to extract its content, then generate a .docx file using the docx-js library. Common use cases include scanned government forms, meeting minutes photos, receipts, signage, or any text-heavy image that needs to become an editable document.
Read the image file using the Read tool to understand its content, layout, and structure. Identify:
The isolated Node.js environment is at C:\Users\86150\.workbuddy\binaries\node\. The docx package must be installed in the workspace:
# Ensure workspace directory exists
mkdir -p /c/Users/86150/.workbuddy/binaries/node/workspace
# Install docx if not present
cd /c/Users/86150/.workbuddy/binaries/node/workspace && npm install docx
To verify installation:
ls /c/Users/86150/.workbuddy/binaries/node/workspace/node_modules/docx/package.json
Create a JavaScript file using the docx-js API. Use C:\Users\86150\.workbuddy\binaries\node\versions\22.22.2\node.exe as the Node runtime.
Useful patterns:
A4 page settings:
page: {
size: { width: 11906, height: 16838 }, // A4 in DXA
margin: { top: 1440, right: 1440, bottom: 1440, left: 1800 }
}
Chinese font (仿宋):
const font = "仿宋";
const t = (text, bold = false, size = 24) => new TextRun({
text, bold, size, font
});
Underline for fill-in blanks:
const u = (text) => new TextRun({
text,
font: "仿宋",
size: 24,
underline: { type: UnderlineType.SINGLE }
});
Centered title:
new Paragraph({
alignment: AlignmentType.CENTER,
children: [new TextRun({ text: "Title", bold: true, size: 28, font: "仿宋" })],
spacing: { after: 400 }
})
Body paragraph (Chinese indentation):
new Paragraph({
children: [new TextRun({
text: " 这是一个开头缩进的正文段落。",
font: "仿宋", size: 24
})],
spacing: { after: 200 }
})
Execute the script by setting NODE_PATH to the workspace node_modules:
NODE_PATH="C:\\Users\\86150\\.workbuddy\\binaries\\node\\workspace\\node_modules" \
/c/Users/86150/.workbuddy/binaries/node/versions/22.22.2/node.exe \
"<script-path>" 2>&1
The script should write the .docx to the current workspace directory and print "Done" on success.
After generation succeeds, call present_files with the .docx file path. Keep the temp script file for reference but always present the final .docx to the user.
这个 Skill 能将图片中的文字内容转成可编辑的 Word 文档,文档说明详细、步骤清晰,对中文排版有专门优化。但它依赖特定的系统路径配置,说明不够通俗;缺少常见问题解答和示例参考,出了问题不容易排查。总体而言功能实用,但配置和使用上对普通用户不太友好,需要一定耐心才能用好。