mcpField
W
working-with-documents

working-with-documents

github.com/mjunaidcaドキュメント2878 回インストール11 週間前に更新
リポジトリ

working-with-documents について

working-with-documents は、DOCX、PDF、PPTX の読み取り、作成、編集、変換を扱うスキルです。コマンドラインツールやコード例に加え、プレゼンテーションの設計と検証方法もまとめています。

主な機能

  1. 01DOCX、PDF、PPTX に対応
  2. 02文書の読み取りと作成方法
  3. 03OOXML による編集手順
  4. 04PDF の結合と分割の案内
  5. 05形式変換とスキャン文書の OCR
  6. 06スライドのレイアウトと検証方法

活用シーン

  1. 01DOCX の内容を Markdown に変換
  2. 02PDF からテキストや表を抽出
  3. 03文書の結合、分割、形式変換
  4. 04プレゼンテーションの作成と確認

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/mjunaidca/mjs-agent-skills --skill working-with-documents

インストール後、Claude Code で/working-with-documentsを入力して読み込まれたか確認します。

同梱ファイルscripts/verify.py

詳細

ドキュメントの操作

クイックリファレンス

形式読み取り作成編集
DOCXpandoc, python-docxdocx-jsOOXML (unpack/edit/pack)
PDFpdfplumber, pypdfreportlabpypdf (merge/split)
PPTXmarkitdownhtml2pptxOOXML (unpack/edit/pack)

Word ドキュメント (.docx)

コンテンツの読み取り
# Convert to markdown (preserves structure)
pandoc document.docx -o output.md

# With tracked changes visible
pandoc --track-changes=all document.docx -o output.md
新しいドキュメントの作成

docx-js (JavaScript) を使用します:

const { Document, Packer, Paragraph, TextRun } = require('docx');

const doc = new Document({
  sections: [{
    children: [
      new Paragraph({
        children: [
          new TextRun({ text: "Hello World", bold: true }),
        ],
      }),
    ],
  }],
});

Packer.toBuffer(doc).then(buffer => {
  fs.writeFileSync("output.docx", buffer);
});
既存のドキュメントの編集 (変更履歴)
# 1. Unpack
python ooxml/scripts/unpack.py document.docx unpacked/

# 2. Edit XML files in unpacked/word/document.xml
# Key files:
#   - word/document.xml (main content)
#   - word/comments.xml (comments)
#   - word/media/ (images)

# 3. Pack
python ooxml/scripts/pack.py unpacked/ edited.docx

変更履歴の XML パターン:


<w:del><w:r><w:delText>old text</w:delText></w:r></w:del>


<w:ins><w:r><w:t>new text</w:t></w:r></w:ins>

PDF ドキュメント

PDF の読み取り
import pdfplumber

# Extract text
with pdfplumber.open("document.pdf") as pdf:
    for page in pdf.pages:
        print(page.extract_text())

# Extract tables
with pdfplumber.open("document.pdf") as pdf:
    for page in pdf.pages:
        tables = page.extract_tables()
        for table in tables:
            for row in table:
                print(row)
PDF の作成
from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Paragraph
from reportlab.lib.styles import getSampleStyleSheet

doc = SimpleDocTemplate("output.pdf", pagesize=letter)
styles = getSampleStyleSheet()
story = [
    Paragraph("Report Title", styles['Title']),
    Paragraph("Body text goes here.", styles['Normal']),
]
doc.build(story)
PDF の結合/分割
from pypdf import PdfReader, PdfWriter

# Merge
writer = PdfWriter()
for pdf_file in ["doc1.pdf", "doc2.pdf"]:
    reader = PdfReader(pdf_file)
    for page in reader.pages:
        writer.add_page(page)
writer.write(open("merged.pdf", "wb"))

# Split
reader = PdfReader("input.pdf")
for i, page in enumerate(reader.pages):
    writer = PdfWriter()
    writer.add_page(page)
    writer.write(open(f"page_{i+1}.pdf", "wb"))
コマンドラインツール
# Extract text
pdftotext input.pdf output.txt
pdftotext -layout input.pdf output.txt  # Preserve layout

# Merge with qpdf
qpdf --empty --pages file1.pdf file2.pdf -- merged.pdf

# Split pages
qpdf input.pdf --pages . 1-5 -- pages1-5.pdf

PowerPoint プレゼンテーション (.pptx)

コンテンツの読み取り
# Convert to markdown
python -m markitdown presentation.pptx
新しいプレゼンテーションの作成

html2pptx ワークフローを使用します:

  1. HTML スライドを作成します (16:9 の場合は 720pt × 405pt)
  2. html2pptx.js ライブラリで変換します
  3. サムネイルグリッドで検証します
# Create thumbnails for validation
python scripts/thumbnail.py output.pptx --cols 4
既存のプレゼンテーションの編集
# 1. Unpack
python ooxml/scripts/unpack.py presentation.pptx unpacked/

# Key files:
#   - ppt/slides/slide1.xml, slide2.xml, etc.
#   - ppt/notesSlides/ (speaker notes)
#   - ppt/media/ (images)

# 2. Edit XML

# 3. Validate
python ooxml/scripts/validate.py unpacked/ --original presentation.pptx

# 4. Pack
python ooxml/scripts/pack.py unpacked/ edited.pptx
スライドの並べ替え
# Duplicate, reorder, delete slides
python scripts/rearrange.py template.pptx output.pptx 0,3,3,5,7
# Creates: slide 0, slide 3 (twice), slide 5, slide 7

形式間の変換

# DOCX/PPTX to PDF
soffice --headless --convert-to pdf document.docx

# PDF to images
pdftoppm -jpeg -r 150 document.pdf page
# Creates: page-1.jpg, page-2.jpg, etc.

# DOCX to Markdown
pandoc document.docx -o output.md

スキャンされたドキュメントの OCR

import pytesseract
from pdf2image import convert_from_path

images = convert_from_path('scanned.pdf')
text = ""
for image in images:
    text += pytesseract.image_to_string(image)

デザインガイドライン (プレゼンテーション)

カラーパレット

互いに調和する 3〜5 色を選びます:

パレット色
クラシックブルーネイビー #1C2833、スレート #2E4053、シルバー #AAB7B8
ティール & コーラルティール #5EA8A7、コーラル #FE4447、ホワイト #FFFFFF
ブラック & ゴールドゴールド #BF9A4A、ブラック #000000、クリーム #F4F6F6
Web セーフフォントのみ

Arial、Helvetica、Times New Roman、Georgia、Verdana、Tahoma、Trebuchet MS、Courier New、Impact

レイアウトのルール
  • 2 カラム: 明確に異なる 2 つの項目に使用します
  • 3 カラム: 3 つの項目に使用します
  • テキストの下にグラフを縦に積み重ねないでください
  • テキストオーバーレイ付きの全幅画像は効果的です

依存関係

# Python
pip install pypdf pdfplumber reportlab python-docx openpyxl

# System tools
apt-get install pandoc poppler-utils libreoffice

# Node.js (for docx-js)
npm install docx

検証

実行: python scripts/verify.py

関連スキル

  • working-with-spreadsheets - Excel ファイルの操作
  • building-nextjs-apps - ドキュメントアップロード用のフロントエンド

コメント