Reads PDF files and extracts text content in Markdown format. Handles tables and multi-page documents. Use when needing to read PDF documents. Requires pdfplumber package.
PDF ファイルをテキスト抽出して Markdown 形式に変換するスキルです。
# WSL環境でPythonスクリプトを実行
wsl python3 scripts/read_pdf.py "/mnt/c/path/to/file.pdf"
pdfplumber パッケージが必要です:
wsl pip3 install pdfplumber
User: "C:\Users\keita\repos\guideline.pdf を読み込んで"
Assistant:
1. Windowsパスを WSL パスに変換: /mnt/c/Users/keita/repos/guideline.pdf
2. wsl python3 scripts/read_pdf.py を実行
3. 抽出されたテキストを Markdown 形式で表示
User: "ガイドライン.pdf を Markdown に変換して保存"
Assistant:
1. scripts/read_pdf.py でテキスト抽出
2. Markdown形式で構造化(ページごとに見出し、テーブルも含む)
3. Write ツールで ガイドライン.md に保存
4. 保存完了を報告
C:\ → /mnt/c/)wsl python3 scripts/read_pdf.py を実行# [PDFファイル名]
**Total Pages:** 10
---
## Page 1
[ページ1のテキスト内容]
### Tables
**Table 1:**
| 列1 | 列2 | 列3 |
| --- | --- | --- |
| データ1 | データ2 | データ3 |
---
## Page 2
[ページ2のテキスト内容]
---
Python スクリプトは scripts/read_pdf.py に配置されています。
主な機能:
使い方:
python scripts/read_pdf.py <file_path>
wsl pip3 install pdfplumber
# 日本語対応の確認
wsl locale
# UTF-8 が含まれていることを確認
大きな PDF ファイルの場合、ページごとに分割して処理することを検討してください。
Windows パスから WSL パスへの変換:
C:\Users\... → /mnt/c/Users/...D:\Projects\... → /mnt/d/Projects/...\ をスラッシュ / に変換スクリプトを修正して pdf.pages[0:5] のようにスライスを使用できます。
スクリプト内の extract_tables() 部分のみを使用します。
pytesseract と pdf2image を組み合わせて使用します(別スキルとして作成推奨)。
Edit PDFs with natural-language instructions using the nano-pdf CLI.