Communitygithub.com

LiChangZheng10086/doyin_ai_video

ユーザーがPDFファイルに関して何かしたいときに使用するスキルです。PDFからのテキスト/表の読み取りや抽出、複数PDFの結合、分割、ページ回転、透かし追加、新しいPDFの作成、フォーム入力、暗号化/復号化、画像抽出、スキャンPDFのOCRによる検索可能化などに対応します。

doyin_ai_video とは?

このスキルは、PDFファイルに関するあらゆる操作を包括的にサポートするためのガイドです。pypdf、pdfplumber、reportlabといった主要なPythonライブラリを使用した、テキスト抽出、結合、分割、回転、透かし追加、パスワード保護、OCRなどの基本的な処理から、qpdfやpdftotextなどのコマンドラインツールを使った高速な処理までをカバーします。ユーザーが「PDFを編集したい」「特定のページだけ抽出したい」「スキャンされたPDFをテキスト化したい」といったリクエストをした場合、このスキルが自動的に選択され、最適な方法と実装例を提供します。また、フォーム入力や高度な機能については、別途REFERENCE.mdやFORMS.mdを参照するよう指示するため、初心者から上級者まで幅広いニーズに対応できる設計になっています。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/LiChangZheng10086/doyin_ai_video/tree/HEAD/.agents/skills/pdf

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

PDF 処理ガイド

概要

このガイドは、Python ライブラリとコマンドラインツールを使用した、基本的な PDF 処理操作について説明します。高度な機能、JavaScript ライブラリ、および詳細な例については、REFERENCE.md を参照してください。PDF フォームに入力する必要がある場合は、FORMS.md を読み、その指示に従ってください。

クイックスタート

from pypdf import PdfReader, PdfWriter

# PDF を読む
reader = PdfReader("document.pdf")
print(f"ページ数: {len(reader.pages)}")

# テキストを抽出
text = ""
for page in reader.pages:
    text += page.extract_text()

Python ライブラリ

pypdf - 基本操作

PDF の結合

from pypdf import PdfWriter, PdfReader

writer = PdfWriter()
for pdf_file in ["doc1.pdf", "doc2.pdf", "doc3.pdf"]:
    reader = PdfReader(pdf_file)
    for page in reader.pages:
        writer.add_page(page)

with open("merged.pdf", "wb") as output:
    writer.write(output)

PDF の分割

reader = PdfReader("input.pdf")
for i, page in enumerate(reader.pages):
    writer = PdfWriter()
    writer.add_page(page)
    with open(f"page_{i+1}.pdf", "wb") as output:
        writer.write(output)

メタデータの抽出

reader = PdfReader("document.pdf")
meta = reader.metadata
print(f"タイトル: {meta.title}")
print(f"作成者: {meta.author}")
print(f"件名: {meta.subject}")
print(f"作成プログラム: {meta.creator}")

ページの回転

reader = PdfReader("input.pdf")
writer = PdfWriter()

page = reader.pages[0]
page.rotate(90)  # 時計回りに90度回転
writer.add_page(page)

with open("rotated.pdf", "wb") as output:
    writer.write(output)

pdfplumber - テキストと表の抽出

レイアウトを保持したテキスト抽出

import pdfplumber

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

表の抽出

with pdfplumber.open("document.pdf") as pdf:
    for i, page in enumerate(pdf.pages):
        tables = page.extract_tables()
        for j, table in enumerate(tables):
            print(f"ページ {i+1} の表 {j+1}:")
            for row in table:
                print(row)

高度な表抽出

import pandas as pd

with pdfplumber.open("document.pdf") as pdf:
    all_tables = []
    for page in pdf.pages:
        tables = page.extract_tables()
        for table in tables:
            if table:  # 表が空でないかを確認
                df = pd.DataFrame(table[1:], columns=table[0])
                all_tables.append(df)

# すべての表を結合
if all_tables:
    combined_df = pd.concat(all_tables, ignore_index=True)
    combined_df.to_excel("extracted_tables.xlsx", index=False)

