📄

图片转Word

👤 程晨 📦 v1.0.0 ⭐ 4.0 ⬇️ 403 下载
📄 办公效率 免费

📖 技能介绍


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


Image to DOCX

Overview

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.

Workflow

Step 1: Read and Analyze the Image

Read the image file using the Read tool to understand its content, layout, and structure. Identify:

  • Title and headings
  • Body text and paragraphs
  • Tables or form fields
  • Signature/date areas
  • Any fill-in-the-blank fields (underlines)
  • Alignment and formatting cues

Step 2: Set Up the docx-js Environment

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

Step 3: Write the Generation Script

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 }
})

Step 4: Run the Script and Generate DOCX

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.

Step 5: Present the Result

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.

Notes

  • The docx-js default page size is A4, not US Letter. Set explicitly for consistency.
  • For Chinese documents, 仿宋 at 24 half-points (12pt) is standard for body text.
  • Underlines for blanks use full-width spaces ( ) to maintain proper visual width.
  • All file paths in scripts should use absolute paths to avoid cwd issues.
  • Clean up temp scripts only after user confirms satisfaction with the output.

🤖 AI 评测

这个 Skill 能将图片中的文字内容转成可编辑的 Word 文档,文档说明详细、步骤清晰,对中文排版有专门优化。但它依赖特定的系统路径配置,说明不够通俗;缺少常见问题解答和示例参考,出了问题不容易排查。总体而言功能实用,但配置和使用上对普通用户不太友好,需要一定耐心才能用好。

📊 多维度评分

适应性3.8
规范性4.1
有效性3.8
可靠性3.8
可信度5

📁 包含文件 (1 个)

📄 SKILL.md 3.9 KB

🔥 大家都在搜

wps 写作 pdf 苹果