pdf

Utilisez cette compétence chaque fois que l'utilisateur souhaite effectuer une opération sur des fichiers PDF : lecture, extraction, fusion, séparation, rotation, filigrane, création, remplissage de formulaires, chiffrement/déchiffrement, extraction d'images ou OCR.

Qu'est-ce que pdf ?

Cette compétence fournit un guide complet pour le traitement de fichiers PDF en utilisant des bibliothèques Python (pypdf, pdfplumber, reportlab) et des outils en ligne de commande (pdftotext, qpdf, pdftk). Elle permet de réaliser toutes les opérations courantes : fusion et séparation de PDF, extraction de texte et de tableaux, rotation de pages, ajout de filigrane, création de nouveaux PDF, extraction d'images, OCR sur des PDF scannés, et protection par mot de passe. Elle prend en charge les environnements de développement Python et les systèmes Linux/macOS via des outils CLI. La compétence est conçue pour les développeurs et les utilisateurs d'agents IA qui ont besoin de manipuler des PDF de manière fiable et efficace. Elle renvoie également vers FORMS.md pour le remplissage de formulaires PDF et vers REFERENCE.md pour les fonctionnalités avancées.

Compatible avec~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/anthropics/skills/tree/main/skills/pdf

Installed? Explore more Développement et programmation skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

Demander à votre IA préférée

Ouvre une nouvelle conversation avec cette compétence d'agent déjà préchargée.

Documentation

Guide de traitement des PDF

Présentation

Ce guide couvre les opérations essentielles de traitement des PDF à l'aide de bibliothèques Python et d'outils en ligne de commande. Pour les fonctionnalités avancées, les bibliothèques JavaScript et des exemples détaillés, consultez REFERENCE.md. Si vous devez remplir un formulaire PDF, lisez FORMS.md et suivez ses instructions.

Démarrage rapide

from pypdf import PdfReader, PdfWriter

# Lire un PDF
reader = PdfReader("document.pdf")
print(f"Pages : {len(reader.pages)}")

# Extraire le texte
text = ""
for page in reader.pages:
    text += page.extract_text()

Bibliothèques Python

pypdf - Opérations de base

Fusionner des 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)

Séparer un 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)

Extraire les métadonnées

reader = PdfReader("document.pdf")
meta = reader.metadata
print(f"Titre : {meta.title}")
print(f"Auteur : {meta.author}")
print(f"Sujet : {meta.subject}")
print(f"Créateur : {meta.creator}")

Faire pivoter les pages

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

page = reader.pages[0]
page.rotate(90)  # Rotation de 90 degrés dans le sens horaire
writer.add_page(page)

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

pdfplumber - Extraction de texte et de tableaux

Extraire du texte avec mise en page

import pdfplumber

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

Extraire des tableaux

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"Tableau {j+1} à la page {i+1} :")
            for row in table:
                print(row)

Extraction avancée de tableaux

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:  # Vérifier si le tableau n'est pas vide
                df = pd.DataFrame(table[1:], columns=table[0])
                all_tables.append(df)

# Combiner tous les tableaux
if all_tables:
    combined_df = pd.concat(all_tables, ignore_index=True)
    combined_df.to_excel("extracted_tables.xlsx", index=False)

reportlab - Créer des PDF

Création basique de PDF

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

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

# Ajouter du texte
c.drawString(100, height - 100, "Bonjour le monde !")
c.drawString(100, height - 120, "Ceci est un PDF créé avec reportlab")

# Ajouter une ligne
c.line(100, height - 140, 400, height - 140)

# Sauvegarder
c.save()

Créer un PDF avec plusieurs pages

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 = []

# Ajouter du contenu
title = Paragraph("Titre du rapport", styles['Title'])
story.append(title)
story.append(Spacer(1, 12))

body = Paragraph("Ceci est le corps du rapport. " * 20, styles['Normal'])
story.append(body)
story.append(PageBreak())

# Page 2
story.append(Paragraph("Page 2", styles['Heading1']))
story.append(Paragraph("Contenu de la page 2", styles['Normal']))

# Construire le PDF
doc.build(story)

Indices et exposants

IMPORTANT : N'utilisez jamais les caractères Unicode d'indice/exposant (₀₁₂₃₄₅₆₇₈₉, ⁰¹²³⁴⁵⁶⁷⁸⁹) dans les PDF ReportLab. Les polices intégrées ne contiennent pas ces glyphes, ce qui les fait apparaître comme des rectangles noirs pleins.

Utilisez plutôt les balises XML de ReportLab dans les objets Paragraph :

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

styles = getSampleStyleSheet()

# Indices : utiliser la balise <sub>
chemical = Paragraph("H<sub>2</sub>O", styles['Normal'])

# Exposants : utiliser la balise <super>
squared = Paragraph("x<super>2</super> + y<super>2</super>", styles['Normal'])

Pour le texte dessiné sur le canvas (pas les objets Paragraph), ajustez manuellement la taille et la position de la police plutôt que d'utiliser des indices/exposants Unicode.

Outils en ligne de commande

pdftotext (poppler-utils)

# Extraire le texte
pdftotext input.pdf output.txt

# Extraire le texte en conservant la mise en page
pdftotext -layout input.pdf output.txt

