Communitygithub.com

PDF 文字擷取

從數位 PDF 中提取文字與簡易表格,無需 OCR 二進位檔案。當使用者要求讀取 PDF、將 PDF 轉為文字、從報表中提取簡單表格,或將 PDF 內容餵入 LLM 流程時使用。

PDF 文字擷取 是什麼?

此技能專為 AI 代理工作流程設計,能從數位 PDF 中提取機器可讀文字,並以頁為單位保留頁碼邊界,方便下游進行摘要、分類或結構化提取。它支援純 Python 的 PDF 函式庫(如 pypdf 或 pdfminer.six),並包含一個基於行的簡易表格偵測器,能將表格行按定位點或重複空格分割,以便後續正規化。此技能特別適合用於 Claude Code、Coder、Gemini 等平台,當使用者明確要求「提取 PDF 文字」、「將 PDF 餵給 AI」或「拉出報表中的表格」時自動觸發。它會在無法提取文字時明確報錯,避免對 LLM 送出空提示,同時支援根據頁數/範圍限制文字長度,確保大型 PDF 也能順利處理。

相容平台~Claude Code~Codex CLI~Cursor✓Gemini CLI
npx skills add https://github.com/baronguyen001/ai-automation-skills/tree/HEAD/skills/pdf-text-extract

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

PDF 文字擷取 是做什麼的?

當工作流程需要在進行摘要、分類或結構化提取前,從數位 PDF 取得機器可讀文字時,請使用此技能。輔助程式優先使用純 Python PDF 函式庫,並包含一個基於行的簡易表格偵測器,方便後續清理。

何時觸發

  • 使用者說:「從這個 PDF 提取文字」、「餵 PDF 給 AI」、「從這份報告中拉出表格」、「讀取這份聲明」。
  • PDF 已包含可選取文字,且不需要 OCR。

何時不應觸發

  • PDF 為掃描影像;請改用 OCR 工作流程。
  • 使用者需要完美還原合併儲存格與版面保真度的像素級表格。

具體範例

使用者輸入:

請從這個 PDF 提取文字和粗略表格,好讓 Gemini 可以摘要它。

輸出:

# 將 assets/extract.py 複製到你的專案中,然後:
from extract import extract_pdf

doc = extract_pdf("downloads/report.pdf")
print(doc["text"][:2000])
for table in doc["tables"]:
    print(table["page"], table["rows"][:3])

在目標專案中安裝 pypdf 或 pdfminer.six。不需要 OCR 二進位檔案,且當 PDF 沒有可提取文字時,輔助程式會明確報錯。

套用模式

  1. 優先嘗試數位文字提取;除非來源是掃描檔案,否則不要添加 OCR。
  2. 保留頁面邊界,以便下游提示可以引用頁碼。
  3. 保持表格提取簡單:按定位點或重複空格分割行,然後讓後續的綱要傳遞正規化欄位。
  4. 當 PDF 很長時,按頁面/範圍限制傳送給 LLM 的文字量。
  5. 找不到文字時應明確報錯,而不是向下游送出空提示。

參考資料:assets/extract.py。

來源

從作者自動化專案的實際使用經驗中提煉而成。v1.0.0。 另請參閱:[[gemini-structured-output]]、[[csv-report-writer]]、[[s3-uploader]]。

→ 使用 Trawlkit 建立完整可執行的機器人。

Individual skills in this repo

This repo contains 9 individual skills — each has its own dedicated page.

baronguyen001/ai-automation-skills

Schedule any script to run on a recurring schedule on Windows (Task Scheduler) or Linux (cron) - register, list, and remove jobs from one command, with logging to a file and a guard against overlapping runs. Use for schedule a script, run nightly, set up a cron job, windows task scheduler, or run on a timer.

baronguyen001/ai-automation-skills

Turn a run's list of result dicts into a schema'd CSV and a Markdown table from one column spec - declare columns once, emit both, with stable ordering and safe escaping, stdlib only, no pandas. Use when the user asks to write results to CSV, export a report, make a markdown summary table, or save a run's output as a spreadsheet.

baronguyen001/ai-automation-skills

Strip HTML to clean plain text with the standard library only (no BeautifulSoup/lxml): drops script/style, turns block tags into line breaks, and collapses whitespace. Use when the user wants readable text from an HTML page/email, to clean scraped HTML before sending it to an LLM, or to build a text index from web content.

baronguyen001/ai-automation-skills

Persist records between scheduled runs as append-only JSON Lines (one object per line) with streaming reads and optional key-based dedup, stdlib only. Use when the user wants to log run results to JSONL, append events to a file, dedup records by id across runs, or keep a simple durable history without a database.

baronguyen001/ai-automation-skills

Rotate a pool of HTTP/SOCKS proxies with round-robin selection, failure tracking, and a cooldown that benches dead proxies before retrying. BYO proxy list via env - none are shipped. Use for rotate proxies, spread requests across proxies, avoid IP bans, retry through a different proxy, or proxy health check.

baronguyen001/ai-automation-skills

Parse an RSS 2.0 or Atom feed into normalized item dicts (title, link, id, published, summary) with the standard library only - no feedparser. Use when the user asks to read an RSS/Atom feed, poll a blog/news feed, extract feed entries, or watch a site that publishes a feed.

baronguyen001/ai-automation-skills

Upload and download run artifacts from S3-compatible storage with BYO bucket and credentials from env. Use when the user asks to store scraper output, archive reports, publish artifacts to object storage, fetch a prior run file, or use MinIO/R2/Spaces/S3 without hardcoding credentials.

baronguyen001/ai-automation-skills

Draft a short-form TikTok/Reels/Shorts or long-form video script from a topic and creator persona file - hook variants, beat-structured body, CTA, b-roll cues, caption overlays, and [STORY]/[NUMBER] slots so the model never fabricates personal facts. Use for write a video script, tiktok script, youtube script, or /shortform-script.

baronguyen001/ai-automation-skills

Give scheduled scripts memory between runs with one SQLite file - a seen-set for dedup, a key/value cursor to resume where you left off, and order-preserving new-item filtering. Use for dedup across runs, don't re-alert the same item, remember the last id, resume a scraper, or persist state between cron runs.

相關技能