reportlab - PDF 作成

基本的な PDF 作成

from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas

c = canvas.Canvas("hello.pdf", pagesize=letter)
width, height = letter

# テキストを追加
c.drawString(100, height - 100, "Hello World!")
c.drawString(100, height - 120, "This is a PDF created with reportlab")

# 線を追加
c.line(100, height - 140, 400, height - 140)

# 保存
c.save()

複数ページの PDF 作成

from reportlab.lib.pagesizes import letter
from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, PageBreak
from reportlab.lib.styles import getSampleStyleSheet

doc = SimpleDocTemplate("report.pdf", pagesize=letter)
styles = getSampleStyleSheet()
story = []

# コンテンツを追加
title = Paragraph("レポートタイトル", styles['Title'])
story.append(title)
story.append(Spacer(1, 12))

body = Paragraph("これはレポートの本文です。 " * 20, styles['Normal'])
story.append(body)
story.append(PageBreak())

# 2ページ目
story.append(Paragraph("2ページ目", styles['Heading1']))
story.append(Paragraph("2ページ目のコンテンツ", styles['Normal']))

# PDF を生成
doc.build(story)

下付き文字と上付き文字

重要: ReportLab の PDF では、Unicode の下付き/上付き文字 (₀₁₂₃₄₅₆₇₈₉、⁰¹²³⁴⁵⁶⁷⁸⁹) を使用しないでください。組み込みフォントにはこれらのグリフが含まれていないため、黒いボックスとしてレンダリングされます。

代わりに、Paragraph オブジェクトで ReportLab の XML マークアップタグを使用してください:

from reportlab.platypus import Paragraph
from reportlab.lib.styles import getSampleStyleSheet

styles = getSampleStyleSheet()

# 下付き文字: <sub> タグを使用
chemical = Paragraph("H<sub>2</sub>O", styles['Normal'])

# 上付き文字: <super> タグを使用
squared = Paragraph("x<super>2</super> + y<super>2</super>", styles['Normal'])

キャンバス描画テキスト (Paragraph オブジェクト以外) の場合は、Unicode の下付き/上付き文字を使用する代わりに、フォントサイズと位置を手動で調整してください。

コマンドラインツール

pdftotext (poppler-utils)

# テキストを抽出
pdftotext input.pdf output.txt

# レイアウトを保持してテキストを抽出
pdftotext -layout input.pdf output.txt

# 特定のページを抽出
pdftotext -f 1 -l 5 input.pdf output.txt  # 1-5ページ

qpdf

# PDF を結合
qpdf --empty --pages file1.pdf file2.pdf -- merged.pdf

# ページを分割
qpdf input.pdf --pages . 1-5 -- pages1-5.pdf
qpdf input.pdf --pages . 6-10 -- pages6-10.pdf

# ページを回転
qpdf input.pdf output.pdf --rotate=+90:1  # 1ページ目を90度回転

# パスワードを解除
qpdf --password=mypassword --decrypt encrypted.pdf decrypted.pdf

pdftk (利用可能な場合)

# 結合
pdftk file1.pdf file2.pdf cat output merged.pdf

# 分割
pdftk input.pdf burst

# 回転
pdftk input.pdf rotate 1east output rotated.pdf

一般的なタスク

スキャンされた PDF からテキストを抽出

# 必要条件: pip install pytesseract pdf2image
import pytesseract
from pdf2image import convert_from_path

# PDF を画像に変換
images = convert_from_path('scanned.pdf')

# 各ページを OCR
text = ""
for i, image in enumerate(images):
    text += f"ページ {i+1}:\n"
    text += pytesseract.image_to_string(image)
    text += "\n\n"

print(text)

透かしを追加

from pypdf import PdfReader, PdfWriter

# 透かしを作成(または既存のものを読み込む)
watermark = PdfReader("watermark.pdf").pages[0]

# すべてのページに適用
reader = PdfReader("document.pdf")
writer = PdfWriter()

