📄

圖片轉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

推薦訪問7w4.net獲取更多AI技能。

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