Description
Use multiple methods to read PDF files and convert them into structured text, supporting local files and web URLs.
Trigger Conditions
- "Read PDF" "open this paper" "look at this file"
- "read PDF", "open paper", "extract from PDF"
- Provide a PDF file path or URL
Available Tools
MCP Tools (microsoft-mar)
| Tool | Purpose | Parameters |
|---|---|---|
convert_to_markdown |
Convert PDF to Markdown | uri (file:// or http://) |
MCP Tools (pubmed-search)
| Tool | Purpose | Parameters |
|---|---|---|
get_article_fulltext_links |
Get full-text link | pmid |
Python Scripts (optional)
# scripts/pdf_utils.py
import fitz # PyMuPDF
def extract_text(pdf_path: str) -> str:
"""提取 PDF 文字"""
doc = fitz.open(pdf_path)
text = ""
for page in doc:
text += page.get_text()
return text
def extract_images(pdf_path: str, output_dir: str) -> list:
"""提取 PDF 圖片"""
# ...實作
pass
def extract_references(pdf_path: str) -> list:
"""提取參考文獻"""
# ...實作
pass
Execution Flow
1. Local PDF reading
用戶提供本地路徑: C:\papers\article.pdf
↓
convert_to_markdown(uri="file:///C:/papers/article.pdf")
↓
返回 Markdown 格式文字
2. Web PDF reading
用戶提供 URL 或 PMID
↓
(如果是 PMID) get_article_fulltext_links(pmid)
↓
取得 PDF URL
↓
convert_to_markdown(uri="https://...")
↓
返回 Markdown 格式文字
3. Batch processing mode
# 處理多個 PDF
pdf_files = [
"C:/papers/paper1.pdf",
"C:/papers/paper2.pdf",
"C:/papers/paper3.pdf"
]
for pdf in pdf_files:
content = convert_to_markdown(uri=f"file:///{pdf}")
save_to_notes(content, pdf)
# Checkpoint: 記錄處理進度
update_checkpoint(processed=pdf)
Output Format
## PDF 讀取結果
**檔案**: article.pdf
**頁數**: 12
**處理時間**: 3.2s
---
### 提取內容
# [論文標題]
## Abstract
[摘要內容...]
## Introduction
[介紹內容...]
## Methods
[方法內容...]
## Results
[結果內容...]
## Discussion
[討論內容...]
## References
1. Author et al. (2024). Title...
2. ...
---
### 圖表清單
| 圖表 | 頁碼 | 說明 |
|------|------|------|
| Figure 1 | p.3 | Study flowchart |
| Table 1 | p.5 | Baseline characteristics |
Usage Examples
Example 1: Local PDF
用戶:「讀取 C:\papers\remimazolam-study.pdf」
執行:convert_to_markdown(uri="file:///C:/papers/remimazolam-study.pdf")
Example 2: Get PDF from PMID
用戶:「讀取 PMID 38353755 的全文」
執行:
1. get_article_fulltext_links(pmid="38353755")
2. convert_to_markdown(uri=pmc_url)
Example 3: Batch reading
用戶:「讀取 papers/ 資料夾中的所有 PDF」
執行:
1. 列出資料夾中的 PDF 檔案
2. 迴圈處理每個檔案
3. 建立 Checkpoint 追蹤進度
Error Handling
| Error | Handling Method |
|---|---|
| PDF encrypted | Prompt the user to provide a password or use another version |
| Image PDF (scanned) | Prompt that OCR is required; recommend using other tools |
| Network error | Retry 3 times; if it fails, prompt the user to download |
Related Skills
note-writer- Writing notesreport-writing- Combined skill: read + write