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
推薦訪問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.
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 文件,文件說明詳細、步驟清晰,對中文排版有專門最佳化。但它依賴特定的系統路徑配置,說明不夠通俗;缺少常見問題解答和示例參考,出了問題不容易排查。總體而言功能實用,但配置和使用上對普通使用者不太友好,需要一定耐心才能用好。