# Extraire des pages spécifiques
pdftotext -f 1 -l 5 input.pdf output.txt  # Pages 1-5

qpdf

# Fusionner des PDF
qpdf --empty --pages file1.pdf file2.pdf -- merged.pdf

# Séparer des pages
qpdf input.pdf --pages . 1-5 -- pages1-5.pdf
qpdf input.pdf --pages . 6-10 -- pages6-10.pdf

# Faire pivoter des pages
qpdf input.pdf output.pdf --rotate=+90:1  # Rotation de la page 1 de 90 degrés

# Supprimer le mot de passe
qpdf --password=mymotdepasse --decrypt encrypted.pdf decrypted.pdf

pdftk (si disponible)

# Fusionner
pdftk file1.pdf file2.pdf cat output merged.pdf

# Séparer
pdftk input.pdf burst

# Faire pivoter
pdftk input.pdf rotate 1east output rotated.pdf

Tâches courantes

Extraire le texte de PDF scannés

# Nécessite : pip install pytesseract pdf2image
import pytesseract
from pdf2image import convert_from_path

# Convertir le PDF en images
images = convert_from_path('scanned.pdf')

# OCR pour chaque page
text = ""
for i, image in enumerate(images):
    text += f"Page {i+1} :\n"
    text += pytesseract.image_to_string(image)
    text += "\n\n"

print(text)

Ajouter un filigrane

from pypdf import PdfReader, PdfWriter

# Créer un filigrane (ou charger un existant)
watermark = PdfReader("watermark.pdf").pages[0]

# Appliquer à toutes les pages
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)

Extraire des images

# En utilisant pdfimages (poppler-utils)
pdfimages -j input.pdf output_prefix

# Cela extrait toutes les images sous la forme output_prefix-000.jpg, output_prefix-001.jpg, etc.

Protection par mot de passe

from pypdf import PdfReader, PdfWriter

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

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

# Ajouter un mot de passe
writer.encrypt("motdepasseutilisateur", "motdepasseproprietaire")

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

Référence rapide

TâcheMeilleur outilCommande/Code
Fusionner des PDFpypdfwriter.add_page(page)
Séparer des PDFpypdfUn fichier par page
Extraire du textepdfplumberpage.extract_text()
Extraire des tableauxpdfplumberpage.extract_tables()
Créer des PDFreportlabCanvas ou Platypus
Fusion en ligne de commandeqpdfqpdf --empty --pages ...
OCR sur PDF scannéspytesseractConvertir d'abord en image
Remplir des formulaires PDFpdf-lib ou pypdf (voir FORMS.md)Voir FORMS.md

Prochaines étapes

  • Pour une utilisation avancée de pypdfium2, consultez REFERENCE.md
  • Pour les bibliothèques JavaScript (pdf-lib), consultez REFERENCE.md
  • Si vous devez remplir un formulaire PDF, suivez les instructions dans FORMS.md
  • Pour des guides de dépannage, consultez REFERENCE.md

Individual skills in this repo

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

academy-guide

Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials, and use cases from Claude Academy (academy.claude.com), Anthropic's learning hub. Trigger on: "how do I", "how can I", "getting started with", "what can Claude do", "teach me", "learn to use"; questions about artifacts, projects, skills, plugins, connectors, MCP; requests about rolling Claude out to a team, class, or organization; and any ask for training materials, onboarding content, or learning resources. Use it when the user is learning how to use a feature or product — not when they are mid-task and just want the task done. This skill composes with other skills: after consulting product documentation to answer how a Claude feature works, also check here for a matching course or tutorial — a docs-grounded answer and an Academy recommendation belong together. Only recommend on a strong match; never invent Academy content.

algorithmic-art

Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems. Create original algorithmic art rather than copying existing artists

anthropics/template-skill

Replace with description of the skill and when Claude should use it.

brand-guidelines

Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.

canvas-design

Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists

claude-api

|-

discernment-nudge

After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals, or emails, estimates or projections, analysis or interpretation of data, factual claims they may rely on, or a multi-step argument — invoke this skill BEFORE finalizing your reply and then, if it applies, append 2-3 short follow-up questions, each tied to something specific in what you just produced, that help the user check key facts, probe the reasoning or assumptions, and notice missing context. Do this at most once per conversation. Skip it when the user asked a trivial how-to or simple lookup, wants a purely educational explanation, asked you only to format, convert, or assemble a file from content they provided, is writing code they will run, is doing creative writing or casual chat, or already asked you to double-check, cite, or review — the skill file explains these boundaries and the exact output format.

doc-coauthoring

Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision docs, or similar structured content. This workflow helps users efficiently transfer context, refine content through iteration, and verify the doc works for readers. Trigger when user mentions writing docs, creating proposals, drafting specs, or similar documentation tasks.

docx

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.

frontend-design

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.

internal-comms

A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).

mcp-builder

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

pptx

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.

skill-creator

Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill

slack-gif-creator

Knowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like

theme-factory

Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.

webapp-testing

Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.

web-artifacts-builder

Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use for complex artifacts requiring state management, routing, or shadcn/ui components - not for simple single-file HTML/JSX artifacts.

xlsx

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.

Skills associés