for page in reader.pages:
    page.merge_page(watermark)
    writer.add_page(page)

with open("watermarked.pdf", "wb") as output:
    writer.write(output)

画像を抽出

# pdfimages (poppler-utils) を使用
pdfimages -j input.pdf output_prefix

# これにより、output_prefix-000.jpg、output_prefix-001.jpg のようにすべての画像が抽出されます

パスワード保護

from pypdf import PdfReader, PdfWriter

reader = PdfReader("input.pdf")
writer = PdfWriter()

for page in reader.pages:
    writer.add_page(page)

# パスワードを追加
writer.encrypt("userpassword", "ownerpassword")

with open("encrypted.pdf", "wb") as output:
    writer.write(output)

クイックリファレンス

タスク最適なツールコマンド/コード
PDF の結合pypdfwriter.add_page(page)
PDF の分割pypdfファイルごとに1ページ
テキスト抽出pdfplumberpage.extract_text()
表の抽出pdfplumberpage.extract_tables()
PDF の作成reportlabCanvas または Platypus
コマンドライン結合qpdfqpdf --empty --pages ...
スキャン PDF の OCRpytesseractまず画像に変換
PDF フォーム入力pdf-lib または pypdf (FORMS.md を参照)FORMS.md を参照

次のステップ

  • 高度な pypdfium2 の使用方法については、REFERENCE.md を参照してください
  • JavaScript ライブラリ (pdf-lib) については、REFERENCE.md を参照してください
  • PDF フォームに入力する必要がある場合は、FORMS.md の指示に従ってください
  • トラブルシューティングガイドについては、REFERENCE.md を参照してください

Individual skills in this repo

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

LiChangZheng10086/doyin_ai_video

Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction.

LiChangZheng10086/doyin_ai_video

Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER — read BEFORE opening the target file; don't skip because it "looks like a one-liner" — whenever: the prompt names Claude/Anthropic in any form (Claude, Anthropic, Fable, Opus, Sonnet, Haiku, `anthropic`, `@anthropic-ai`, `claude-*`, `us.anthropic.*`, `[1m]`); the user asks about an LLM (pricing/model choice/limits/caching) — never answer from memory; OR the task is LLM-shaped with provider unstated (agent/MCP/tool-definition/multi-agent/RAG/LLM-judge/computer-use; generate/summarize/extract/classify/rewrite/converse over NL; debugging refusals/cutoffs/streaming/tool-calls/tokens). SKIP only when another provider is being worked on (overrides all triggers): OpenAI/GPT/Gemini/Llama/Mistral/Cohere/Ollama named in the query; OR `grep -rE 'openai|langchain_openai|google.generativeai|genai|mistralai|cohere|ollama'` over the project hits (run this grep FIR...

LiChangZheng10086/doyin_ai_video

Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.

LiChangZheng10086/doyin_ai_video

Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.

LiChangZheng10086/doyin_ai_video

Grill me about specs for the workflows I want to build, within this workspace.

LiChangZheng10086/doyin_ai_video

智能 PPT 生成器。支持 7 种视觉风格(乐高/波普/黏土/黑白/商务/学术/科技),具备根据内容自动推荐风格、生成大纲、绘制配图并组装成片的全自动能力。

LiChangZheng10086/doyin_ai_video

Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions \"deck,\" \"slides,\" \"presentation,\" or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.

LiChangZheng10086/doyin_ai_video

Diagnose and fix React codebase health issues. Use when reviewing React code, fixing performance problems, auditing security, or improving code quality.

LiChangZheng10086/doyin_ai_video

Sentry error monitoring and performance tracing patterns for Next.js applications.

LiChangZheng10086/doyin_ai_video

Simplify and refine recently modified code for clarity and consistency. Use after writing code to improve readability without changing functionality.

LiChangZheng10086/doyin_ai_video

✅ "你知道今天所有大模型能读懂你的话,全靠一个叫Transformer的架构吗?"

LiChangZheng10086/doyin_ai_video

Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like \"the xlsx in my downloads\") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.

関連スキル